evcc-io/tests/customization.spec.ts

69 lines
2.4 KiB
TypeScript

import { test, expect } from "@playwright/test";
import { start, stop, baseUrl } from "./evcc";
import { openMoreMenu } from "./utils";
test.use({ baseURL: baseUrl() });
test.beforeAll(async () => {
await start("basics.evcc.yaml", null, [
"--disable-auth",
"--custom-brand",
"G1GA HEMS",
"--custom-logo-light",
"tests/custom-logo-light.svg",
"--custom-logo-dark",
"tests/custom-logo-dark.svg",
"--custom-website",
"https://example.com/hems",
"--custom-email",
"support@example.com",
"--custom-phone",
"+49 123 456789",
]);
});
test.afterAll(async () => {
await stop();
});
test.describe("customization", async () => {
test("more menu shows custom brand", async ({ page }) => {
await page.goto("/");
const menu = await openMoreMenu(page);
await expect(menu.getByRole("button", { name: /G1GA HEMS/ })).toBeVisible();
});
test("about modal shows custom logo and contact info", async ({ page }) => {
await page.goto("/");
const menu = await openMoreMenu(page);
await menu.getByRole("button", { name: /G1GA HEMS/ }).click();
// only the theme-matching logo variant is visible
const logo = page.getByRole("img", { name: "G1GA HEMS" });
await expect(logo).toBeVisible();
await expect(logo).toHaveAttribute("src", "./custom-logo-light");
const website = page.getByRole("link", { name: "example.com", exact: true });
await expect(website).toBeVisible();
await expect(website).toHaveAttribute("href", "https://example.com/hems");
const phone = page.getByRole("link", { name: "+49 123 456789" });
await expect(phone).toBeVisible();
await expect(phone).toHaveAttribute("href", "tel:+49123456789");
const email = page.getByRole("link", { name: "support@example.com" });
await expect(email).toBeVisible();
await expect(email).toHaveAttribute("href", "mailto:support@example.com");
});
test("help modal shows contact button instead of github discussions", async ({ page }) => {
await page.goto("/");
const menu = await openMoreMenu(page);
await menu.getByRole("button", { name: "Need Help?" }).click();
const contact = page.getByRole("link", { name: "Contact us" });
await expect(contact).toBeVisible();
await expect(contact).toHaveAttribute("href", "mailto:support@example.com");
await expect(page.getByRole("link", { name: "GitHub discussions" })).not.toBeVisible();
});
});