forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig-mqtt.spec.js
63 lines (52 loc) · 2.37 KB
/
config-mqtt.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
import { test, expect } from "@playwright/test";
import { start, stop, restart, baseUrl } from "./evcc";
import { enableExperimental, login } from "./utils";
const CONFIG = "config-grid-only.evcc.yaml";
test.use({ baseURL: baseUrl() });
test.describe.configure({ mode: "parallel" });
test.beforeEach(async ({ page }) => {
await start(CONFIG, "password.sql");
await page.goto("/#/config");
await login(page);
await enableExperimental(page);
});
test.afterEach(async () => {
await stop();
});
test.describe("mqtt", async () => {
test("mqtt not configured", async ({ page }) => {
await expect(page.getByTestId("mqtt")).toBeVisible();
await expect(page.getByTestId("mqtt")).toContainText(["Configured", "no"].join(""));
});
test("mqtt via ui", async ({ page }) => {
await page.getByTestId("mqtt").getByRole("button", { name: "edit" }).click();
const modal = await page.getByTestId("mqtt-modal");
await modal.getByLabel("Broker").fill("unknown.example.org");
await modal.getByLabel("Topic").fill("my-topic");
await modal.getByLabel("Client ID").fill("my-client-id");
await page.getByRole("button", { name: "Save" }).click();
await expect(modal.getByTestId("error")).not.toBeVisible();
await expect(modal).not.toBeVisible();
// restart button appears
const restartButton = await page
.getByTestId("bottom-banner")
.getByRole("button", { name: "Restart" });
await expect(restartButton).toBeVisible();
await restart(CONFIG);
// config error
await expect(restartButton).not.toBeVisible();
await expect(page.getByTestId("mqtt")).toHaveClass(/round-box--error/);
await expect(page.getByTestId("mqtt")).toContainText(
["Broker", "unknown.example.org", "Topic", "my-topic"].join("")
);
await expect(page.getByTestId("bottom-banner")).toContainText("failed configuring mqtt");
await page.getByTestId("mqtt").getByRole("button", { name: "edit" }).click();
await page.getByRole("button", { name: "Remove" }).click();
await expect(page.getByTestId("mqtt")).toContainText(["Configured", "no"].join(""));
await expect(restartButton).toBeVisible();
await restart(CONFIG);
await expect(restartButton).not.toBeVisible();
await expect(page.getByTestId("mqtt")).not.toHaveClass(/round-box--error/);
await expect(page.getByTestId("mqtt")).toContainText(["Configured", "no"].join(""));
});
});