Skip to content

Commit 2cd08d6

Browse files
Add comments and improve hideContentOnSubmit default handling
Co-authored-by: JamesPHoughton <4304478+JamesPHoughton@users.noreply.github.com>
1 parent 65f5098 commit 2cd08d6

2 files changed

Lines changed: 88 additions & 1 deletion

File tree

client/src/components/ConditionalRender.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,13 @@ export function SubmissionConditionalRender({ children }) {
170170
if (player?.stage?.get("submit")) {
171171
const hideContentOnSubmit = player.get("hideContentOnSubmit");
172172

173-
// If hideContentOnSubmit is false, continue showing content
173+
// If hideContentOnSubmit is explicitly false, continue showing content
174174
if (hideContentOnSubmit === false) {
175175
return children;
176176
}
177177

178178
// Default behavior: hide content and show waiting message
179+
// This happens when hideContentOnSubmit is true, undefined, or null
179180
if (!players || players.length === 1) {
180181
return <Loading />;
181182
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Test for hideContentOnSubmit functionality
2+
3+
describe("hideContentOnSubmit Feature Test", { retries: { runMode: 2, openMode: 0 } }, () => {
4+
5+
beforeEach(() => {
6+
cy.empiricaClearBatches();
7+
cy.exec("truncate -s 0 ../data/empirica.log");
8+
9+
const configJson = `{
10+
"batchName": "cytest_hideContentOnSubmit",
11+
"cdn": "test",
12+
"treatmentFile": "projects/example/cypress.treatments.yaml",
13+
"customIdInstructions": "none",
14+
"platformConsent": "US",
15+
"consentAddendum": "none",
16+
"checkAudio": false,
17+
"checkVideo": false,
18+
"introSequence": "none",
19+
"treatments": [
20+
"cypress_hideContentOnSubmit_test"
21+
],
22+
"payoffs": "equal",
23+
"knockdowns": "none",
24+
"dispatchWait": 1,
25+
"launchDate": "immediate",
26+
"centralPrereg": false,
27+
"preregRepos": [],
28+
"dataRepos": [],
29+
"videoStorage": {
30+
"bucket": "deliberation-lab-recordings-test",
31+
"region": "us-east-1"
32+
},
33+
"exitCodes": {
34+
"complete": "cypressComplete",
35+
"error": "cypressError",
36+
"lobbyTimeout": "cypressLobbyTimeout",
37+
"failedEquipmentCheck": "cypressFailedEquipmentCheck"
38+
}
39+
}`;
40+
41+
cy.empiricaCreateBatch(configJson);
42+
cy.empiricaStartBatch("cytest_hideContentOnSubmit");
43+
});
44+
45+
it("should hide content when hideContentOnSubmit is true, and keep content when false", () => {
46+
// Start with two players
47+
cy.stepPlayerStart("playerA", "MyId");
48+
cy.stepPlayerStart("playerB", "MyId");
49+
50+
cy.stepJoin("playerA");
51+
cy.stepJoin("playerB");
52+
53+
// Stage 1: Test hideContentOnSubmit: true (should hide content)
54+
cy.get('[test-player-id="playerA"]').contains("Test Hide Content True (Default)");
55+
cy.get('[test-player-id="playerA"]').contains("Submit and Hide Content");
56+
cy.get('[test-player-id="playerA"] [data-test="submitButton"]').click();
57+
58+
// Content should be hidden after submit
59+
cy.get('[test-player-id="playerA"]').should('not.contain', 'HTML');
60+
cy.get('[test-player-id="playerA"]').contains("Please wait for other participant(s).");
61+
62+
// Submit second player to advance
63+
cy.get('[test-player-id="playerB"] [data-test="submitButton"]').click();
64+
65+
// Stage 2: Test hideContentOnSubmit: false (should keep content)
66+
cy.get('[test-player-id="playerA"]').contains("Test Hide Content False");
67+
cy.get('[test-player-id="playerA"]').contains("Submit but Keep Content");
68+
cy.get('[test-player-id="playerA"] [data-test="submitButton"]').click();
69+
70+
// Content should still be visible after submit (this is the new behavior)
71+
cy.get('[test-player-id="playerA"]').should('contain', 'Rainbow');
72+
cy.get('[test-player-id="playerA"]').should('not.contain', 'Please wait for other participant(s).');
73+
74+
// Submit second player to advance
75+
cy.get('[test-player-id="playerB"] [data-test="submitButton"]').click();
76+
77+
// Stage 3: Test default behavior (should hide content)
78+
cy.get('[test-player-id="playerA"]').contains("Test Hide Content Default");
79+
cy.get('[test-player-id="playerA"]').contains("Submit (Default Behavior)");
80+
cy.get('[test-player-id="playerA"] [data-test="submitButton"]').click();
81+
82+
// Content should be hidden (default behavior)
83+
cy.get('[test-player-id="playerA"]').should('not.contain', 'Wizard');
84+
cy.get('[test-player-id="playerA"]').contains("Please wait for other participant(s).");
85+
});
86+
});

0 commit comments

Comments
 (0)