forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
limits.spec.js
112 lines (88 loc) · 4.44 KB
/
limits.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
102
103
104
105
106
107
108
109
110
111
112
import { test, expect } from "@playwright/test";
import { start, stop, baseUrl } from "./evcc";
import { startSimulator, stopSimulator, simulatorUrl, simulatorConfig } from "./simulator";
test.use({ baseURL: baseUrl() });
test.beforeAll(async () => {
await startSimulator();
});
test.afterAll(async () => {
await stopSimulator();
});
test.beforeEach(async ({ page }) => {
await start(simulatorConfig(), "password.sql");
await page.goto(simulatorUrl());
await page.getByLabel("Grid Power").fill("500");
await page.getByTestId("vehicle0").getByLabel("SoC").fill("20");
await page.getByTestId("loadpoint0").getByText("B (connected)").click();
await page.getByRole("button", { name: "Apply changes" }).click();
});
test.afterEach(async () => {
await stop();
});
test.describe("limitSoc", async () => {
test("survives a reload", async ({ page }) => {
await page.goto("/");
await expect(page.getByTestId("limit-soc-value")).toHaveText("100%");
await page.getByTestId("limit-soc").getByRole("combobox").selectOption("50%");
await expect(page.getByTestId("limit-soc-value")).toHaveText("50%");
await page.reload();
await expect(page.getByTestId("limit-soc-value")).toHaveText("50%");
});
test("can be set even if vehicle isn't connected yet", async ({ page }) => {
await page.goto(simulatorUrl());
await page.getByTestId("loadpoint0").getByText("A (disconnected)").click();
await page.getByRole("button", { name: "Apply changes" }).click();
await page.goto("/");
await expect(page.getByTestId("vehicle-title")).toContainText("blauer e-Golf");
await expect(page.getByTestId("vehicle-status")).toHaveText("Disconnected.");
await expect(page.getByTestId("limit-soc-value")).toHaveText("100%");
await page.getByTestId("limit-soc").getByRole("combobox").selectOption("50%");
await expect(page.getByTestId("limit-soc-value")).toHaveText("50%");
await page.goto(simulatorUrl());
await page.getByTestId("loadpoint0").getByText("B (connected)").click();
await page.getByRole("button", { name: "Apply changes" }).click();
await page.goto("/");
await expect(page.getByTestId("limit-soc-value")).toHaveText("50%");
});
test("limit soc should be resetted when vehicle gets disconnected", async ({ page }) => {
await page.goto("/");
await expect(page.getByTestId("limit-soc-value")).toHaveText("100%");
await page.getByTestId("limit-soc").getByRole("combobox").selectOption("50%");
await expect(page.getByTestId("limit-soc-value")).toHaveText("50%");
// disconnect
await page.goto(simulatorUrl());
await page.getByTestId("loadpoint0").getByText("A (disconnected)").click();
await page.getByRole("button", { name: "Apply changes" }).click();
await page.goto("/");
await expect(page.getByTestId("vehicle-status")).toHaveText("Disconnected.");
await expect(page.getByTestId("limit-soc-value")).toHaveText("100%");
// connect
await page.goto(simulatorUrl());
await page.getByTestId("loadpoint0").getByText("B (connected)").click();
await page.getByRole("button", { name: "Apply changes" }).click();
await page.goto("/");
await expect(page.getByTestId("vehicle-status")).toHaveText("Connected.");
await expect(page.getByTestId("limit-soc-value")).toHaveText("100%");
});
});
test.describe("limitEnergy", async () => {
test("survives a reload", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "blauer e-Golf" }).click();
await page.getByRole("button", { name: "grüner Honda e" }).click();
await expect(page.getByTestId("limit-energy-value")).toHaveText("none");
await page.getByTestId("limit-energy").getByRole("combobox").selectOption("10 kWh (+35%)");
await expect(page.getByTestId("limit-energy-value")).toHaveText("10 kWh");
await page.reload();
await expect(page.getByTestId("limit-energy-value")).toHaveText("10 kWh");
});
test("should not be reset on vehicle change", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "blauer e-Golf" }).click();
await page.getByRole("button", { name: "grüner Honda e" }).click();
await page.getByTestId("limit-energy").getByRole("combobox").selectOption("10 kWh (+35%)");
await page.getByRole("button", { name: "grüner Honda e" }).click();
await page.getByRole("button", { name: "Guest vehicle" }).click();
await expect(page.getByTestId("limit-energy-value")).toHaveText("10 kWh");
});
});