@@ -14,7 +14,10 @@ BeforeAll(async function () {
14
14
headless : true ,
15
15
args : [ '--no-sandbox' , '--disable-setuid-sandbox' ]
16
16
} ) ;
17
- context = await browser . newContext ( ) ;
17
+ context = await browser . newContext ( {
18
+ // Increase timeout for slower Docker environments
19
+ timeout : 30000
20
+ } ) ;
18
21
} ) ;
19
22
20
23
AfterAll ( async function ( ) {
@@ -26,8 +29,11 @@ Given('the Staging site is started', async function () {
26
29
page = await context . newPage ( ) ;
27
30
28
31
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
+ } ) ;
31
37
32
38
if ( ! response || ! response . ok ( ) ) {
33
39
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 () {
43
49
}
44
50
45
51
// 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
+ } ) ;
47
56
48
57
if ( ! response || ! response . ok ( ) ) {
49
58
throw new Error ( `Index page failed to load. Status: ${ response ? response . status ( ) : 'No response' } ` ) ;
50
59
}
51
60
52
61
// Verify the page has loaded by checking for basic HTML structure
53
- await page . waitForSelector ( 'html' ) ;
62
+ await page . waitForSelector ( 'html' , { timeout : 10000 } ) ;
54
63
} ) ;
55
64
56
65
Then ( '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 () {
59
68
}
60
69
61
70
// 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 ) {
67
76
throw new Error ( 'Logo (favicon.png) is not displayed in a nav element' ) ;
68
77
}
69
78
} ) ;
0 commit comments