Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

gui tests: plugin-page waits for the glance's text instead of throwing before it is drawn (#4180)

yetonedbdc6b87bb16
diff --git a/internal/gui/tests/plugin-page.test.cjs b/internal/gui/tests/plugin-page.test.cjs
index d43d83c40..d650906a2 100644
--- a/internal/gui/tests/plugin-page.test.cjs
+++ b/internal/gui/tests/plugin-page.test.cjs
@@ -165,9 +165,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
if (lang === "de") {
// a new language retitles the tab, and back
await page.evaluate(() => setLocale("ja"));
- await page.waitForFunction(() => document.querySelector("#nav button[data-plugin-page] span").textContent === "使用量の概要");
+ await page.waitForFunction(() => document.querySelector("#nav button[data-plugin-page] span")?.textContent === "使用量の概要");
await page.evaluate(() => setLocale("de"));
- await page.waitForFunction(() => document.querySelector("#nav button[data-plugin-page] span").textContent === "Usage glance");
+ await page.waitForFunction(() => document.querySelector("#nav button[data-plugin-page] span")?.textContent === "Usage glance");
}
// no frame until the page is looked at
assert.equal(await page.locator("iframe.plugin-frame").count(), 0, `${where}: nothing loaded unseen`);
@@ -176,7 +176,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.evaluate(() => show("plugin-glance"));
const glance = await frameReady(page, GLANCE);
assert.equal(await page.locator("#view-plugin-glance iframe").getAttribute("sandbox"), "allow-scripts", where);
- await glance.waitForFunction(() => document.getElementById("cost").textContent === "$0.50");
+ await glance.waitForFunction(() => document.getElementById("cost")?.textContent === "$0.50");
assert.equal(await glance.locator("#calls").textContent(), "12 calls, 1234 tokens", where);
assert.deepEqual(seen.reads.map((r) => [r.spec, r.read]), [["/x/glance", "usage:summary"]], where);
assert.equal(await glance.evaluate(() => document.documentElement.lang), lang, `${where}: the window's language`);
@@ -185,7 +185,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await glance.waitForFunction(() => document.documentElement.dataset.theme === "dark");
assert.ok((await glance.evaluate(() => document.documentElement.style.getPropertyValue("--magpie-bg"))).length > 0, `${where}: the tokens`);
await glance.locator("#hide").click();
- await glance.waitForFunction(() => document.getElementById("cost").textContent === "");
+ await glance.waitForFunction(() => document.getElementById("cost")?.textContent === "");
assert.deepEqual(seen.options.map((o) => [o.spec, o.options.hideCost]), [["/x/glance", true]], `${where}: its own options`);
// the frame fits the window
assert.ok(await page.evaluate(() => { const v = document.querySelector("#view-plugin-glance"); const f = v.querySelector("iframe"); return f.getBoundingClientRect().width <= v.clientWidth + 1 && v.scrollWidth <= v.clientWidth + 1 && f.getBoundingClientRect().height > 200; }), `${where}: fits`);