Skip to content

Commit b253e2f

Browse files
committed
create e2e test for customise page
1 parent ca3b8b9 commit b253e2f

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

e2e/customisation.test.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { test, expect } from "./fixtures/auth";
2+
3+
test.describe("App Customisation", () => {
4+
test("admin can update general branding", async ({ adminPage }) => {
5+
await adminPage.goto("/en/admin/customise");
6+
7+
// Update app name and accent color
8+
const newAppName = "Test Registry " + Math.random().toString(36).slice(7);
9+
const newAccentColor = "#ff0000";
10+
11+
await adminPage.fill('input[name="appNameEn"]', newAppName);
12+
await adminPage.fill('input[name="accentColor"]', newAccentColor);
13+
14+
await adminPage.click('button[type="submit"]');
15+
16+
// Check for success toast - try both languages just in case, or use a more robust locator
17+
// We expect "Settings updated successfully" (EN) or "Asetukset tallennettu onnistuneesti" (FI)
18+
await expect(
19+
adminPage.locator("text=/Settings updated successfully|Asetukset tallennettu onnistuneesti/"),
20+
).toBeVisible();
21+
22+
// Verify changes are reflected on the page (synced via $effect)
23+
await expect(adminPage.locator('input[name="appNameEn"]')).toHaveValue(newAppName);
24+
25+
// Verify changes on a public page
26+
await adminPage.goto("/en");
27+
await expect(adminPage).toHaveTitle(new RegExp(newAppName));
28+
29+
// Verify accent color in head
30+
// The style tag is injected via {@html} in +layout.svelte
31+
const styleTag = await adminPage.locator("style").filter({ hasText: "--primary" }).first();
32+
await expect(styleTag).toContainText(newAccentColor);
33+
});
34+
35+
test("admin can update organization details", async ({ adminPage }) => {
36+
await adminPage.goto("/en/admin/customise");
37+
38+
const newOrgName = "Test Organization " + Math.random().toString(36).slice(7);
39+
const newBusinessId = "1234567-8";
40+
const newContact = "test@example.com";
41+
42+
await adminPage.fill('input[name="organizationNameEn"]', newOrgName);
43+
await adminPage.fill('input[name="businessId"]', newBusinessId);
44+
await adminPage.fill('input[name="overseerContact"]', newContact);
45+
46+
await adminPage.click('button[type="submit"]');
47+
await expect(
48+
adminPage.locator("text=/Settings updated successfully|Asetukset tallennettu onnistuneesti/"),
49+
).toBeVisible();
50+
51+
// Verify on privacy policy page (which uses these details in footer or content)
52+
await adminPage.goto("/en/privacy-policy");
53+
// The footer usually contains org name and business ID
54+
await expect(adminPage.locator("footer")).toContainText(newOrgName);
55+
await expect(adminPage.locator("footer")).toContainText(newBusinessId);
56+
await expect(adminPage.locator("footer")).toContainText(newContact);
57+
});
58+
59+
test("readonly admin cannot update customisations", async ({ readonlyAdminPage }) => {
60+
await readonlyAdminPage.goto("/en/admin/customise");
61+
62+
// Check if a warning banner is present
63+
await expect(
64+
readonlyAdminPage.locator("text=/You have read-only access|Sinulla on vain lukuoikeus/"),
65+
).toBeVisible();
66+
67+
// Try to submit anyway (if button is not disabled)
68+
const saveButton = readonlyAdminPage.locator('button[type="submit"]');
69+
70+
const isDisabled = await saveButton.isDisabled();
71+
72+
if (!isDisabled) {
73+
await saveButton.click();
74+
// The server action returns error(404, "Not found") for unauthorized write access
75+
await expect(readonlyAdminPage.locator("text=/Not found|Ei löytynyt/i")).toBeVisible();
76+
}
77+
});
78+
});

0 commit comments

Comments
 (0)