1
1
import { test , expect } from "@playwright/test"
2
- import { CODE_SERVER_ADDRESS , PASSWORD } from "../utils/constants"
2
+ import { PASSWORD } from "../utils/constants"
3
+ import { CodeServer } from "./models/CodeServer"
3
4
4
5
test . describe ( "login" , ( ) => {
5
6
// Reset the browser so no cookies are persisted
@@ -9,26 +10,32 @@ test.describe("login", () => {
9
10
storageState : { } ,
10
11
} ,
11
12
}
13
+ let codeServer : CodeServer
14
+
15
+ test . beforeEach ( async ( { page } ) => {
16
+ codeServer = new CodeServer ( page )
17
+ await codeServer . navigate ( )
18
+ } )
12
19
13
20
test ( "should see the login page" , options , async ( { page } ) => {
14
- await page . goto ( CODE_SERVER_ADDRESS , { waitUntil : "networkidle" } )
15
21
// It should send us to the login page
16
22
expect ( await page . title ( ) ) . toBe ( "code-server login" )
17
23
} )
18
24
19
25
test ( "should be able to login" , options , async ( { page } ) => {
20
- await page . goto ( CODE_SERVER_ADDRESS , { waitUntil : "networkidle" } )
21
26
// Type in password
22
27
await page . fill ( ".password" , PASSWORD )
23
28
// Click the submit button and login
24
29
await page . click ( ".submit" )
25
30
await page . waitForLoadState ( "networkidle" )
31
+ // We do this because occassionally code-server doesn't load on Firefox
32
+ // but loads if you reload once or twice
33
+ await codeServer . reloadUntilEditorIsVisible ( )
26
34
// Make sure the editor actually loaded
27
- expect ( await page . isVisible ( "div.monaco-workbench" ) ) . toBe ( true )
35
+ expect ( await codeServer . isEditorVisible ( ) ) . toBe ( true )
28
36
} )
29
37
30
38
test ( "should see an error message for missing password" , options , async ( { page } ) => {
31
- await page . goto ( CODE_SERVER_ADDRESS , { waitUntil : "networkidle" } )
32
39
// Skip entering password
33
40
// Click the submit button and login
34
41
await page . click ( ".submit" )
@@ -37,7 +44,6 @@ test.describe("login", () => {
37
44
} )
38
45
39
46
test ( "should see an error message for incorrect password" , options , async ( { page } ) => {
40
- await page . goto ( CODE_SERVER_ADDRESS , { waitUntil : "networkidle" } )
41
47
// Type in password
42
48
await page . fill ( ".password" , "password123" )
43
49
// Click the submit button and login
@@ -47,7 +53,6 @@ test.describe("login", () => {
47
53
} )
48
54
49
55
test ( "should hit the rate limiter for too many unsuccessful logins" , options , async ( { page } ) => {
50
- await page . goto ( CODE_SERVER_ADDRESS , { waitUntil : "networkidle" } )
51
56
// Type in password
52
57
await page . fill ( ".password" , "password123" )
53
58
// Click the submit button and login
0 commit comments