feat: consolidate shared UI and harden browser authority for release
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("Mail synthetic parent labels select without opening nonexistent folders or changing expansion", async ({ page }) => {
|
||||
const errors: string[] = [];
|
||||
const providerFolders: string[] = [];
|
||||
const writes: string[] = [];
|
||||
page.on("pageerror", (error) => errors.push(error.message));
|
||||
await page.route(url => url.pathname.startsWith("/api/"), async route => {
|
||||
const request = route.request();
|
||||
const url = new URL(request.url());
|
||||
if (request.method() !== "GET") writes.push(url.pathname);
|
||||
let body: unknown = {};
|
||||
if (url.pathname === "/api/v1/mail/profiles") body = { profiles: [{
|
||||
id: "tree-profile", name: "Fixture mailbox", is_active: true, scope_type: "tenant",
|
||||
imap: { enabled: true, host: "imap.example.test", port: 993, security: "ssl", folder_mappings: { inbox: "INBOX" } }
|
||||
}] };
|
||||
else if (url.pathname.endsWith("/mailbox/bootstrap")) body = {
|
||||
folder: "INBOX", folders: { ok: true, folders: [{ name: "INBOX", flags: [] }, { name: "Archive/2026", flags: [] }] },
|
||||
messages: { ok: true, folder: "INBOX", messages: [], total_count: 0 }
|
||||
};
|
||||
else if (url.pathname.endsWith("/mailbox/messages")) {
|
||||
providerFolders.push(url.searchParams.get("folder") ?? "");
|
||||
body = { ok: true, folder: url.searchParams.get("folder"), messages: [], total_count: 0 };
|
||||
}
|
||||
return route.fulfill({ json: body });
|
||||
});
|
||||
await page.goto("/?mail-folder-explorer&language=en&theme=light");
|
||||
const archive = page.locator('.explorer-tree-node').filter({ hasText: /^Archive$/ });
|
||||
const archiveRow = page.locator('.explorer-tree-node-wrap').filter({ has: archive });
|
||||
const toggle = archiveRow.locator(':scope > .explorer-tree-toggle');
|
||||
await expect(archive).toBeEnabled();
|
||||
await expect(toggle).toHaveAttribute("aria-expanded", "false");
|
||||
const initialReads = providerFolders.length;
|
||||
await archive.click();
|
||||
await expect(archive).toHaveAttribute("aria-current", "true");
|
||||
await expect(toggle).toHaveAttribute("aria-expanded", "false");
|
||||
await expect(page.getByText("This grouping contains mailbox folders.", { exact: false })).toBeVisible();
|
||||
expect(providerFolders).toHaveLength(initialReads);
|
||||
await toggle.click();
|
||||
await expect(toggle).toHaveAttribute("aria-expanded", "true");
|
||||
await archive.click();
|
||||
await expect(toggle).toHaveAttribute("aria-expanded", "true");
|
||||
await page.locator('.explorer-tree-node').filter({ hasText: /^2026$/ }).click();
|
||||
await expect.poll(() => providerFolders.includes("Archive/2026")).toBe(true);
|
||||
expect(providerFolders).not.toContain("Archive");
|
||||
expect(errors).toEqual([]);
|
||||
expect(writes).toEqual([]);
|
||||
});
|
||||
Reference in New Issue
Block a user