11import { 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"
34
45test . describe ( "login" , ( ) => {
56 // Reset the browser so no cookies are persisted
@@ -9,26 +10,32 @@ test.describe("login", () => {
910 storageState : { } ,
1011 } ,
1112 }
13+ let codeServer : CodeServer
14+
15+ test . beforeEach ( async ( { page } ) => {
16+ codeServer = new CodeServer ( page )
17+ await codeServer . navigate ( )
18+ } )
1219
1320 test ( "should see the login page" , options , async ( { page } ) => {
14- await page . goto ( CODE_SERVER_ADDRESS , { waitUntil : "networkidle" } )
1521 // It should send us to the login page
1622 expect ( await page . title ( ) ) . toBe ( "code-server login" )
1723 } )
1824
1925 test ( "should be able to login" , options , async ( { page } ) => {
20- await page . goto ( CODE_SERVER_ADDRESS , { waitUntil : "networkidle" } )
2126 // Type in password
2227 await page . fill ( ".password" , PASSWORD )
2328 // Click the submit button and login
2429 await page . click ( ".submit" )
2530 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 ( )
2634 // Make sure the editor actually loaded
27- expect ( await page . isVisible ( "div.monaco-workbench" ) ) . toBe ( true )
35+ expect ( await codeServer . isEditorVisible ( ) ) . toBe ( true )
2836 } )
2937
3038 test ( "should see an error message for missing password" , options , async ( { page } ) => {
31- await page . goto ( CODE_SERVER_ADDRESS , { waitUntil : "networkidle" } )
3239 // Skip entering password
3340 // Click the submit button and login
3441 await page . click ( ".submit" )
@@ -37,7 +44,6 @@ test.describe("login", () => {
3744 } )
3845
3946 test ( "should see an error message for incorrect password" , options , async ( { page } ) => {
40- await page . goto ( CODE_SERVER_ADDRESS , { waitUntil : "networkidle" } )
4147 // Type in password
4248 await page . fill ( ".password" , "password123" )
4349 // Click the submit button and login
@@ -47,7 +53,6 @@ test.describe("login", () => {
4753 } )
4854
4955 test ( "should hit the rate limiter for too many unsuccessful logins" , options , async ( { page } ) => {
50- await page . goto ( CODE_SERVER_ADDRESS , { waitUntil : "networkidle" } )
5156 // Type in password
5257 await page . fill ( ".password" , "password123" )
5358 // Click the submit button and login
0 commit comments