forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodals.spec.js
101 lines (80 loc) · 3.21 KB
/
modals.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import { test, expect } from "@playwright/test";
import { start, stop, baseUrl } from "./evcc";
import { startSimulator, stopSimulator, simulatorConfig } from "./simulator";
const BASICS_CONFIG = "basics.evcc.yaml";
const UI_ROUTES = ["/", "/#/sessions", "/#/config"];
test.use({ baseURL: baseUrl() });
async function login(page) {
await page.locator("#loginPassword").fill("secret");
await page.getByRole("button", { name: "Login" }).click();
await expect(page.locator("#loginPassword")).not.toBeVisible();
}
test.describe("Basics", async () => {
test.beforeAll(async () => {
await start(BASICS_CONFIG, "password.sql");
});
test.afterAll(async () => {
await stop();
});
test("Menu options. No battery and grid.", async ({ page }) => {
for (const route of UI_ROUTES) {
await page.goto(route);
if (route === "/#/config") {
await login(page);
}
await page.getByTestId("topnavigation-button").click();
await expect(page.getByRole("button", { name: "User Interface" })).toBeVisible();
await expect(page.getByRole("button", { name: "Home Battery" })).not.toBeVisible();
await expect(page.getByRole("button", { name: "Need help?" })).toBeVisible();
}
});
test("Need help?", async ({ page }) => {
await page.goto("/");
await page.getByTestId("topnavigation-button").click();
await page.getByRole("button", { name: "Need help?" }).click();
await expect(page.getByRole("heading", { name: "Need help?" })).toBeVisible();
});
test("User Interface", async ({ page }) => {
await page.goto("/");
await page.getByTestId("topnavigation-button").click();
await page.getByRole("button", { name: "User Interface" }).click();
await expect(page.getByRole("heading", { name: "User Interface" })).toBeVisible();
});
});
test.describe("Advanced", async () => {
test.beforeAll(async () => {
await startSimulator();
await start(simulatorConfig(), "password.sql");
});
test.afterAll(async () => {
await stop();
await stopSimulator();
});
test("Menu options. All available.", async ({ page }) => {
for (const route of UI_ROUTES) {
await page.goto(route);
if (route === "/#/config") {
await login(page);
}
await page.getByTestId("topnavigation-button").click();
await expect(page.getByRole("button", { name: "User Interface" })).toBeVisible();
await expect(page.getByRole("button", { name: "Home Battery" })).toBeVisible();
await expect(page.getByRole("button", { name: "Need help?" })).toBeVisible();
}
});
test("Home Battery from top navigation", async ({ page }) => {
await page.goto("/");
await page.getByTestId("topnavigation-button").click();
await page.getByRole("button", { name: "Home Battery" }).click();
await expect(page.getByRole("heading", { name: "Home Battery" })).toBeVisible();
});
test("Home Battery from energyflow", async ({ page }) => {
await page.goto("/");
await page.getByTestId("energyflow").click();
await page
.getByTestId("energyflow-entry-batterydischarge")
.getByTestId("energyflow-entry-details")
.click();
await expect(page.getByRole("heading", { name: "Home Battery" })).toBeVisible();
});
});