evcc-io/tests/demo.spec.ts
guido4096 f927d5fa18
Add explicit demo mode (#21848)
Co-authored-by: Michael Geers <michael@geers.tv>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
2025-06-20 12:05:08 +02:00

44 lines
1.4 KiB
TypeScript

import { test, expect } from "@playwright/test";
import { start, stop, baseUrl } from "./evcc";
import { expectModalHidden } from "./utils";
import { ChildProcess } from "child_process";
test.use({ baseURL: baseUrl() });
let instance: ChildProcess;
test.beforeAll(async () => {
instance = await start(undefined, undefined, "--demo");
});
test.afterAll(async () => {
// force quit by instance, shutdown endpoint disabled
await stop(instance);
});
test.beforeEach(async ({ page }) => {
await page.goto("/");
});
test.describe("demo mode", async () => {
test("no admin password prompt", async ({ page }) => {
await expectModalHidden(page.getByTestId("password-modal"));
});
test("site title", async ({ page }) => {
await expect(page.getByRole("heading", { name: "Demo Mode" })).toBeVisible();
});
test("two loadpoints", async ({ page }) => {
await expect(page.getByTestId("loadpoint")).toHaveCount(2);
await expect(page.getByTestId("loadpoint").nth(0)).toContainText("Carport");
await expect(page.getByTestId("loadpoint").nth(1)).toContainText("Garage");
});
test("auth is locked", async ({ page }) => {
await page.getByTestId("topnavigation-button").click();
await page.getByRole("link", { name: "Configuration" }).click();
const loginModal = page.getByTestId("login-modal");
await expect(loginModal).toBeVisible();
await expect(loginModal).toContainText("Login is not supported in demo mode.");
});
});