@@ -21,15 +21,25 @@ async function home(page: Page, context: Context) {
2121 await page . goto ( FRONTEND_BASE_URL )
2222
2323 const carousel = await page . getByTestId ( "resource-carousel" )
24- const articlesCount = await carousel . locator ( "article" ) . count ( )
24+ const articles = carousel . locator ( "article" )
25+
26+ try {
27+ await articles . first ( ) . waitFor ( { timeout : 10_000 } )
28+ } catch {
29+ // carousel never populated; let the assertion below report it
30+ }
31+
32+ const articlesCount = await articles . count ( )
33+
2534 await check ( carousel , {
2635 "home page carousel has 12 items" : ( ) => articlesCount === 12 ,
2736 } )
2837
29- await carousel
30- . locator ( "article" )
31- . nth ( randomIntBetween ( 0 , articlesCount - 1 ) )
32- . click ( )
38+ if ( articlesCount === 0 ) {
39+ return
40+ }
41+
42+ await articles . nth ( randomIntBetween ( 0 , articlesCount - 1 ) ) . click ( )
3343}
3444
3545async function search ( page : Page , context : Context ) {
@@ -53,12 +63,18 @@ async function units(page: Page, context: Context) {
5363}
5464
5565async function login ( page : Page , context : Context ) {
56- const credential : AuthCredential = randomItem ( credentials )
66+ const credential : AuthCredential | undefined = randomItem ( credentials )
5767
5868 if ( credential == null ) {
5969 console . log ( "Login > skipping because no credentials provided" )
70+ return
71+ }
72+
73+ if ( ! SSO_BASE_URL ) {
74+ throw Error ( "SSO_BASE_URL must be set to run the login flow" )
6075 }
61- if ( page . url ( ) == "about:blank" ) {
76+
77+ if ( page . url ( ) === "about:blank" ) {
6278 await page . goto ( FRONTEND_BASE_URL )
6379 }
6480
@@ -67,11 +83,22 @@ async function login(page: Page, context: Context) {
6783 const loginButton = page . getByTestId ( "login-button-desktop" )
6884 await loginButton . first ( ) . click ( )
6985
70- await loginKeycloak ( page , credential , context )
86+ let loggedIn = false
7187
72- await page . waitForURL ( / .* \/ d a s h b o a r d .* / )
88+ try {
89+ await loginKeycloak ( page , credential , context )
90+ await page . locator ( '[aria-label="User Menu"]' ) . waitFor ( { timeout : 10_000 } )
91+ loggedIn = true
92+ console . log ( "Login > authenticated; user menu visible" )
93+ } catch ( err ) {
94+ console . log (
95+ `Login > failed for '${ credential . email } ' at URL '${ page . url ( ) } ': ${ err } ` ,
96+ )
97+ }
7398
74- console . log ( "Login > reached dashboard" )
99+ check ( null , {
100+ "login succeeded" : ( ) => loggedIn ,
101+ } )
75102}
76103
77104const ESCAPED_SSO_URL = escapeRegex ( SSO_BASE_URL )
0 commit comments