1
1
import { test , expect } from "@playwright/test" ;
2
2
import { start , stop , baseUrl } from "./evcc" ;
3
-
3
+ import { expectModalHidden , expectModalVisible } from "./utils" ;
4
4
test . use ( { baseURL : baseUrl ( ) } ) ;
5
5
6
6
const BASIC = "basics.evcc.yaml" ;
@@ -11,7 +11,7 @@ test("set initial password", async ({ page }) => {
11
11
12
12
const modal = page . getByTestId ( "password-modal" ) ;
13
13
14
- await expect ( modal ) . toBeVisible ( ) ;
14
+ await expectModalVisible ( modal ) ;
15
15
await expect ( modal . getByRole ( "heading" , { name : "Set Administrator Password" } ) ) . toBeVisible ( ) ;
16
16
17
17
// empty password
@@ -28,7 +28,7 @@ test("set initial password", async ({ page }) => {
28
28
await modal . getByLabel ( "New password" ) . fill ( "secret" ) ;
29
29
await modal . getByLabel ( "Repeat password" ) . fill ( "secret" ) ;
30
30
await modal . getByRole ( "button" , { name : "Create Password" } ) . click ( ) ;
31
- await expect ( modal ) . not . toBeVisible ( ) ;
31
+ await expectModalHidden ( modal ) ;
32
32
33
33
await stop ( ) ;
34
34
} ) ;
@@ -43,7 +43,7 @@ test("login", async ({ page }) => {
43
43
44
44
// login modal
45
45
const login = page . getByTestId ( "login-modal" ) ;
46
- await expect ( login ) . toBeVisible ( ) ;
46
+ await expectModalVisible ( login ) ;
47
47
await expect ( login . getByRole ( "heading" , { name : "Authentication" } ) ) . toBeVisible ( ) ;
48
48
49
49
// enter wrong password
@@ -54,7 +54,7 @@ test("login", async ({ page }) => {
54
54
// enter correct password
55
55
await login . getByLabel ( "Password" ) . fill ( "secret" ) ;
56
56
await login . getByRole ( "button" , { name : "Login" } ) . click ( ) ;
57
- await expect ( login ) . not . toBeVisible ( ) ;
57
+ await expectModalHidden ( login ) ;
58
58
await expect ( page . getByRole ( "heading" , { name : "Configuration" } ) ) . toBeVisible ( ) ;
59
59
60
60
await stop ( ) ;
@@ -70,7 +70,7 @@ test("http iframe hint", async ({ page }) => {
70
70
71
71
// login modal
72
72
const login = page . getByTestId ( "login-modal" ) ;
73
- await expect ( login ) . toBeVisible ( ) ;
73
+ await expectModalVisible ( login ) ;
74
74
await expect ( login . getByRole ( "heading" , { name : "Authentication" } ) ) . toBeVisible ( ) ;
75
75
76
76
// rewrite api call to simulate lost auth cookie
@@ -97,10 +97,10 @@ test("update password", async ({ page }) => {
97
97
// login modal
98
98
await page . goto ( "/#/config" ) ;
99
99
const loginModal = page . getByTestId ( "login-modal" ) ;
100
- await expect ( loginModal ) . toBeVisible ( ) ;
100
+ await expectModalVisible ( loginModal ) ;
101
101
await loginModal . getByLabel ( "Password" ) . fill ( oldPassword ) ;
102
102
await loginModal . getByRole ( "button" , { name : "Login" } ) . click ( ) ;
103
- await expect ( loginModal ) . not . toBeVisible ( ) ;
103
+ await expectModalHidden ( loginModal ) ;
104
104
105
105
// update password
106
106
await page . getByTestId ( "generalconfig-password" ) . getByRole ( "button" , { name : "edit" } ) . click ( ) ;
@@ -123,11 +123,11 @@ test("update password", async ({ page }) => {
123
123
await expect ( page . getByRole ( "button" , { name : "Logout" } ) ) . not . toBeVisible ( ) ;
124
124
await page . getByRole ( "link" , { name : "Configuration" } ) . click ( ) ;
125
125
const loginNew = page . getByTestId ( "login-modal" ) ;
126
- await expect ( loginNew ) . toBeVisible ( ) ;
126
+ await expectModalVisible ( loginNew ) ;
127
127
await loginNew . getByLabel ( "Password" ) . fill ( newPassword ) ;
128
128
await loginNew . getByRole ( "button" , { name : "Login" } ) . click ( ) ;
129
129
await expect ( page . getByRole ( "heading" , { name : "Configuration" } ) ) . toBeVisible ( ) ;
130
- await expect ( loginNew ) . not . toBeVisible ( ) ;
130
+ await expectModalHidden ( loginNew ) ;
131
131
132
132
// revert to old password
133
133
await page . getByTestId ( "generalconfig-password" ) . getByRole ( "button" , { name : "edit" } ) . click ( ) ;
@@ -148,7 +148,7 @@ test("disable auth", async ({ page }) => {
148
148
149
149
// no password modal
150
150
const modal = page . getByTestId ( "password-modal" ) ;
151
- await expect ( modal ) . not . toBeVisible ( ) ;
151
+ await expectModalHidden ( modal ) ;
152
152
153
153
// configuration page without login
154
154
await page . getByTestId ( "topnavigation-button" ) . click ( ) ;
0 commit comments