forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.spec.js
79 lines (67 loc) · 2.83 KB
/
config.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { test, expect } from "@playwright/test";
import { start, stop, baseUrl } from "./evcc";
const CONFIG_GRID_ONLY = "config-grid-only.evcc.yaml";
test.use({ baseURL: baseUrl() });
test.beforeAll(async () => {
await start(CONFIG_GRID_ONLY, "password.sql");
});
test.afterAll(async () => {
await stop();
});
async function login(page) {
await page.locator("#loginPassword").fill("secret");
await page.getByRole("button", { name: "Login" }).click();
await expect(page.locator("#loginPassword")).not.toBeVisible();
}
async function enableExperimental(page) {
await page
.getByTestId("generalconfig-experimental")
.getByRole("button", { name: "edit" })
.click();
await page.getByLabel("Experimental 🧪").click();
await page.getByRole("button", { name: "Close" }).click();
}
test.describe("basics", async () => {
test("navigation to config", async ({ page }) => {
await page.goto("/");
await page.getByTestId("topnavigation-button").click();
await page.getByRole("link", { name: "Configuration" }).click();
await login(page);
await expect(page.getByRole("heading", { name: "Configuration" })).toBeVisible();
});
test.skip("alert box should always be visible", async ({ page }) => {
await page.goto("/#/config");
await login(page);
await enableExperimental(page);
await expect(page.getByRole("alert")).toBeVisible();
});
});
test.describe("general", async () => {
test("change site title", async ({ page }) => {
// initial value on main ui
await page.goto("/");
await expect(page.getByRole("heading", { name: "Hello World" })).toBeVisible();
// change value in config
await page.goto("/#/config");
await login(page);
await enableExperimental(page);
await expect(page.getByTestId("generalconfig-title")).toContainText("Hello World");
await page.getByTestId("generalconfig-title").getByRole("button", { name: "edit" }).click();
const modal = page.getByTestId("title-modal");
await expect(modal).toBeVisible();
await modal.getByLabel("Title").fill("Whoops World");
// close modal and ignore entry on cancel
await modal.getByRole("button", { name: "Cancel" }).click();
await expect(modal).not.toBeVisible();
await expect(page.getByTestId("generalconfig-title")).toContainText("Hello World");
// change and save value
await page.getByTestId("generalconfig-title").getByRole("button", { name: "edit" }).click();
await modal.getByLabel("Title").fill("Ahoy World");
await modal.getByRole("button", { name: "Save" }).click();
await expect(modal).not.toBeVisible();
await expect(page.getByTestId("generalconfig-title")).toContainText("Ahoy World");
// check changed value on main ui
await page.getByTestId("home-link").click();
await expect(page.getByRole("heading", { name: "Ahoy World" })).toBeVisible();
});
});