forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
persist-target-minsoc.spec.js
196 lines (151 loc) · 7.86 KB
/
persist-target-minsoc.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
const { test, expect } = require("@playwright/test");
const { start, stop, restart } = require("./evcc");
const { startSimulator, stopSimulator, SIMULATOR_URL } = require("./simulator");
const CONFIG = "simulator.evcc.yaml";
test.beforeAll(async () => {
await startSimulator();
});
test.afterAll(async () => {
await stopSimulator();
});
test.beforeEach(async ({ page }) => {
await start(CONFIG);
await page.goto(SIMULATOR_URL);
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("targetSoc", async () => {
test("survives a restart", async ({ page }) => {
await page.goto("/");
await expect(page.getByTestId("target-soc-value")).toHaveText("100%");
await page.getByTestId("target-soc").getByRole("combobox").selectOption("50%");
await expect(page.getByTestId("target-soc-value")).toHaveText("50%");
await restart(CONFIG);
await page.reload();
await expect(page.getByTestId("target-soc-value")).toHaveText("50%");
});
test("can be set even if vehicle isn't connected yet", async ({ page }) => {
await page.goto(SIMULATOR_URL);
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("target-soc-value")).toHaveText("100%");
await page.getByTestId("target-soc").getByRole("combobox").selectOption("50%");
await expect(page.getByTestId("target-soc-value")).toHaveText("50%");
await page.goto(SIMULATOR_URL);
await page.getByTestId("loadpoint0").getByText("B (connected)").click();
await page.getByRole("button", { name: "Apply changes" }).click();
await page.goto("/");
await expect(page.getByTestId("target-soc-value")).toHaveText("50%");
});
test("target soc should be preserved when vehicle gets disconnected", async ({ page }) => {
await page.goto("/");
await expect(page.getByTestId("target-soc-value")).toHaveText("100%");
await page.getByTestId("target-soc").getByRole("combobox").selectOption("50%");
await expect(page.getByTestId("target-soc-value")).toHaveText("50%");
// disconnect
await page.goto(SIMULATOR_URL);
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("target-soc-value")).toHaveText("50%");
// connect
await page.goto(SIMULATOR_URL);
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("target-soc-value")).toHaveText("50%");
});
});
test.describe("targetEnergy", async () => {
test("survives a restart", 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("target-energy-value")).toHaveText("none");
await page.getByTestId("target-energy").getByRole("combobox").selectOption("10 kWh (+35%)");
await expect(page.getByTestId("target-energy-value")).toHaveText("10 kWh");
await restart(CONFIG);
await page.reload();
await page.getByRole("button", { name: "blauer e-Golf" }).click();
await page.getByRole("button", { name: "grüner Honda e" }).click();
await expect(page.getByTestId("target-energy-value")).toHaveText("10 kWh");
});
});
test.describe("minSoc", async () => {
test("survives a restart", async ({ page }) => {
await page.goto("/");
await page.getByTestId("charging-plan").getByRole("button", { name: "none" }).click();
await page.getByRole("link", { name: "Arrival" }).click();
await expect(page.getByText("charged to x% in solar mode")).toBeVisible();
await page.getByRole("combobox", { name: "Min. charge %" }).selectOption("20%");
await expect(page.getByText("charged to 20% in solar mode")).toBeVisible();
await restart(CONFIG);
await page.reload();
await page.getByTestId("charging-plan").getByRole("button", { name: "none" }).click();
await page.getByRole("link", { name: "Arrival" }).click();
await expect(page.getByText("charged to 20% in solar mode")).toBeVisible();
});
test("show minsoc instead of plan when minsoc is active", async ({ page }) => {
await page.goto("/");
await expect(page.getByTestId("charging-plan")).toContainText("Plan");
await page.getByTestId("charging-plan").getByRole("button", { name: "none" }).click();
await page.getByRole("link", { name: "Arrival" }).click();
await page.getByRole("combobox", { name: "Min. charge %" }).selectOption("50%");
await page.getByRole("button", { name: "Close" }).click();
await expect(page.getByTestId("charging-plan")).toContainText("Min charge");
await expect(page.getByTestId("vehicle-status")).toHaveText("Minimum charging to 50%.");
await page.getByTestId("charging-plan").getByRole("button", { name: "50%" }).click();
await page.getByRole("combobox", { name: "Min. charge %" }).selectOption("--");
await page.getByRole("button", { name: "Close" }).click();
await expect(page.getByTestId("charging-plan")).toContainText("Plan");
await expect(page.getByTestId("charging-plan").getByRole("button")).toHaveText("none");
});
test("disabled for offline vehicles", async ({ page }) => {
await page.goto("/");
// switch to offline vehicle
await page.getByRole("button", { name: "blauer e-Golf" }).click();
await page.getByRole("button", { name: "grüner Honda e" }).click();
await page.getByTestId("charging-plan").getByRole("button", { name: "none" }).click();
await page.getByRole("link", { name: "Arrival" }).click();
await expect(page.getByRole("combobox", { name: "Min. charge %" })).toBeDisabled();
});
test("disabled for guest vehicles", async ({ page }) => {
await page.goto("/");
// switch to offline vehicle
await page.getByRole("button", { name: "blauer e-Golf" }).click();
await page.getByRole("button", { name: "Guest vehicle" }).click();
await page.getByTestId("charging-plan").getByRole("button", { name: "none" }).click();
await page.getByRole("link", { name: "Arrival" }).click();
await expect(page.getByRole("combobox", { name: "Min. charge %" })).toBeDisabled();
});
});
test.describe("targetTime", async () => {
test("survives a restart", async ({ page }) => {
await page.goto("/");
await page.getByTestId("target-soc").getByRole("combobox").selectOption("90%");
await page.getByTestId("charging-plan").getByRole("button", { name: "none" }).click();
await page.getByTestId("target-day").selectOption({ index: 1 });
await page.getByTestId("target-time").fill("09:30");
await page.getByRole("button", { name: "Activate" }).click();
await expect(page.getByTestId("charging-plan").getByRole("button")).toHaveText(
"tomorrow 9:30 AM"
);
await restart(CONFIG);
await page.reload();
await expect(page.getByTestId("vehicle-status")).toContainText("Target charging starts at");
await expect(page.getByTestId("charging-plan").getByRole("button")).toHaveText(
"tomorrow 9:30 AM"
);
await expect(page.getByTestId("target-soc-value")).toHaveText("90%");
});
});