Files
ComfyUI_frontend/browser_tests/menu.spec.ts
Chenlei Hu 5b4e96f6c5 Test theme toggle feature (#212)
* WIP

* Add test on theme toggle

* Add teardown logic

* Cleanup menu setting
2024-07-23 17:56:35 -04:00

46 lines
1.2 KiB
TypeScript

import { expect } from "@playwright/test";
import { comfyPageFixture as test } from "./ComfyPage";
test.describe("Menu", () => {
test.beforeEach(async ({ comfyPage }) => {
await comfyPage.page.evaluate(async () => {
await window["app"].ui.settings.setSettingValueAsync(
"Comfy.UseNewMenu",
"Top"
);
});
});
test.afterEach(async ({ comfyPage }) => {
const currentThemeId = await comfyPage.menu.getThemeId();
if (currentThemeId !== "dark") {
await comfyPage.menu.toggleTheme();
}
await comfyPage.page.evaluate(async () => {
await window["app"].ui.settings.setSettingValueAsync(
"Comfy.UseNewMenu",
"Disabled"
);
});
});
test("Toggle theme", async ({ comfyPage }) => {
test.setTimeout(30000);
expect(await comfyPage.menu.getThemeId()).toBe("dark");
await comfyPage.menu.toggleTheme();
expect(await comfyPage.menu.getThemeId()).toBe("light");
// Theme id should persist after reload.
await comfyPage.page.reload();
await comfyPage.setup();
expect(await comfyPage.menu.getThemeId()).toBe("light");
await comfyPage.menu.toggleTheme();
expect(await comfyPage.menu.getThemeId()).toBe("dark");
});
});