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