@@ -23,23 +23,35 @@ async function clickStartAndWaitForMap(page) {
2323 await page . waitForTimeout ( 2000 ) ;
2424}
2525
26- async function setTutorialState ( page , step , subStep = 1 ) {
26+ async function goToTutorialStep ( page , step , subStep = 1 ) {
2727 await page . evaluate ( ( { step, subStep } ) => {
28- localStorage . setItem ( 'mapper-tutorial' , JSON . stringify ( {
29- completed : false , dismissed : false ,
30- step, subStep,
31- hasSkippedQuestion : false , skipToastShown : false , returningUser : false ,
32- } ) ) ;
28+ if ( window . __mapper && window . __mapper . tutorialGoToStep ) {
29+ window . __mapper . tutorialGoToStep ( step , subStep ) ;
30+ }
3331 } , { step, subStep } ) ;
32+ await page . waitForTimeout ( 500 ) ;
3433}
3534
3635async function answerQuestion ( page ) {
37- // Wait for quiz option to be visible
38- const opt = page . locator ( '.quiz-option:not([disabled])' ) . first ( ) ;
3936 try {
37+ await page . waitForSelector ( '.quiz-question' , { timeout : 5000 } ) ;
38+ const prevText = await page . textContent ( '.quiz-question' ) ;
39+ const opt = page . locator ( '.quiz-option:not([disabled])' ) . first ( ) ;
4040 await opt . waitFor ( { state : 'visible' , timeout : 5000 } ) ;
4141 await opt . click ( { timeout : 5000 } ) ;
42- await page . waitForTimeout ( 1500 ) ;
42+ // Wait for question to change (auto-advance) or timeout
43+ try {
44+ await page . waitForFunction (
45+ ( prev ) => {
46+ const q = document . querySelector ( '.quiz-question' ) ;
47+ return q && q . textContent !== prev ;
48+ } ,
49+ prevText ,
50+ { timeout : 5000 }
51+ ) ;
52+ } catch {
53+ await page . waitForTimeout ( 1500 ) ;
54+ }
4355 return true ;
4456 } catch { return false ; }
4557}
@@ -67,8 +79,8 @@ test.describe('Tutorial visual verification', () => {
6779 await page . setViewportSize ( { width : 1280 , height : 800 } ) ;
6880 await resetAndLoad ( page ) ;
6981 // Set tutorial to step 6 (Switch Domains) to test highlight on dropdown
70- await setTutorialState ( page , 6 ) ;
7182 await clickStartAndWaitForMap ( page ) ;
83+ await goToTutorialStep ( page , 6 ) ;
7284 await page . waitForTimeout ( 2000 ) ;
7385
7486 // Take screenshot showing the domain selector highlighted (#42)
@@ -133,8 +145,8 @@ test.describe('Tutorial visual verification', () => {
133145 test ( 'Issue #41: Title says "Videos in View"' , async ( { page } ) => {
134146 await page . setViewportSize ( { width : 1280 , height : 800 } ) ;
135147 await resetAndLoad ( page ) ;
136- await setTutorialState ( page , 3 , 1 ) ;
137148 await clickStartAndWaitForMap ( page ) ;
149+ await goToTutorialStep ( page , 3 , 1 ) ;
138150 await page . waitForSelector ( '#tutorial-modal' , { timeout : 10000 } ) ;
139151 await page . waitForTimeout ( 800 ) ;
140152
@@ -146,8 +158,8 @@ test.describe('Tutorial visual verification', () => {
146158 test ( 'Issue #44: Expertise text softened' , async ( { page } ) => {
147159 await page . setViewportSize ( { width : 1280 , height : 800 } ) ;
148160 await resetAndLoad ( page ) ;
149- await setTutorialState ( page , 8 ) ;
150161 await clickStartAndWaitForMap ( page ) ;
162+ await goToTutorialStep ( page , 8 ) ;
151163 await page . waitForSelector ( '#tutorial-modal' , { timeout : 10000 } ) ;
152164 await page . waitForTimeout ( 500 ) ;
153165
@@ -159,32 +171,26 @@ test.describe('Tutorial visual verification', () => {
159171 test ( 'Issue #45: New tutorial steps exist (modes, save/load, about)' , async ( { page } ) => {
160172 await page . setViewportSize ( { width : 1280 , height : 800 } ) ;
161173 await resetAndLoad ( page ) ;
174+ await clickStartAndWaitForMap ( page ) ;
162175
163176 // Step 11: Question Modes
164- await setTutorialState ( page , 11 ) ;
165- await clickStartAndWaitForMap ( page ) ;
177+ await goToTutorialStep ( page , 11 ) ;
166178 await page . waitForSelector ( '#tutorial-modal' , { timeout : 10000 } ) ;
167179 await page . waitForTimeout ( 500 ) ;
168180 const title11 = await page . textContent ( '[data-tutorial-title]' ) ;
169181 console . log ( 'Issue #45: Step 11 title:' , title11 ) ;
170182 await page . screenshot ( { path : `${ SHOTS } /issue45-step11-modes.png` } ) ;
171183
172184 // Step 12: Save & Load
173- await setTutorialState ( page , 12 ) ;
174- await page . goto ( BASE ) ;
175- await page . waitForSelector ( '#landing-start-btn[data-ready="true"]' , { timeout : 30000 } ) ;
176- await clickStartAndWaitForMap ( page ) ;
185+ await goToTutorialStep ( page , 12 ) ;
177186 await page . waitForSelector ( '#tutorial-modal' , { timeout : 10000 } ) ;
178187 await page . waitForTimeout ( 500 ) ;
179188 const title12 = await page . textContent ( '[data-tutorial-title]' ) ;
180189 console . log ( 'Issue #45: Step 12 title:' , title12 ) ;
181190 await page . screenshot ( { path : `${ SHOTS } /issue45-step12-save-load.png` } ) ;
182191
183192 // Step 13: Learn More
184- await setTutorialState ( page , 13 ) ;
185- await page . goto ( BASE ) ;
186- await page . waitForSelector ( '#landing-start-btn[data-ready="true"]' , { timeout : 30000 } ) ;
187- await clickStartAndWaitForMap ( page ) ;
193+ await goToTutorialStep ( page , 13 ) ;
188194 await page . waitForSelector ( '#tutorial-modal' , { timeout : 10000 } ) ;
189195 await page . waitForTimeout ( 500 ) ;
190196 const title13 = await page . textContent ( '[data-tutorial-title]' ) ;
@@ -277,8 +283,8 @@ test.describe('Tutorial visual verification', () => {
277283 const list = document . querySelector ( '#insights-modal-body .insights-modal-list' ) ;
278284 return {
279285 count : items . length ,
280- maxHeight : list ? .style . maxHeight || getComputedStyle ( list ) . maxHeight ,
281- overflowY : list ? .style . overflowY || getComputedStyle ( list ) . overflowY ,
286+ maxHeight : list ? ( list . style . maxHeight || getComputedStyle ( list ) . maxHeight ) : 'not-found' ,
287+ overflowY : list ? ( list . style . overflowY || getComputedStyle ( list ) . overflowY ) : 'not-found' ,
282288 } ;
283289 } ) ;
284290 console . log ( 'Issue #48: Items:' , info . count , 'maxHeight:' , info . maxHeight , 'overflow:' , info . overflowY ) ;
0 commit comments