|
| 1 | +const batchConfigFixture = require("../fixtures/mockCDN/test/discussionConditions/test.config.json"); |
| 2 | + |
| 3 | +describe( |
| 4 | + "Discussion Conditions", |
| 5 | + { retries: { runMode: 2, openMode: 0 } }, |
| 6 | + () => { |
| 7 | + beforeEach(() => { |
| 8 | + cy.empiricaClearBatches(); |
| 9 | + |
| 10 | + const config = { |
| 11 | + ...batchConfigFixture, |
| 12 | + }; |
| 13 | + |
| 14 | + cy.empiricaCreateCustomBatch(JSON.stringify(config), {}); |
| 15 | + cy.wait(3000); |
| 16 | + cy.empiricaStartBatch(1); |
| 17 | + }); |
| 18 | + |
| 19 | + it("shows or hides discussion based on conditions and position", () => { |
| 20 | + const playerKeys = [ |
| 21 | + `discCond_A_${Math.floor(Math.random() * 1e13)}`, |
| 22 | + `discCond_B_${Math.floor(Math.random() * 1e13)}`, |
| 23 | + ]; |
| 24 | + const hitId = "discussionConditionsHIT"; |
| 25 | + |
| 26 | + cy.empiricaSetupWindow({ playerKeys, hitId }); |
| 27 | + cy.interceptIpApis(); |
| 28 | + |
| 29 | + // Intro steps |
| 30 | + playerKeys.forEach((playerKey) => { |
| 31 | + cy.stepIntro(playerKey); |
| 32 | + }); |
| 33 | + |
| 34 | + playerKeys.forEach((playerKey) => { |
| 35 | + cy.stepConsent(playerKey); |
| 36 | + cy.stepAttentionCheck(playerKey); |
| 37 | + cy.stepVideoCheck(playerKey, { |
| 38 | + setupMicrophone: false, |
| 39 | + setupCamera: false, |
| 40 | + }); |
| 41 | + cy.stepNickname(playerKey); |
| 42 | + }); |
| 43 | + |
| 44 | + // Lobby |
| 45 | + playerKeys.forEach((playerKey) => { |
| 46 | + cy.waitForGameLoad(playerKey); |
| 47 | + }); |
| 48 | + |
| 49 | + // ===== Stage 1: Setup Choice ===== |
| 50 | + // Both players select "HTML" so the condition `equals HTML, position: all` will be true |
| 51 | + playerKeys.forEach((playerKey) => { |
| 52 | + cy.playerCanSee(playerKey, "Setup Choice"); |
| 53 | + cy.get( |
| 54 | + `[data-player-id="${playerKey}"] [data-test="test/discussionConditions/setupChoice.md"] input[value="HTML"]` |
| 55 | + ).click(); |
| 56 | + }); |
| 57 | + cy.submitPlayers(playerKeys); |
| 58 | + |
| 59 | + // ===== Stage 2: Discussion Condition Met ===== |
| 60 | + // Condition: prompt.setupChoice equals HTML (position: all) → TRUE |
| 61 | + // Discussion should be visible (two-column layout with text chat) |
| 62 | + playerKeys.forEach((playerKey) => { |
| 63 | + cy.playerCanSee(playerKey, "Discussion Condition Met"); |
| 64 | + cy.get(`[data-player-id="${playerKey}"] [data-test="discussion"]`).should( |
| 65 | + "be.visible" |
| 66 | + ); |
| 67 | + // The no-discussion single-column layout should NOT be present |
| 68 | + cy.get( |
| 69 | + `[data-player-id="${playerKey}"] [data-test="stageContent"]` |
| 70 | + ).should("not.exist"); |
| 71 | + }); |
| 72 | + |
| 73 | + // Verify text chat works |
| 74 | + cy.typeInChat(playerKeys[0], "Hello from player A"); |
| 75 | + cy.get(`[data-player-id="${playerKeys[1]}"]`).contains( |
| 76 | + "Hello from player A" |
| 77 | + ); |
| 78 | + |
| 79 | + cy.submitPlayers(playerKeys); |
| 80 | + |
| 81 | + // ===== Stage 3: Discussion Condition Not Met ===== |
| 82 | + // Condition: prompt.setupChoice equals Markdown (position: all) → FALSE |
| 83 | + // Discussion should be hidden, single-column layout should render |
| 84 | + playerKeys.forEach((playerKey) => { |
| 85 | + cy.playerCanSee(playerKey, "Discussion Condition Not Met"); |
| 86 | + // Discussion panel should NOT exist |
| 87 | + cy.get( |
| 88 | + `[data-player-id="${playerKey}"] [data-test="discussion"]` |
| 89 | + ).should("not.exist"); |
| 90 | + // Single-column layout should be present |
| 91 | + cy.get( |
| 92 | + `[data-player-id="${playerKey}"] [data-test="stageContent"]` |
| 93 | + ).should("be.visible"); |
| 94 | + }); |
| 95 | + cy.submitPlayers(playerKeys); |
| 96 | + |
| 97 | + // ===== Stage 4: Discussion Position Hidden ===== |
| 98 | + // hideFromPositions: [0, 1] hides from both players → single-column layout |
| 99 | + playerKeys.forEach((playerKey) => { |
| 100 | + cy.playerCanSee(playerKey, "Discussion Position Hidden"); |
| 101 | + cy.get( |
| 102 | + `[data-player-id="${playerKey}"] [data-test="discussion"]` |
| 103 | + ).should("not.exist"); |
| 104 | + cy.get( |
| 105 | + `[data-player-id="${playerKey}"] [data-test="stageContent"]` |
| 106 | + ).should("be.visible"); |
| 107 | + }); |
| 108 | + cy.submitPlayers(playerKeys); |
| 109 | + |
| 110 | + // Exit |
| 111 | + playerKeys.forEach((playerKey) => { |
| 112 | + cy.stepQCSurvey(playerKey); |
| 113 | + }); |
| 114 | + }); |
| 115 | + } |
| 116 | +); |
0 commit comments