Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions extension/download.selftest.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,10 @@ const last = () => dialogs[dialogs.length - 1];
assert.strictEqual(text(last()), "该笔记已存在 整篇覆盖会替换全部内容: 整篇覆盖 取消", "a note without an AI 问答 section");
last().close("");

// C150: a click outside closes it; a selection dragged from the box out to the backdrop does not.
const picked = D.choose("f.md");
last().fire("pointerdown", {});
last().fire("click", "self");
assert.ok(last().open, "drag out of the box");
last().fire("pointerdown", "self");
last().fire("click", "self");
assert.strictEqual(await picked, "");
// C150: a click outside closes it, which the browser does for closedBy "any".
D.choose("f.md");
assert.strictEqual(last().closedBy, "any");
last().close("");

// K23: a write says 写, never 存.
D.choosePage("https://example.com/x", false, true, "写");
Expand Down
9 changes: 7 additions & 2 deletions scripts/selftest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ const tests = ["", "triage", "history", "agent-sites"].flatMap((dir) =>
fs.readdirSync(path.join(ext, dir)).filter((f) => f.endsWith(".selftest.js")).sort().map((f) => path.join(ext, dir, f))
);
for (const test of tests) {
if (spawnSync(process.execPath, [test], { stdio: "inherit" }).status !== 0) {
console.error(`failed: ${path.relative(ext, test)}`);
const run = spawnSync(process.execPath, [test], { stdio: ["inherit", "pipe", "inherit"], encoding: "utf8" });
process.stdout.write(run.stdout);
// Node exits 0 when a test is left awaiting something that never comes, so a test has passed only once it says so
// on its last line.
const said = /\b(ok|passed|checked)\b/.test(run.stdout.trimEnd().split("\n").pop());
if (run.status !== 0 || !said) {
console.error(`failed: ${path.relative(ext, test)}${run.status === 0 ? " (it stopped before its last line)" : ""}`);
process.exit(1);
}
}
Expand Down
8 changes: 7 additions & 1 deletion scripts/smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,16 @@ try {
}
step = YOUTUBE;
const yt = await open(YOUTUBE, 10000);
// From GitHub's runners YouTube may serve the page without a video to read ("Sign in to confirm you're not a bot"),
// and the side panel shows a conversation only once it has read the active tab's video.
const played = await evaluate(yt, `(document.querySelector("#movie_player")?.getPlayerResponse?.()?.playabilityStatus?.status || "none") + " " + location.href + " " + JSON.stringify(document.title)`);
const noVideo = !String(played).startsWith("OK ");
if (noVideo) console.log(`smoke: YouTube served no video here (${played}); the side panel's seed check skipped`);
for (const { page, count } of DATA_PAGES) {
if (noVideo && page === "sidepanel.html") continue;
step = `${page} (seeded)`;
const t = await open(`chrome-extension://${id}/${page}`, 0, true);
if (!(await until(t, `!!document.querySelector(${JSON.stringify(count)})`, 10000))) errors.push(`${step}: the seeded data drew no ${count}`);
if (!(await until(t, `!!document.querySelector(${JSON.stringify(count)})`, 10000))) errors.push(`${step}: the seeded data drew no ${count} (${String(await evaluate(t, "document.body.innerText")).replace(/\s+/g, " ").slice(0, 200)})`);
await close(t);
}
await close(yt);
Expand Down
Loading