gui tests: the key models menu offers an empty provider whole

This commit is contained in:
yetone
2026-11-11 15:07:21 +08:00
parent a6e5abaeb6
commit bd6a016156
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -151,7 +151,7 @@ function fixture(lang, theme, events, options = {}) {
{ id: "relay/me@example.com", name: "me@example.com", provider: "relay", providerName: "Relay", account: true, plan: "Pro" },
{ id: "relay/spare@example.com", name: "spare@example.com", provider: "relay", providerName: "Relay", account: true },
{ id: "openai/k-1a2b3c", name: "k-1a2b3c", provider: "openai", providerName: "OpenAI", key: true },
], groups: accountGroups });
], providers: options.emptyProvider ? [{ id: "later/*", name: "Later", provider: "later", providerName: "Later" }] : [], groups: accountGroups });
// the MCP servers and tools a key may be held to: magpie's own, then
// the Library's (wakaka on Discord)
if (url.pathname === "/api/caller-keys/mcp") return json({ servers: [
@@ -16,7 +16,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
page.setDefaultNavigationTimeout(60000);
const events = [], errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", fixture(lang, "light", events, { lan: true, limits: { server: { models: ["openai/*", "relay/m"] } } }));
await page.route("**/*", fixture(lang, "light", events, { lan: true, emptyProvider: true, limits: { server: { models: ["openai/*", "relay/m"] } } }));
const zh = lang === "zh";
const w = zh
? { label: "此密钥可用的模型", all: "全部模型", two: "2 个模型", relay: "Relay 的全部模型", only: /仅限这些模型/ }
@@ -48,6 +48,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal((await menu.locator(".pm-head").textContent()).trim(), w.label);
assert.deepEqual(await scrolled(), at, "opening the menu moved the page");
assert.equal(await menu.locator(".pm-item.on").count(), 1, "All models is ticked for a free key");
// a provider that serves no model now can be allowed whole, for later
const later = menu.locator(".pm-item", { hasText: zh ? "Later 的全部模型" : "Every Later model" });
assert.equal(await later.count(), 1, "no every-model entry for a provider with no model yet");
// a short window: the menu stays in it, scrolling, rather than running off it
// (reduced motion still runs a .01ms transition, so it is waited for)
await page.waitForFunction(() => {