@@ -10,12 +10,13 @@ describe("login", () => {
10
10
let context : BrowserContext
11
11
12
12
beforeAll ( async ( ) => {
13
- browser = await chromium . launch ( { headless : false } )
13
+ browser = await chromium . launch ( )
14
14
context = await browser . newContext ( )
15
15
} )
16
16
17
17
afterAll ( async ( ) => {
18
18
await browser . close ( )
19
+ await context . close ( )
19
20
} )
20
21
21
22
beforeEach ( async ( ) => {
@@ -30,21 +31,25 @@ describe("login", () => {
30
31
31
32
it ( "should see a 'Go Home' button in the Application Menu that goes to coder.com" , async ( ) => {
32
33
await page . goto ( "http://localhost:8080" )
34
+ // In case the page takes a long time to load
35
+ await page . waitForTimeout ( 2000 )
33
36
// Type in password
34
37
await page . fill ( ".password" , PASSWORD )
35
38
// Click the submit button and login
36
39
await page . click ( ".submit" )
37
40
// Click the Applicaiton menu
38
41
await page . click ( ".menubar-menu-button[title='Application Menu']" )
39
42
// See the Go Home button
40
- const goHomeButton = ".home-bar [aria-label='Home'] li "
43
+ const goHomeButton = "a.action-menu-item span [aria-label='Go Home']"
41
44
expect ( await page . isVisible ( goHomeButton ) )
42
- // Hover over element without clicking
43
- await page . hover ( goHomeButton )
44
- // Click the top left corner of the element
45
+ // Click it and navigate to coder.com
45
46
await page . click ( goHomeButton )
46
- // Note: we have to click on <li> in the Go Home button for it to work
47
- // Land on coder.com
48
- // expect(await page.url()).toBe("https://coder.com/")
47
+
48
+ // If there are unsaved changes it will show a dialog
49
+ // asking if you're sure you want to leave
50
+ page . on ( "dialog" , ( dialog ) => dialog . accept ( ) )
51
+
52
+ await page . waitForTimeout ( 5000 )
53
+ expect ( await page . url ( ) ) . toBe ( "https://coder.com/" )
49
54
} )
50
55
} )
0 commit comments