@@ -14,7 +14,10 @@ BeforeAll(async function () {
1414 headless : true ,
1515 args : [ '--no-sandbox' , '--disable-setuid-sandbox' ]
1616 } ) ;
17- context = await browser . newContext ( ) ;
17+ context = await browser . newContext ( {
18+ // Increase timeout for slower Docker environments
19+ timeout : 30000
20+ } ) ;
1821} ) ;
1922
2023AfterAll ( async function ( ) {
@@ -26,8 +29,11 @@ Given('the Staging site is started', async function () {
2629 page = await context . newPage ( ) ;
2730
2831 try {
29- // Verify that the BASE_URL can be reached
30- const response = await page . goto ( BASE_URL , { waitUntil : 'networkidle' } ) ;
32+ // Verify that the BASE_URL can be reached (allow redirects)
33+ const response = await page . goto ( BASE_URL , {
34+ waitUntil : 'networkidle' ,
35+ timeout : 30000
36+ } ) ;
3137
3238 if ( ! response || ! response . ok ( ) ) {
3339 throw new Error ( `Failed to reach staging site at ${ BASE_URL } . Status: ${ response ? response . status ( ) : 'No response' } ` ) ;
@@ -43,14 +49,17 @@ When('the index page is visited', async function () {
4349 }
4450
4551 // Navigate to the index page and ensure it loads without HTTP errors
46- const response = await page . goto ( BASE_URL , { waitUntil : 'networkidle' } ) ;
52+ const response = await page . goto ( BASE_URL , {
53+ waitUntil : 'networkidle' ,
54+ timeout : 30000
55+ } ) ;
4756
4857 if ( ! response || ! response . ok ( ) ) {
4958 throw new Error ( `Index page failed to load. Status: ${ response ? response . status ( ) : 'No response' } ` ) ;
5059 }
5160
5261 // Verify the page has loaded by checking for basic HTML structure
53- await page . waitForSelector ( 'html' ) ;
62+ await page . waitForSelector ( 'html' , { timeout : 10000 } ) ;
5463} ) ;
5564
5665Then ( 'the Logo should be displayed in the top left corner' , async function ( ) {
@@ -59,11 +68,11 @@ Then('the Logo should be displayed in the top left corner', async function () {
5968 }
6069
6170 // Check that favicon.png is somewhere nested under a <nav> element
62- const faviconInNav = await page . locator ( 'nav img[src*=" favicon.png"]' ) . first ( ) ;
63-
64- const isVisible = await faviconInNav . isVisible ( ) . catch ( ( ) => false ) ;
65-
66- if ( ! isVisible ) {
71+ // This covers both relative paths ( favicon.png) and absolute URLs containing favicon.png
72+ try {
73+ const faviconInNav = await page . locator ( 'nav img[src*="favicon.png"]' ) . first ( ) ;
74+ await faviconInNav . waitFor ( { state : 'visible' , timeout : 10000 } ) ;
75+ } catch ( error ) {
6776 throw new Error ( 'Logo (favicon.png) is not displayed in a nav element' ) ;
6877 }
6978} ) ;
0 commit comments