@@ -64,6 +64,18 @@ async function signUpFresh(page: Page, user: DemoUser, locale: Locale) {
6464 await expect ( page ) . toHaveURL ( / \/ a p p $ / , { timeout : 20_000 } ) ;
6565}
6666
67+ // On a slow runner the welcome tooltip first renders over the card and only
68+ // slides below it a moment later. A click before that slide was lost, so wait
69+ // for the tooltip's final position.
70+ async function welcomeTourSettled ( page : Page ) {
71+ const tooltip = page . locator ( ".react-joyride__tooltip" ) ;
72+ const card = page . locator ( '[data-tour="current-debate"]' ) ;
73+ await expect . poll ( async ( ) => {
74+ const [ tip , target ] = await Promise . all ( [ tooltip . boundingBox ( ) , card . boundingBox ( ) ] ) ;
75+ return ! ! tip && ! ! target && tip . y >= target . y + target . height ;
76+ } , { timeout : 15_000 } ) . toBe ( true ) ;
77+ }
78+
6779async function serverDebates ( user : DemoUser ) {
6880 const userId = await user . userId ( ) ;
6981 const [ { data : debates } , { data : current } ] = await Promise . all ( [
@@ -86,6 +98,7 @@ for (const locale of ["en", "hu"] as const) {
8698 await expect ( tooltip ) . toContainText ( text . firstDebate ) ;
8799 await expect ( page . locator ( "html" ) ) . toHaveAttribute ( "lang" , locale ) ;
88100
101+ await welcomeTourSettled ( page ) ;
89102 await tooltip . getByRole ( "button" , { name : text . startDebate } ) . click ( ) ;
90103 const dialog = page . getByRole ( "dialog" ) ;
91104 await dialog . getByLabel ( text . motionField ) . fill ( text . tourMotion ) ;
@@ -123,6 +136,7 @@ for (const locale of ["en", "hu"] as const) {
123136 test ( `[${ locale } ] a fresh account that skips the tour is offered a debate from its motion` , async ( { page, user } ) => {
124137 test . setTimeout ( 90_000 ) ;
125138 await signUpFresh ( page , user , locale ) ;
139+ await welcomeTourSettled ( page ) ;
126140 await page . locator ( '[data-test-id="button-skip"]' ) . click ( ) ;
127141 await expect ( page . locator ( ".react-joyride__tooltip" ) ) . toHaveCount ( 0 ) ;
128142
0 commit comments