mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-20 09:50:48 +01:00
Stabilize watchdog startup and planning row assertions
CI stopped the watchdog fixture before its never-settling test started. Reuse the startup-marker fixture from #22176 so that case checks the intended stall phase rather than assuming a short worker startup time. The separate top-level-await fixture still checks stalled file loading. The planning browser test selected every link to the task. On mobile, that matched the row, status link, and sidebar recent item. Check the bound task row instead, including its full text on both viewport sizes. Verification: all seven watchdog tests pass. The planning browser test passes with a fresh disposable database and Chromium. Its unmodified version also passed locally; the Linux CI report preserves the original three-link strict-mode failure. Runtime code is unchanged by this commit. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
b197e4f9f6
commit
77778da28a
2 files changed
+18
-12
No files matched your search
@@ -3,7 +3,7 @@ import { spawnSync } from "node:child_process";
|
||||
import { mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import StalledFileReporter, { defaultStallMs, stallAnnotation, stalledFileReporterEnabled, stallLimitMs }
|
||||
from "./stalled-file-reporter.mjs";
|
||||
@@ -83,9 +83,9 @@ test("a file that never finishes loading is named from the moment it is queued",
|
||||
// The failure this guards: a test awaiting a promise that never settles, with
|
||||
// a test timeout longer than the CI job, holds Vitest until the job is
|
||||
// cancelled and never prints the file's name.
|
||||
for (const [label, body, step] of [
|
||||
["a test that never settles", 'import { test } from "vitest";\ntest("waits forever", () => new Promise(() => {}), 600_000);\n', 'test "waits forever"'],
|
||||
["a top-level await that never settles", 'import { test } from "vitest";\nawait new Promise(() => {});\ntest("never collected", () => {});\n', "loading the file"],
|
||||
for (const [label, body, steps] of [
|
||||
["a test that never settles", 'import { test } from "vitest";\nimport { writeFileSync } from "node:fs";\ntest("waits forever", () => { writeFileSync(process.env.PAPERCLIP_WATCHDOG_TEST_STARTED, "started"); return new Promise(() => {}); }, 600_000);\n', ['test "waits forever"']],
|
||||
["a top-level await that never settles", 'import { test } from "vitest";\nawait new Promise(() => {});\ntest("never collected", () => {});\n', ["loading the file"]],
|
||||
]) test(`a real Vitest run with ${label} fails fast and names the file`, () => {
|
||||
const directory = realpathSync(mkdtempSync(path.join(tmpdir(), "stalled-file-reporter-")));
|
||||
try {
|
||||
@@ -93,21 +93,27 @@ for (const [label, body, step] of [
|
||||
writeFileSync(path.join(directory, "quick.test.mjs"), `import { test } from "vitest";
|
||||
test("passes", () => {});
|
||||
`);
|
||||
const startedMarker = path.join(directory, "started");
|
||||
let fixtureReporter = reporterPath;
|
||||
if (label === "a test that never settles") {
|
||||
fixtureReporter = path.join(directory, "after-test-start.mjs");
|
||||
writeFileSync(fixtureReporter, 'import Base from ' + JSON.stringify(pathToFileURL(reporterPath).href) + ';\nimport { existsSync } from "node:fs";\nexport default class extends Base { check() { if (!existsSync(' + JSON.stringify(startedMarker) + ')) return; super.check(); } }\n');
|
||||
}
|
||||
const configFile = path.join(directory, "vitest.config.mjs");
|
||||
writeFileSync(configFile, `export default ${JSON.stringify({ test: { include: ["*.test.mjs"],
|
||||
reporters: ["default", [reporterPath, { limitMs: 1500, graceMs: 5000, root: directory }]] } })};`);
|
||||
reporters: ["default", [fixtureReporter, { limitMs: 1500, graceMs: 5000, root: directory }]] } })};`);
|
||||
const started = Date.now();
|
||||
const result = spawnSync(process.execPath, [path.join(root, "node_modules/vitest/vitest.mjs"), "run",
|
||||
"--config", configFile, "--root", directory], {
|
||||
cwd: directory, encoding: "utf8", timeout: 60_000,
|
||||
env: { ...process.env, GITHUB_ACTIONS: "", PAPERCLIP_VITEST_FILE_STALL_MS: "" },
|
||||
env: { ...process.env, GITHUB_ACTIONS: "", PAPERCLIP_VITEST_FILE_STALL_MS: "", PAPERCLIP_WATCHDOG_TEST_STARTED: startedMarker },
|
||||
});
|
||||
const output = `${result.stdout}\n${result.stderr}`;
|
||||
assert.equal(result.signal, null, `Vitest was still running after 60 s:\n${output}`);
|
||||
assert.notEqual(result.status, 0, output);
|
||||
assert.ok(Date.now() - started < 30_000, `took ${Date.now() - started} ms:\n${output}`);
|
||||
assert.match(output, /::error file=stuck\.test\.mjs,title=Test file stopped making progress::stuck\.test\.mjs made no progress/);
|
||||
assert.ok(output.includes(`while in: ${step}.`), output);
|
||||
assert.ok(steps.some(step => output.includes(`while in: ${step}.`)), output);
|
||||
} finally {
|
||||
rmSync(directory, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ test("captures planning mode UI for desktop and mobile", async ({ page }) => {
|
||||
const issueIdentifier = issue.identifier ?? issue.id;
|
||||
const issuePath = `/${company.issuePrefix ?? company.id}/issues/${issueIdentifier}`;
|
||||
const companyPrefix = company.issuePrefix ?? company.id;
|
||||
const issueLinkSelector = `a[href$="/issues/${issueIdentifier}"]`;
|
||||
const issueRow = page.locator(`[data-issue-row-details="${issue.id}"]`);
|
||||
|
||||
const setMode = async (mode: "standard" | "planning") => {
|
||||
const patchRes = await page.request.patch(`${baseOrigin}/api/issues/${issue.id}`, {
|
||||
@@ -159,8 +159,8 @@ test("captures planning mode UI for desktop and mobile", async ({ page }) => {
|
||||
});
|
||||
|
||||
await page.goto(`/${companyPrefix}/issues`);
|
||||
await expect(page.locator(issueLinkSelector)).toBeVisible();
|
||||
await expect(page.locator(issueLinkSelector)).not.toContainText("Plan mode");
|
||||
await expect(issueRow).toBeVisible();
|
||||
await expect(issueRow).not.toContainText("Plan mode");
|
||||
await page.screenshot({
|
||||
path: `${screenshotDir}/desktop-planning-row-${timestamp}.png`,
|
||||
fullPage: true,
|
||||
@@ -190,8 +190,8 @@ test("captures planning mode UI for desktop and mobile", async ({ page }) => {
|
||||
});
|
||||
|
||||
await page.goto(`/${companyPrefix}/issues`);
|
||||
await expect(page.locator(issueLinkSelector)).toBeVisible();
|
||||
await expect(page.locator(issueLinkSelector)).not.toContainText("Plan mode");
|
||||
await expect(issueRow).toBeVisible();
|
||||
await expect(issueRow).not.toContainText("Plan mode");
|
||||
await page.screenshot({
|
||||
path: `${screenshotDir}/mobile-planning-row-${timestamp}.png`,
|
||||
fullPage: true,
|
||||
|
||||
Reference in new issue
Block a user