forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatistics.spec.js
106 lines (85 loc) Β· 4.38 KB
/
statistics.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
import { test, expect } from "@playwright/test";
import { start, stop, baseUrl } from "./evcc";
test.use({ baseURL: baseUrl() });
test.beforeAll(async () => {
await start("statistics.evcc.yaml", ["password.sql", "statistics.sql"]);
});
test.afterAll(async () => {
await stop();
});
test.describe("footer", async () => {
test("default 30d solar percentage in footer and change on period switch", async ({ page }) => {
await page.goto("/");
// last 30 days
await expect(page.getByTestId("savings-button")).toContainText("60% solar energy");
// last 365 days
await page.getByTestId("savings-button").click();
const savingsModal = await page.getByTestId("savings-modal");
await expect(savingsModal).toBeVisible();
await page
.getByTestId("savings-period-select")
.getByRole("combobox")
.selectOption("last 365 days");
await page.getByRole("button", { name: "Close" }).click();
await expect(savingsModal).not.toBeVisible();
await expect(page.getByTestId("savings-button")).toContainText("30% solar energy");
// all time
await page.getByTestId("savings-button").click();
await expect(savingsModal).toBeVisible();
await page.getByTestId("savings-period-select").getByRole("combobox").selectOption("all time");
await page.getByRole("button", { name: "Close" }).click();
await expect(savingsModal).not.toBeVisible();
await expect(page.getByTestId("savings-button")).toContainText("50% solar energy");
});
});
test.describe("statistics values", async () => {
test("last 30 days", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "60% solar energy" }).click();
await expect(page.getByTestId("savings-modal")).toBeVisible();
await page
.getByTestId("savings-period-select")
.getByRole("combobox")
.selectOption("last 30 days");
await expect(page.getByTestId("savings-tile-solar")).toContainText("60.0%");
await expect(page.getByTestId("savings-tile-solar")).toContainText("30 kWh solar");
await expect(page.getByTestId("savings-tile-solar")).toContainText("20 kWh grid");
await expect(page.getByTestId("savings-tile-price")).toContainText("18.0rp/kWh");
await expect(page.getByTestId("savings-tile-price")).toContainText("6 CHF saved");
await expect(page.getByTestId("savings-tile-co2")).toContainText("8g/kWh");
await expect(page.getByTestId("savings-tile-co2")).toContainText("19 kg saved");
});
test("last 365 days", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "60% solar energy" }).click();
await expect(page.getByTestId("savings-modal")).toBeVisible();
await page
.getByTestId("savings-period-select")
.getByRole("combobox")
.selectOption("last 365 days");
await expect(page.getByTestId("savings-tile-solar")).toContainText("30.0%");
await expect(page.getByTestId("savings-tile-solar")).toContainText("30 kWh solar");
await expect(page.getByTestId("savings-tile-solar")).toContainText("70 kWh grid");
await expect(page.getByTestId("savings-tile-price")).toContainText("24.0rp/kWh");
await expect(page.getByTestId("savings-tile-price")).toContainText("6 CHF saved");
await expect(page.getByTestId("savings-tile-co2")).toContainText("14g/kWh");
await expect(page.getByTestId("savings-tile-co2")).toContainText("37 kg saved");
});
test("reference data", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "60% solar energy" }).click();
await expect(page.getByTestId("savings-modal")).toBeVisible();
await expect(page.getByTestId("savings-reference")).toContainText("Reference data:");
await expect(page.getByTestId("savings-reference")).toContainText("30.0 rp/kWh (grid)");
await expect(page.getByTestId("savings-reference")).toContainText("β 385 g/kWh");
await expect(page.getByTestId("savings-reference")).toContainText("Germany");
await expect(page.getByTestId("savings-tile-co2")).toContainText("19 kg saved");
await page
.getByTestId("savings-region-select")
.getByRole("combobox")
.selectOption("Switzerland");
await expect(page.getByTestId("savings-reference")).toContainText("β 46 g/kWh");
await expect(page.getByTestId("savings-reference")).toContainText("Switzerland");
await expect(page.getByTestId("savings-tile-co2")).toContainText("2 kg saved");
});
});