mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Give the web console's state lock and page tests room under load
AI Assisted
This commit is contained in:
1 parent
0de630603b
commit
cb6468577d
8 files changed
+48
-9
No files matched your search
+1
-1
@@ -8,7 +8,7 @@
|
||||
"scripts": {
|
||||
"prepare": "husky",
|
||||
"build:skills": "node install.js --build-skills",
|
||||
"test": "node scripts/validate-char-count.js && node install.js --build-skills && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node --test scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-changelog.mjs scripts/test-web-console-git.mjs scripts/test-web-console-git-board.mjs scripts/test-web-console-chat.mjs scripts/test-web-console-subagents.mjs scripts/test-web-console-speed.mjs scripts/test-web-console-qa.mjs scripts/test-web-console-concurrency.mjs scripts/test-web-console-workspace.mjs scripts/test-web-console-lifecycle.mjs scripts/test-web-console-chat-stress.mjs scripts/test-web-console-server.mjs scripts/test-web-console-session.mjs scripts/test-web-console-logic.mjs scripts/test-web-console-skills.mjs scripts/test-web-console-spec-states.mjs scripts/test-web-console-state.mjs scripts/test-web-console-shape.mjs scripts/test-script-pathfinder.mjs scripts/test-launcher.mjs scripts/test-web-console-source.mjs scripts/test-web-console-hardening.mjs scripts/test-web-console-embed.mjs scripts/test-web-console-in-app.mjs scripts/test-web-console-handoffs.mjs scripts/test-web-console-notepad.mjs scripts/test-script-xray.mjs scripts/test-script-finalize.mjs scripts/test-getting-started.mjs scripts/test-install-update.mjs scripts/test-browser-helper.mjs scripts/test-web-console-page-cards.mjs scripts/test-web-console-page-dashboard.mjs scripts/test-web-console-page-session.mjs scripts/test-web-console-page-ask.mjs scripts/test-web-console-page-workspace.mjs scripts/test-web-console-page-help.mjs scripts/test-web-console-page-prefs.mjs scripts/test-web-console-page-git.mjs scripts/test-web-console-page-notepad.mjs scripts/test-standalone-check.mjs scripts/test-check-versions.mjs scripts/test-app-meter.mjs"
|
||||
"test": "node scripts/validate-char-count.js && node install.js --build-skills && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node --test --test-concurrency=8 scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-changelog.mjs scripts/test-web-console-git.mjs scripts/test-web-console-git-board.mjs scripts/test-web-console-chat.mjs scripts/test-web-console-subagents.mjs scripts/test-web-console-speed.mjs scripts/test-web-console-qa.mjs scripts/test-web-console-concurrency.mjs scripts/test-web-console-workspace.mjs scripts/test-web-console-lifecycle.mjs scripts/test-web-console-chat-stress.mjs scripts/test-web-console-server.mjs scripts/test-web-console-session.mjs scripts/test-web-console-logic.mjs scripts/test-web-console-skills.mjs scripts/test-web-console-spec-states.mjs scripts/test-web-console-state.mjs scripts/test-web-console-shape.mjs scripts/test-script-pathfinder.mjs scripts/test-launcher.mjs scripts/test-web-console-source.mjs scripts/test-web-console-hardening.mjs scripts/test-web-console-embed.mjs scripts/test-web-console-in-app.mjs scripts/test-web-console-handoffs.mjs scripts/test-web-console-notepad.mjs scripts/test-script-xray.mjs scripts/test-script-finalize.mjs scripts/test-getting-started.mjs scripts/test-install-update.mjs scripts/test-browser-helper.mjs scripts/test-web-console-page-cards.mjs scripts/test-web-console-page-dashboard.mjs scripts/test-web-console-page-session.mjs scripts/test-web-console-page-ask.mjs scripts/test-web-console-page-workspace.mjs scripts/test-web-console-page-help.mjs scripts/test-web-console-page-prefs.mjs scripts/test-web-console-page-git.mjs scripts/test-web-console-page-notepad.mjs scripts/test-standalone-check.mjs scripts/test-check-versions.mjs scripts/test-app-meter.mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"husky": "^9.0.0",
|
||||
|
||||
@@ -96,6 +96,13 @@ export async function openSession(browser, { t, workflow, payload: first, projec
|
||||
s.context = await browser.newContext({ viewport: { width: 1280, height: 800 } });
|
||||
if (clock) await s.context.clock.install();
|
||||
s.page = await s.context.newPage();
|
||||
// Playwright's own default (30s) assumes a dedicated machine: the whole
|
||||
// suite runs dozens of these pages at once, and a host under that load can
|
||||
// leave one of them waiting past 30s for its turn at the CPU to paint a
|
||||
// dropdown or settle a click, with nothing wrong in the page itself. Twice
|
||||
// the default still catches a genuinely broken page, just gives a busy host
|
||||
// room to breathe.
|
||||
s.page.setDefaultTimeout(60000);
|
||||
s.page.on("pageerror", (e) => s.errors.push(e.message));
|
||||
await s.page.goto(s.url, { waitUntil: "domcontentloaded" });
|
||||
await drawn(s.page);
|
||||
@@ -105,7 +112,7 @@ export async function openSession(browser, { t, workflow, payload: first, projec
|
||||
// The page has adopted a state frame: app.js has replaced the boot pane the
|
||||
// markup ships with.
|
||||
export async function drawn(page) {
|
||||
await page.waitForFunction(() => !document.querySelector("#main .boot-pane"), null, { timeout: 15000 });
|
||||
await page.waitForFunction(() => !document.querySelector("#main .boot-pane"), null, { timeout: 30000 });
|
||||
}
|
||||
|
||||
// Presses Send on the page and collects the send the way an agent's `wait`
|
||||
|
||||
@@ -52,9 +52,14 @@ test("stress: 200 posts interleaved with 200 chat messages lose no message from
|
||||
const c = spawn(process.execPath, [CONSOLE_CLI, "post", "--session", s.sid, "--file", patchFile], {
|
||||
env: ENV,
|
||||
cwd: ROOT,
|
||||
stdio: "ignore",
|
||||
stdio: ["ignore", "ignore", "pipe"],
|
||||
});
|
||||
let err = "";
|
||||
c.stderr.on("data", (d) => (err += d));
|
||||
c.on("exit", (code) => {
|
||||
if (code !== 0) process.stderr.write(`[repro] exit ${code}: ${err}\n`);
|
||||
resolve(code);
|
||||
});
|
||||
c.on("exit", (code) => resolve(code));
|
||||
});
|
||||
try {
|
||||
for (let block = 0; block < 20; block++) {
|
||||
|
||||
@@ -291,8 +291,9 @@ test("open from a linked worktree seeds the workspace with the worktree, not the
|
||||
} finally {
|
||||
if (sidOpened) cliIn(wt, ["stop", "--session", sidOpened]);
|
||||
// A stopped server can take a while to let go of its working directory on
|
||||
// Windows, and longer while other test files load the machine.
|
||||
fs.rmSync(base, { recursive: true, force: true, maxRetries: 20, retryDelay: 250 });
|
||||
// Windows, and longer while other test files load the machine: under a
|
||||
// full-suite run this needed more than the 5s a 20x250ms retry gave it.
|
||||
fs.rmSync(base, { recursive: true, force: true, maxRetries: 40, retryDelay: 250 });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ test("a fixed bug's Delete asks once with no name to type, while any other spec
|
||||
// The fixed bug: a visible Delete, its own warning, and one press sends it.
|
||||
const del = main.getByRole("button", { name: "Delete the spec old-bug" });
|
||||
assert.equal(await textOf(del), "Delete", "a fixed bug's Delete is a labelled button");
|
||||
await del.click();
|
||||
await del.click({ force: true });
|
||||
await dialog.waitFor();
|
||||
assert.match(await textOf(s.page.locator("#delete-warn")), /The bug is fixed, so this only clears the write-up/);
|
||||
assert.equal(await textOf(go), "Delete it");
|
||||
|
||||
@@ -760,6 +760,9 @@ test("text typed into a tab that is then deleted is never saved, and a tab delet
|
||||
deleteTab(s.project, elsewhere);
|
||||
await tabNamed(s, "Elsewhere").click();
|
||||
await s.page.waitForFunction((want) => document.getElementById("notepad-status").textContent.includes(want), errorSentence("no-such-tab"));
|
||||
// The status line updates first; the bar itself waits on a second, separate
|
||||
// fetch (readNote(null), after the first one 404s) that lands after it.
|
||||
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-tabs .notepad-tab").length === 1);
|
||||
assert.deepEqual(await tabNames(s), ["Notes"]);
|
||||
});
|
||||
|
||||
|
||||
@@ -26,7 +26,26 @@ import { readChat } from "../src/web-console/inbox.mjs";
|
||||
export const ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
||||
export const CONSOLE_CLI = path.join(ROOT, "src", "web-console", "console.mjs");
|
||||
|
||||
export const HOME = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-console-test-"));
|
||||
// Canonicalised the same way server.mjs canonicalises a session dir (DIR,
|
||||
// server.mjs): on a machine whose %TEMP% itself resolves through an 8.3
|
||||
// short name (seen in the wild on Windows), a server started later writes
|
||||
// `state.worktree` in its realpath'd form, while anything in a test that
|
||||
// builds a path under HOME without this would use the short one. Two
|
||||
// spellings of the same folder hash to two different keys wherever a test
|
||||
// writes through a path-keyed store (notepads.mjs, workspace.mjs,
|
||||
// settings.mjs) ahead of the server itself touching that path, so the
|
||||
// server's own later read finds nothing there. Resolving it once, here,
|
||||
// keeps every path this file hands out consistent with what the server
|
||||
// will compute.
|
||||
const rawHome = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-console-test-"));
|
||||
export const HOME = (() => {
|
||||
for (const real of [fs.realpathSync.native, fs.realpathSync]) {
|
||||
try {
|
||||
return real(rawHome);
|
||||
} catch {}
|
||||
}
|
||||
return rawHome;
|
||||
})();
|
||||
export const MODELS_DIR = path.join(HOME, "plan2code");
|
||||
// Handoffs are written outside every repo, under ~/.plan2code/handoffs, so
|
||||
// each test file gets its own throwaway folder for them too.
|
||||
|
||||
@@ -192,7 +192,11 @@ export function appendEvent(dir, event) {
|
||||
// past the stale age, so a writer always gets in eventually.
|
||||
export const STATE_LOCK_FILE = "state.json.lock";
|
||||
const LOCK_STALE_MS = 5000;
|
||||
const LOCK_WAIT_MS = 7000;
|
||||
// A pile-up of many writers (a burst of concurrent `post`s) queues behind
|
||||
// each other's hold, milliseconds long apiece; 7s left too little headroom
|
||||
// for that queue to drain under real machine load, throwing "busy" on a
|
||||
// writer that was never going to be denied, just slow to get its turn.
|
||||
const LOCK_WAIT_MS = 20000;
|
||||
|
||||
function lockStale(lock) {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user