mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-03 08:59:52 +08:00
Ship folder-based workspaces and data migration, daily practice, redesigned provider and model settings, and streaming conversation improvements. Synchronize README translations and document the archive/permanent-delete upgrade behavior in assets/releases/ver1-6-9.md. Reduce initial JavaScript by deduplicating English resources and loading animation features after hydration. Keep the existing route size budgets. Update regression fixtures and browser audits for scoped URLs and the new settings and learning interfaces.
103 lines
3.7 KiB
TypeScript
103 lines
3.7 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
const BASE_URL = process.env.WEB_BASE_URL || "http://127.0.0.1:3300";
|
|
|
|
const surfaces = [
|
|
["Chat", "/chat"],
|
|
["Reading", "/learning/reading"],
|
|
["Mastery", "/learning/mastery"],
|
|
["Settings", "/settings"],
|
|
["Knowledge", "/knowledge-bases"],
|
|
["Co-Writer", "/co-writer"],
|
|
] as const;
|
|
|
|
const themes = ["snow", "light", "dark", "glass"] as const;
|
|
const languages = ["en", "zh"] as const;
|
|
const viewports = [
|
|
["mobile", { width: 390, height: 844 }],
|
|
// A 1440 px desktop at 200% browser zoom exposes roughly 720 CSS pixels.
|
|
["desktop-200pct", { width: 720, height: 500 }],
|
|
["tablet", { width: 820, height: 1180 }],
|
|
["desktop", { width: 1440, height: 1000 }],
|
|
] as const;
|
|
|
|
for (const theme of themes) {
|
|
for (const language of languages) {
|
|
for (const [viewportName, viewport] of viewports) {
|
|
test(`${theme}/${language}/${viewportName} keeps all primary surfaces usable`, async ({
|
|
browser,
|
|
}) => {
|
|
const context = await browser.newContext({
|
|
viewport,
|
|
reducedMotion: "reduce",
|
|
});
|
|
await context.addInitScript(
|
|
({ selectedTheme, selectedLanguage }) => {
|
|
localStorage.setItem("deeptutor-theme", selectedTheme);
|
|
localStorage.setItem("deeptutor-language", selectedLanguage);
|
|
},
|
|
{ selectedTheme: theme, selectedLanguage: language },
|
|
);
|
|
const page = await context.newPage();
|
|
|
|
for (const [surface, path] of surfaces) {
|
|
await test.step(surface, async () => {
|
|
await page.goto(`${BASE_URL}${path}`, {
|
|
waitUntil: "domcontentloaded",
|
|
});
|
|
await expect(page.locator("body")).toBeVisible();
|
|
await page.waitForTimeout(250);
|
|
|
|
const rootClasses = await page
|
|
.locator("html")
|
|
.getAttribute("class");
|
|
if (theme === "snow") expect(rootClasses).toContain("theme-snow");
|
|
if (theme === "dark") expect(rootClasses).toContain("dark");
|
|
if (theme === "glass") {
|
|
expect(rootClasses).toContain("dark");
|
|
expect(rootClasses).toContain("theme-glass");
|
|
}
|
|
if (theme === "light") {
|
|
expect(rootClasses || "").not.toMatch(
|
|
/\bdark\b|\btheme-snow\b|\btheme-glass\b/,
|
|
);
|
|
}
|
|
|
|
const layout = await page.evaluate(() => ({
|
|
viewport: window.innerWidth,
|
|
documentWidth: document.documentElement.scrollWidth,
|
|
populatedPasswords: Array.from(
|
|
document.querySelectorAll<HTMLInputElement>(
|
|
'input[type="password"]',
|
|
),
|
|
).filter((input) => input.value.length > 0).length,
|
|
text: document.body.innerText,
|
|
}));
|
|
expect(
|
|
layout.documentWidth,
|
|
`${surface} overflows at ${theme}/${language}/${viewportName}`,
|
|
).toBeLessThanOrEqual(layout.viewport + 1);
|
|
expect(layout.populatedPasswords).toBe(0);
|
|
expect(layout.text).not.toMatch(
|
|
/\bsk-[A-Za-z0-9_-]{20,}\b|\bBearer\s+[A-Za-z0-9._-]{20,}/,
|
|
);
|
|
|
|
const focusables = page.locator(
|
|
'a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',
|
|
);
|
|
if ((await focusables.count()) > 0) {
|
|
await page.keyboard.press("Tab");
|
|
const focusedTag = await page.evaluate(
|
|
() => document.activeElement?.tagName,
|
|
);
|
|
expect(focusedTag).not.toBe("BODY");
|
|
}
|
|
});
|
|
}
|
|
|
|
await context.close();
|
|
});
|
|
}
|
|
}
|
|
}
|