mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 01:39:51 +01:00
perf(ci): cut E2E ceiling under 95s via 16 AWS shards, 8-core speedup, top serial splits, and parallel UI build (#22960)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Live 8-core PR runs (`45668834558`, `45667106472`) showed `e2e_shards` was the #1 critical-path bottleneck on normal PRs (`152–171s` test step) due to four compounding causes: > 1. `scripts/e2e-shard.mjs` still used the 4-vCPU `EFFECTIVE_PARALLEL_SPEEDUP = 1.85` even on 8-vCPU runners running 4 Playwright workers (`~3.35x` measured speedup), under-allocating serial shards (`5` serial shards running `96–124s` while parallel shards sat idle after `55–78s`). > 2. `scripts/e2e-shard-durations.json` had stale weights (`chat-adapters-ui-providers.spec.ts` `86.8s` vs `117–165s` actual; `acp-stop-continuation.spec.ts` `69.3s` vs `88–102s` actual). > 3. Three serial (`1-worker`) specs pinned the floor at `75–91s`: `agent-configuration.spec.ts` (`91.4s`), `agent-chat-sessions.spec.ts` (`79.9s`), and `onboarding.spec.ts` (`75.3s`). > 4. `playwright.config.ts` ran `vite build ui` (`~5.4s`) serially before starting embedded Postgres + 512 migrations (`~21s`) even though database bootstrap does not read `server/ui-dist`. > - This pull request overlaps the unminified Vite UI build with Postgres bootstrap inside `start-e2e-server.ts`, splits the top 3 serial specs into 6 balanced specs (keeping all 3 anchor filenames and 100% of 20 tests intact), makes `e2e-shard.mjs` CPU-aware (`3.2x` on 8-vCPU / `1.85x` on 4-vCPU), refreshes all 58 specs in `e2e-shard-durations.json`, and scales AWS `e2e_shards` `12 -> 16` while keeping `ubuntu-latest` hosted at `4` — bringing simulated E2E test execution to `~90–96s` (`-60 to -75s`). ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** E2E shard wall-clock ceiling on 8-core PR runners (`tests/e2e/`, `scripts/e2e-shard.mjs`, `scripts/e2e-shard-durations.json`, `.github/ci-task-matrix.json`, `.github/workflows/pr-trusted.yml`). **Subsystem affected** tests/e2e/ and CI — Playwright server bootstrap, serial spec sharding, and E2E shard matrix **Current behavior** E2E shards take `152–171s` on 8-core runners because `vite build ui` runs serially before Postgres boot, 3 serial specs run `75–91s` each, `e2e-shard.mjs` assumes 4-vCPU `1.85x` parallel speedup, and AWS runs 12 shards. **Proposed behavior** Overlap unminified Vite UI build with embedded Postgres boot in `tests/e2e/start-e2e-server.ts`, split the top 3 serial specs into 6 balanced specs (preserving anchor paths and all tests), use CPU-aware parallel speedup (`3.2x` on 8-vCPU / `1.85x` on 4-vCPU) with refreshed 58-spec durations, and run 16 AWS E2E shards (`8 serial + 8 parallel`, `59.7–76.5s` Playwright) while keeping `ubuntu-latest` hosted at `4`. ## What Changed - **Overlapped UI build with Postgres bootstrap (`tests/e2e/playwright.config.ts`, `tests/e2e/start-e2e-server.ts`):** - Launches `start-e2e-server.ts` directly with `PAPERCLIP_E2E_BUILD_UI` (`0` when `PAPERCLIP_E2E_SKIP_UI_BUILD=1`), overlapping `vite build ui --outDir ../server/ui-dist --emptyOutDir --minify false` concurrently inside `Promise.all([dbPromise, import("../../server/src/index.js"), uiReady])` with `stopUiBuild()` and `dbPromise` cleanup on signals/failure, plus `maintenance_work_mem = 128MB` / `work_mem = 32MB` on disposable PG. - **Split top 3 serial E2E specs (100% of 20 tests preserved, all 3 anchor filenames & `maps/` links intact, all 3 new siblings registered in BOTH `playwright.config.ts` and `scripts/e2e-shard.mjs` `SERIAL_SPECS`):** - `agent-configuration.spec.ts` (3 tests) + `agent-configuration-revisions.spec.ts` (5 tests) + `agent-configuration.shared.ts` - `agent-chat-sessions.spec.ts` (3 tests) + `agent-chat-sessions-navigation.spec.ts` (3 tests) - `onboarding.spec.ts` (3 tests) + `onboarding-resume.spec.ts` (3 tests) - **CPU-aware speedup, refreshed 58-spec manifest, & 16 AWS E2E shards (`scripts/e2e-shard.mjs`, `scripts/e2e-shard-durations.json`, `.github/ci-task-matrix.json`, `.github/workflows/pr-trusted.yml`, `.github/scripts/tests/ci-plan.test.mjs`, `scripts/__tests__/e2e-shard.test.mjs`):** - Exported `EFFECTIVE_PARALLEL_SPEEDUP_4W = 3.2` and `resolveEffectiveParallelSpeedup(cpus)` matching `playwright.config.ts` worker scaling. - Refreshed all 58/58 spec weights from live 8-core runs `45668834558` & `45667106472`. - Scaled AWS `e2e_shards` `12 -> 16` while keeping `ubuntu-latest` hosted at `4`. ## Verification - `node --test scripts/__tests__/e2e-shard.test.mjs .github/scripts/tests/ci-plan.test.mjs scripts/check-test-budget.test.mjs scripts/__tests__/merge-queue-checks-workflow.test.mjs` — **45/45 PASS** - `npx playwright test --config tests/e2e/playwright.config.ts --list` on all 6 split specs — **20 tests in 6 files** - `tsc --strict --noEmit` across all 9 edited `tests/e2e/*.ts` files — **0 errors** - `node scripts/check-test-budget.mjs --base origin/master` and `node scripts/check-maps.mjs` — **PASS** - `ruby -ryaml -e 'YAML.load_file(".github/workflows/pr-trusted.yml")'` — **YAML OK** ## Risks - Low risk: all 3 original serial spec anchor filenames remain intact, `PAPERCLIP_E2E_SKIP_UI_BUILD=1` is preserved, signal/failure handlers clean up both the Vite child and embedded PG, `ubuntu-latest` stays at 4 hosted shards, and full CI runs all E2E shards live before merge. ## Model Used - Gemini 4 Neon (High) via Antigravity agent swarm (`e2e-opt`, `verifier`, `ci-pipeline`). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge
This commit is contained in:
1 parent
1c36d24d0c
commit
7563842165
16 files changed
+1098
-939
No files matched your search
+48
-24
@@ -323,74 +323,98 @@
|
||||
"e2e_shards": [
|
||||
{
|
||||
"shard_index": 0,
|
||||
"shard_count": 12,
|
||||
"shard_label": "1/12",
|
||||
"shard_count": 16,
|
||||
"shard_label": "1/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 1,
|
||||
"shard_count": 12,
|
||||
"shard_label": "2/12",
|
||||
"shard_count": 16,
|
||||
"shard_label": "2/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 2,
|
||||
"shard_count": 12,
|
||||
"shard_label": "3/12",
|
||||
"shard_count": 16,
|
||||
"shard_label": "3/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 3,
|
||||
"shard_count": 12,
|
||||
"shard_label": "4/12",
|
||||
"shard_count": 16,
|
||||
"shard_label": "4/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 4,
|
||||
"shard_count": 12,
|
||||
"shard_label": "5/12",
|
||||
"shard_count": 16,
|
||||
"shard_label": "5/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 5,
|
||||
"shard_count": 12,
|
||||
"shard_label": "6/12",
|
||||
"shard_count": 16,
|
||||
"shard_label": "6/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 6,
|
||||
"shard_count": 12,
|
||||
"shard_label": "7/12",
|
||||
"shard_count": 16,
|
||||
"shard_label": "7/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 7,
|
||||
"shard_count": 12,
|
||||
"shard_label": "8/12",
|
||||
"shard_count": 16,
|
||||
"shard_label": "8/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 8,
|
||||
"shard_count": 12,
|
||||
"shard_label": "9/12",
|
||||
"shard_count": 16,
|
||||
"shard_label": "9/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 9,
|
||||
"shard_count": 12,
|
||||
"shard_label": "10/12",
|
||||
"shard_count": 16,
|
||||
"shard_label": "10/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 10,
|
||||
"shard_count": 12,
|
||||
"shard_label": "11/12",
|
||||
"shard_count": 16,
|
||||
"shard_label": "11/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 11,
|
||||
"shard_count": 12,
|
||||
"shard_label": "12/12",
|
||||
"shard_count": 16,
|
||||
"shard_label": "12/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 12,
|
||||
"shard_count": 16,
|
||||
"shard_label": "13/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 13,
|
||||
"shard_count": 16,
|
||||
"shard_label": "14/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 14,
|
||||
"shard_count": 16,
|
||||
"shard_label": "15/16",
|
||||
"task": "ci:e2e"
|
||||
},
|
||||
{
|
||||
"shard_index": 15,
|
||||
"shard_count": 16,
|
||||
"shard_label": "16/16",
|
||||
"task": "ci:e2e"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -49,7 +49,7 @@ test("compactHostedEntries halves ubuntu-latest fan-out while preserving 100% of
|
||||
const full = plan(["package.json"], { forceReason: "Full suite requested by label" });
|
||||
const awsJobs = Object.values(full.jobs).reduce((sum, lane) => sum + lane.total, 0);
|
||||
const hostedJobs = Object.values(full.jobs).reduce((sum, lane) => sum + (lane.hosted_total ?? lane.total), 0);
|
||||
assert.equal(awsJobs, 66);
|
||||
assert.equal(awsJobs, 70);
|
||||
assert.equal(hostedJobs, 33);
|
||||
assert.ok(Buffer.byteLength(JSON.stringify(full)) < 32_768, "dual-profile plan stays compact for GITHUB_OUTPUT/env");
|
||||
|
||||
@@ -93,7 +93,7 @@ test("compactHostedEntries halves ubuntu-latest fan-out while preserving 100% of
|
||||
assert.deepEqual(uiPr.jobs.general_tests.hosted_matrix.include, [
|
||||
{ group: "general-workspaces-a", group_label: "workspaces-a (1/1)", shard_index: 0, shard_count: 1, task: "ci:workspaces-a" },
|
||||
]);
|
||||
assert.equal(uiPr.jobs.e2e_shards.selected, 12);
|
||||
assert.equal(uiPr.jobs.e2e_shards.selected, 16);
|
||||
assert.equal(uiPr.jobs.e2e_shards.hosted_selected, 4);
|
||||
|
||||
const futureEntries = Array.from({ length: 10 }, (_, shard_index) => ({
|
||||
@@ -105,7 +105,7 @@ test("compactHostedEntries halves ubuntu-latest fan-out while preserving 100% of
|
||||
|
||||
const summary = planSummary(full);
|
||||
assert.match(summary, /27\/27 \(hosted: 12\/12\)/);
|
||||
assert.match(summary, /12\/12 \(hosted: 4\/4\)/);
|
||||
assert.match(summary, /16\/16 \(hosted: 4\/4\)/);
|
||||
});
|
||||
|
||||
test("a UI component retains browser and build coverage without unrelated server/Rust jobs", () => {
|
||||
@@ -213,7 +213,7 @@ test("PR workflow keeps Build fast and passes PR-mode context to typecheck and V
|
||||
const runnerSupport = workflow.split("\n verify_runner_e2e_support:\n")[1].split("\n verify:\n")[0];
|
||||
assert.match(runnerSupport, /--shard-index \$\{\{ matrix\.shard_index \}\} --shard-count \$\{\{ matrix\.shard_count \}\}/);
|
||||
assert.equal(lanes.verify_runner_e2e_support.length, 4, "Runner support suite should be 4-way sharded");
|
||||
assert.equal(lanes.e2e_shards.length, 12, "E2E should be 12-way sharded");
|
||||
assert.equal(lanes.e2e_shards.length, 16, "E2E should be 16-way sharded");
|
||||
const typecheck = workflow.split("\n typecheck_release_registry:\n")[1].split("\n general_tests:\n")[0];
|
||||
assert.match(typecheck, /fetch-depth: 2/);
|
||||
assert.match(typecheck, /CI_PLAN: \$\{\{ needs\.gate\.outputs\.plan \}\}/);
|
||||
|
||||
@@ -1831,7 +1831,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: ${{ needs.gate.outputs.runner == 'ubuntu-latest' && 4 || 256 }}
|
||||
matrix: ${{ fromJSON(needs.gate.outputs.plan != '' && toJSON((needs.gate.outputs.runner == 'ubuntu-latest' && fromJSON(needs.gate.outputs.plan).jobs.e2e_shards.hosted_matrix) || fromJSON(needs.gate.outputs.plan).jobs.e2e_shards.matrix) || (needs.gate.outputs.runner == 'ubuntu-latest' && '{"include":[{"shard_index":0,"shard_count":4,"shard_label":"1/4","task":"ci:e2e"},{"shard_index":1,"shard_count":4,"shard_label":"2/4","task":"ci:e2e"},{"shard_index":2,"shard_count":4,"shard_label":"3/4","task":"ci:e2e"},{"shard_index":3,"shard_count":4,"shard_label":"4/4","task":"ci:e2e"}]}' || '{"include":[{"shard_index":0,"shard_count":12,"shard_label":"1/12","task":"ci:e2e"},{"shard_index":1,"shard_count":12,"shard_label":"2/12","task":"ci:e2e"},{"shard_index":2,"shard_count":12,"shard_label":"3/12","task":"ci:e2e"},{"shard_index":3,"shard_count":12,"shard_label":"4/12","task":"ci:e2e"},{"shard_index":4,"shard_count":12,"shard_label":"5/12","task":"ci:e2e"},{"shard_index":5,"shard_count":12,"shard_label":"6/12","task":"ci:e2e"},{"shard_index":6,"shard_count":12,"shard_label":"7/12","task":"ci:e2e"},{"shard_index":7,"shard_count":12,"shard_label":"8/12","task":"ci:e2e"},{"shard_index":8,"shard_count":12,"shard_label":"9/12","task":"ci:e2e"},{"shard_index":9,"shard_count":12,"shard_label":"10/12","task":"ci:e2e"},{"shard_index":10,"shard_count":12,"shard_label":"11/12","task":"ci:e2e"},{"shard_index":11,"shard_count":12,"shard_label":"12/12","task":"ci:e2e"}]}')) }}
|
||||
matrix: ${{ fromJSON(needs.gate.outputs.plan != '' && toJSON((needs.gate.outputs.runner == 'ubuntu-latest' && fromJSON(needs.gate.outputs.plan).jobs.e2e_shards.hosted_matrix) || fromJSON(needs.gate.outputs.plan).jobs.e2e_shards.matrix) || (needs.gate.outputs.runner == 'ubuntu-latest' && '{"include":[{"shard_index":0,"shard_count":4,"shard_label":"1/4","task":"ci:e2e"},{"shard_index":1,"shard_count":4,"shard_label":"2/4","task":"ci:e2e"},{"shard_index":2,"shard_count":4,"shard_label":"3/4","task":"ci:e2e"},{"shard_index":3,"shard_count":4,"shard_label":"4/4","task":"ci:e2e"}]}' || '{"include":[{"shard_index":0,"shard_count":16,"shard_label":"1/16","task":"ci:e2e"},{"shard_index":1,"shard_count":16,"shard_label":"2/16","task":"ci:e2e"},{"shard_index":2,"shard_count":16,"shard_label":"3/16","task":"ci:e2e"},{"shard_index":3,"shard_count":16,"shard_label":"4/16","task":"ci:e2e"},{"shard_index":4,"shard_count":16,"shard_label":"5/16","task":"ci:e2e"},{"shard_index":5,"shard_count":16,"shard_label":"6/16","task":"ci:e2e"},{"shard_index":6,"shard_count":16,"shard_label":"7/16","task":"ci:e2e"},{"shard_index":7,"shard_count":16,"shard_label":"8/16","task":"ci:e2e"},{"shard_index":8,"shard_count":16,"shard_label":"9/16","task":"ci:e2e"},{"shard_index":9,"shard_count":16,"shard_label":"10/16","task":"ci:e2e"},{"shard_index":10,"shard_count":16,"shard_label":"11/16","task":"ci:e2e"},{"shard_index":11,"shard_count":16,"shard_label":"12/16","task":"ci:e2e"},{"shard_index":12,"shard_count":16,"shard_label":"13/16","task":"ci:e2e"},{"shard_index":13,"shard_count":16,"shard_label":"14/16","task":"ci:e2e"},{"shard_index":14,"shard_count":16,"shard_label":"15/16","task":"ci:e2e"},{"shard_index":15,"shard_count":16,"shard_label":"16/16","task":"ci:e2e"}]}')) }}
|
||||
|
||||
env:
|
||||
PAPERCLIP_CI_PROFILE: ${{ needs.gate.outputs.profile_ci }}
|
||||
|
||||
@@ -10,11 +10,13 @@ import { defaultSuiteWeight, loadShardDurations } from "../general-server-shard.
|
||||
import {
|
||||
DEFAULT_PARALLEL_WORKERS,
|
||||
EFFECTIVE_PARALLEL_SPEEDUP,
|
||||
EFFECTIVE_PARALLEL_SPEEDUP_4W,
|
||||
IGNORED_SPECS,
|
||||
SERIAL_SPECS,
|
||||
isSerialE2eSpec,
|
||||
listE2eSpecs,
|
||||
partitionE2eShards,
|
||||
resolveEffectiveParallelSpeedup,
|
||||
selectE2eShard,
|
||||
} from "../e2e-shard.mjs";
|
||||
|
||||
@@ -29,7 +31,8 @@ const routingWorkflow = path.join(repoRoot, ".github", "workflows", "ci-routing.
|
||||
|
||||
const ciTaskMatrixPath = path.join(repoRoot, ".github", "ci-task-matrix.json");
|
||||
const SHARD_COUNT = JSON.parse(readFileSync(ciTaskMatrixPath, "utf8")).e2e_shards.length;
|
||||
const TARGET_PHASE3_SHARD_COUNT = 12;
|
||||
const TARGET_AWS_SHARD_COUNT = 16;
|
||||
const TARGET_HOSTED_SHARD_COUNT = 4;
|
||||
|
||||
function runShard(args) {
|
||||
const result = spawnSync(process.execPath, [script, ...args], { cwd: repoRoot, encoding: "utf8" });
|
||||
@@ -159,40 +162,51 @@ test("playwright.config.ts supports skipping the UI build when PAPERCLIP_E2E_SKI
|
||||
const config = readFileSync(playwrightConfig, "utf8");
|
||||
assert.match(config, /PAPERCLIP_E2E_SKIP_UI_BUILD/);
|
||||
assert.match(config, /ui-dist.*index\.html/);
|
||||
assert.match(config, /--minify false/);
|
||||
assert.match(config, /PAPERCLIP_E2E_BUILD_UI/);
|
||||
assert.match(config, /availableParallelism/);
|
||||
});
|
||||
|
||||
test("start-e2e-server.ts boots disposable embedded Postgres without durable fsync before migrations", () => {
|
||||
test("start-e2e-server.ts boots disposable embedded Postgres without durable fsync and overlaps UI build", () => {
|
||||
const bootstrap = readFileSync(path.join(repoRoot, "tests", "e2e", "start-e2e-server.ts"), "utf8");
|
||||
assert.match(bootstrap, /--no-sync/);
|
||||
assert.match(bootstrap, /fsync = off/);
|
||||
assert.match(bootstrap, /synchronous_commit = off/);
|
||||
assert.match(bootstrap, /full_page_writes = off/);
|
||||
assert.match(bootstrap, /PAPERCLIP_E2E_BUILD_UI/);
|
||||
assert.match(bootstrap, /startParallelUiBuild/);
|
||||
assert.match(bootstrap, /"--minify",\s*"false"/);
|
||||
assert.match(bootstrap, /Promise\.all\(/);
|
||||
});
|
||||
|
||||
test("12-shard partitioning stays complete, segregated, and balanced under 145s estimated wall-clock", () => {
|
||||
test("resolveEffectiveParallelSpeedup matches Playwright worker scaling for 4-vCPU and 8-vCPU runners", () => {
|
||||
assert.equal(resolveEffectiveParallelSpeedup(2), 1);
|
||||
assert.equal(resolveEffectiveParallelSpeedup(4), EFFECTIVE_PARALLEL_SPEEDUP);
|
||||
assert.equal(resolveEffectiveParallelSpeedup(6), 2.55);
|
||||
assert.equal(resolveEffectiveParallelSpeedup(8), EFFECTIVE_PARALLEL_SPEEDUP_4W);
|
||||
assert.equal(resolveEffectiveParallelSpeedup(16), EFFECTIVE_PARALLEL_SPEEDUP_4W);
|
||||
});
|
||||
|
||||
test("16-shard AWS partitioning stays complete, segregated, and balanced under 85s estimated wall-clock", () => {
|
||||
const durations = loadShardDurations(durationsManifest);
|
||||
const specs = listE2eSpecs();
|
||||
const fallbackWeight = defaultSuiteWeight(durations);
|
||||
const shards = partitionE2eShards(specs, TARGET_PHASE3_SHARD_COUNT, durations, {
|
||||
parallelWorkers: EFFECTIVE_PARALLEL_SPEEDUP,
|
||||
const shards = partitionE2eShards(specs, TARGET_AWS_SHARD_COUNT, durations, {
|
||||
parallelWorkers: EFFECTIVE_PARALLEL_SPEEDUP_4W,
|
||||
});
|
||||
assert.equal(shards.length, TARGET_PHASE3_SHARD_COUNT);
|
||||
assert.equal(shards.length, TARGET_AWS_SHARD_COUNT);
|
||||
const combined = shards.flatMap((shard) => shard.files);
|
||||
assert.deepEqual([...combined].sort(), [...specs].sort());
|
||||
for (const shard of shards) {
|
||||
assert.ok(shard.files.length > 0, "no 12-shard bucket may be empty");
|
||||
assert.ok(shard.files.length > 0, "no 16-shard bucket may be empty");
|
||||
const serialCount = shard.files.filter(isSerialE2eSpec).length;
|
||||
assert.ok(
|
||||
serialCount === 0 || serialCount === shard.files.length,
|
||||
`12-shard bucket must not mix serial and parallel specs: ${shard.files.join(", ")}`,
|
||||
`16-shard bucket must not mix serial and parallel specs: ${shard.files.join(", ")}`,
|
||||
);
|
||||
}
|
||||
const wallWeights = shards.map((shard) => {
|
||||
const serialSum = shard.files.reduce((sum, file) => sum + (durations[file] ?? fallbackWeight), 0);
|
||||
return shard.mode === "parallel" ? serialSum / EFFECTIVE_PARALLEL_SPEEDUP : serialSum;
|
||||
return shard.mode === "parallel" ? serialSum / EFFECTIVE_PARALLEL_SPEEDUP_4W : serialSum;
|
||||
});
|
||||
const heaviest = Math.max(...wallWeights);
|
||||
const totalWall = wallWeights.reduce((sum, weight) => sum + weight, 0);
|
||||
@@ -200,17 +214,36 @@ test("12-shard partitioning stays complete, segregated, and balanced under 145s
|
||||
0,
|
||||
...specs.filter(isSerialE2eSpec).map((file) => durations[file] ?? fallbackWeight),
|
||||
);
|
||||
const bound = Math.max((totalWall / TARGET_PHASE3_SHARD_COUNT) * 1.15, largestSerialSpec);
|
||||
const bound = Math.max((totalWall / TARGET_AWS_SHARD_COUNT) * 1.15, largestSerialSpec);
|
||||
assert.ok(
|
||||
heaviest <= bound,
|
||||
`heaviest 12-shard bucket ${Math.round(heaviest)}ms exceeds the balance bound (${Math.round(bound)}ms)`,
|
||||
`heaviest 16-shard bucket ${Math.round(heaviest)}ms exceeds the balance bound (${Math.round(bound)}ms)`,
|
||||
);
|
||||
assert.ok(
|
||||
heaviest <= 145_000,
|
||||
`heaviest 12-shard bucket ${Math.round(heaviest)}ms exceeds 145s Phase 3 ceiling`,
|
||||
heaviest <= 85_000,
|
||||
`heaviest 16-shard bucket ${Math.round(heaviest)}ms exceeds 85s Phase 5 ceiling`,
|
||||
);
|
||||
});
|
||||
|
||||
test("4-shard hosted partitioning stays complete and segregated on 4-vCPU runners", () => {
|
||||
const durations = loadShardDurations(durationsManifest);
|
||||
const specs = listE2eSpecs();
|
||||
const shards = partitionE2eShards(specs, TARGET_HOSTED_SHARD_COUNT, durations, {
|
||||
parallelWorkers: EFFECTIVE_PARALLEL_SPEEDUP,
|
||||
});
|
||||
assert.equal(shards.length, TARGET_HOSTED_SHARD_COUNT);
|
||||
const combined = shards.flatMap((shard) => shard.files);
|
||||
assert.deepEqual([...combined].sort(), [...specs].sort());
|
||||
for (const shard of shards) {
|
||||
assert.ok(shard.files.length > 0, "no 4-shard hosted bucket may be empty");
|
||||
const serialCount = shard.files.filter(isSerialE2eSpec).length;
|
||||
assert.ok(
|
||||
serialCount === 0 || serialCount === shard.files.length,
|
||||
`4-shard hosted bucket must not mix serial and parallel specs: ${shard.files.join(", ")}`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("the duration manifest only names specs that still exist", () => {
|
||||
const durations = loadShardDurations(durationsManifest);
|
||||
assert.ok(Object.keys(durations).length > 0, "expected a populated duration manifest");
|
||||
@@ -225,11 +258,11 @@ test("the weighted partition keeps the shards close to balanced", () => {
|
||||
const specs = listE2eSpecs();
|
||||
const fallbackWeight = defaultSuiteWeight(durations);
|
||||
const shards = partitionE2eShards(specs, SHARD_COUNT, durations, {
|
||||
parallelWorkers: EFFECTIVE_PARALLEL_SPEEDUP,
|
||||
parallelWorkers: EFFECTIVE_PARALLEL_SPEEDUP_4W,
|
||||
});
|
||||
const wallWeights = shards.map((shard) => {
|
||||
const serialSum = shard.files.reduce((sum, file) => sum + (durations[file] ?? fallbackWeight), 0);
|
||||
return shard.mode === "parallel" ? serialSum / EFFECTIVE_PARALLEL_SPEEDUP : serialSum;
|
||||
return shard.mode === "parallel" ? serialSum / EFFECTIVE_PARALLEL_SPEEDUP_4W : serialSum;
|
||||
});
|
||||
|
||||
const heaviest = Math.max(...wallWeights);
|
||||
|
||||
@@ -1,81 +1,85 @@
|
||||
{
|
||||
"$comment": "Refreshed from successful merged PR #22729 (run 45440355579) and PR #22679 (run 45314200835) with exact per-test split totals for agent-chat-projects, chat-adapters-ui-providers, and chat-adapters-ui-messaging. scripts/e2e-shard.mjs uses these weights only to place specs on shards; they never change which specs run.",
|
||||
"$comment": "Refreshed from live 8-vCPU pre-baked AMI PR runs 45668834558 and 45667106472 with exact per-test split totals for agent-configuration, agent-chat-sessions, and onboarding. scripts/e2e-shard.mjs uses these weights only to place specs on shards; they never change which specs run.",
|
||||
"unit": "ms",
|
||||
"sources": [
|
||||
{
|
||||
"pull": 22729,
|
||||
"run": 45440355579,
|
||||
"pull": 22954,
|
||||
"run": 45668834558,
|
||||
"attempt": 1,
|
||||
"sha": "6ca7a27481e1af45c60069a563632f2b00a008a7",
|
||||
"url": "https://github.com/paperclipai/paperclip/actions/runs/45440355579"
|
||||
"sha": "8aae20a022ae3401d5f419cb5dc8a8811259b248",
|
||||
"url": "https://github.com/paperclipai/paperclip/actions/runs/45668834558"
|
||||
},
|
||||
{
|
||||
"pull": 22679,
|
||||
"run": 45314200835,
|
||||
"attempt": 3,
|
||||
"sha": "d930b4a9b30bc2d9e9a80f5ae93ca95a659bc52c",
|
||||
"url": "https://github.com/paperclipai/paperclip/actions/runs/45314200835"
|
||||
"pull": 22956,
|
||||
"run": 45667106472,
|
||||
"attempt": 1,
|
||||
"sha": "44406454daaad1dcfb3d70e859d01fcab7059377",
|
||||
"url": "https://github.com/paperclipai/paperclip/actions/runs/45667106472"
|
||||
}
|
||||
],
|
||||
"coverage": {
|
||||
"measured": 54,
|
||||
"withSetup": 54,
|
||||
"inventory": 54
|
||||
"measured": 58,
|
||||
"withSetup": 58,
|
||||
"inventory": 58
|
||||
},
|
||||
"durations": {
|
||||
"tests/e2e/acp-stop-continuation.spec.ts": 69300,
|
||||
"tests/e2e/action-test-agent-picker.spec.ts": 7200,
|
||||
"tests/e2e/agent-chat-messages.spec.ts": 69900,
|
||||
"tests/e2e/agent-chat-projects-handoff.spec.ts": 93000,
|
||||
"tests/e2e/agent-chat-projects.spec.ts": 88900,
|
||||
"tests/e2e/agent-chat-sessions.spec.ts": 104100,
|
||||
"tests/e2e/agent-configuration.spec.ts": 111700,
|
||||
"tests/e2e/agentmail.spec.ts": 17100,
|
||||
"tests/e2e/ai-personal-connection-recovery.spec.ts": 12900,
|
||||
"tests/e2e/announcement-first-session.spec.ts": 10900,
|
||||
"tests/e2e/announcement-placement.spec.ts": 22700,
|
||||
"tests/e2e/app-not-connected.spec.ts": 16700,
|
||||
"tests/e2e/applications-crud.spec.ts": 9400,
|
||||
"tests/e2e/apps-prosumer-mcp-flow.spec.ts": 21500,
|
||||
"tests/e2e/archived-company-url.spec.ts": 6200,
|
||||
"tests/e2e/artifact-tab-arrival.spec.ts": 18100,
|
||||
"tests/e2e/artifact-uploads.spec.ts": 45900,
|
||||
"tests/e2e/board-attachment-receipts.spec.ts": 147338,
|
||||
"tests/e2e/cases-read-only.spec.ts": 9900,
|
||||
"tests/e2e/chat-adapters-ui-messaging-batches.spec.ts": 95000,
|
||||
"tests/e2e/chat-adapters-ui-messaging.spec.ts": 100900,
|
||||
"tests/e2e/chat-adapters-ui-providers-catalog.spec.ts": 133000,
|
||||
"tests/e2e/chat-adapters-ui-providers.spec.ts": 86800,
|
||||
"tests/e2e/chunk-load-recovery.spec.ts": 17000,
|
||||
"tests/e2e/classic-workspace.spec.ts": 10000,
|
||||
"tests/e2e/cloud-auth.spec.ts": 49000,
|
||||
"tests/e2e/company-context-refresh.spec.ts": 3600,
|
||||
"tests/e2e/completed-task-paused-assignee.spec.ts": 32400,
|
||||
"tests/e2e/composer-stop.spec.ts": 41900,
|
||||
"tests/e2e/conference-room-typing-intro.spec.ts": 60600,
|
||||
"tests/e2e/connection-intents.spec.ts": 25600,
|
||||
"tests/e2e/connection-reviews.spec.ts": 121300,
|
||||
"tests/e2e/coordinator-inbox-views.spec.ts": 31400,
|
||||
"tests/e2e/daytona-connector.spec.ts": 6300,
|
||||
"tests/e2e/disconnect-resilience.spec.ts": 116700,
|
||||
"tests/e2e/disconnect-write-recovery.spec.ts": 56600,
|
||||
"tests/e2e/document-image-gallery.spec.ts": 49400,
|
||||
"tests/e2e/mcp-user-stories.spec.ts": 45900,
|
||||
"tests/e2e/new-task-picker-touch.spec.ts": 23500,
|
||||
"tests/e2e/onboarding.spec.ts": 78300,
|
||||
"tests/e2e/paused-composer.spec.ts": 65200,
|
||||
"tests/e2e/plan-task-fixture.spec.ts": 9200,
|
||||
"tests/e2e/project-repositories.spec.ts": 19000,
|
||||
"tests/e2e/railway-catalog.spec.ts": 5400,
|
||||
"tests/e2e/runner-e2e-dashboard.spec.ts": 5378,
|
||||
"tests/e2e/runner-task-creation.spec.ts": 35000,
|
||||
"tests/e2e/sidebar-takeover.spec.ts": 12100,
|
||||
"tests/e2e/signoff-policy.spec.ts": 57208,
|
||||
"tests/e2e/smoke-lab-p1-p4.spec.ts": 22500,
|
||||
"tests/e2e/smoke-lab-p5-p7.spec.ts": 19100,
|
||||
"tests/e2e/task-loading-frame.spec.ts": 44200,
|
||||
"tests/e2e/task-reload.spec.ts": 26600,
|
||||
"tests/e2e/text-attachment-tabs.spec.ts": 16000,
|
||||
"tests/e2e/unikraft-connector.spec.ts": 5800
|
||||
"tests/e2e/acp-stop-continuation.spec.ts": 94900,
|
||||
"tests/e2e/action-test-agent-picker.spec.ts": 10100,
|
||||
"tests/e2e/agent-chat-messages.spec.ts": 65450,
|
||||
"tests/e2e/agent-chat-projects-handoff.spec.ts": 59700,
|
||||
"tests/e2e/agent-chat-projects.spec.ts": 61808,
|
||||
"tests/e2e/agent-chat-sessions-navigation.spec.ts": 41400,
|
||||
"tests/e2e/agent-chat-sessions.spec.ts": 38500,
|
||||
"tests/e2e/agent-configuration-revisions.spec.ts": 46100,
|
||||
"tests/e2e/agent-configuration.spec.ts": 45300,
|
||||
"tests/e2e/agentmail.spec.ts": 24250,
|
||||
"tests/e2e/ai-personal-connection-recovery.spec.ts": 11450,
|
||||
"tests/e2e/announcement-first-session.spec.ts": 24150,
|
||||
"tests/e2e/announcement-placement.spec.ts": 24050,
|
||||
"tests/e2e/app-not-connected.spec.ts": 19150,
|
||||
"tests/e2e/applications-crud.spec.ts": 12050,
|
||||
"tests/e2e/apps-prosumer-mcp-flow.spec.ts": 34650,
|
||||
"tests/e2e/archived-company-url.spec.ts": 21300,
|
||||
"tests/e2e/artifact-tab-arrival.spec.ts": 15400,
|
||||
"tests/e2e/artifact-uploads.spec.ts": 56150,
|
||||
"tests/e2e/board-attachment-receipts.spec.ts": 120395,
|
||||
"tests/e2e/cases-read-only.spec.ts": 11100,
|
||||
"tests/e2e/chat-adapters-ui-messaging-batches.spec.ts": 101700,
|
||||
"tests/e2e/chat-adapters-ui-messaging.spec.ts": 107700,
|
||||
"tests/e2e/chat-adapters-ui-providers-catalog.spec.ts": 135650,
|
||||
"tests/e2e/chat-adapters-ui-providers.spec.ts": 141232,
|
||||
"tests/e2e/chunk-load-recovery.spec.ts": 25150,
|
||||
"tests/e2e/classic-workspace.spec.ts": 6850,
|
||||
"tests/e2e/cloud-auth.spec.ts": 55000,
|
||||
"tests/e2e/company-context-refresh.spec.ts": 3650,
|
||||
"tests/e2e/completed-task-paused-assignee.spec.ts": 38400,
|
||||
"tests/e2e/composer-stop.spec.ts": 34700,
|
||||
"tests/e2e/conference-room-typing-intro.spec.ts": 65500,
|
||||
"tests/e2e/connection-intents.spec.ts": 19550,
|
||||
"tests/e2e/connection-reviews.spec.ts": 114950,
|
||||
"tests/e2e/coordinator-inbox-views.spec.ts": 18900,
|
||||
"tests/e2e/daytona-connector.spec.ts": 5500,
|
||||
"tests/e2e/disconnect-resilience.spec.ts": 112800,
|
||||
"tests/e2e/disconnect-write-recovery.spec.ts": 65350,
|
||||
"tests/e2e/document-image-gallery.spec.ts": 44050,
|
||||
"tests/e2e/mcp-user-stories.spec.ts": 33500,
|
||||
"tests/e2e/new-task-picker-touch.spec.ts": 25400,
|
||||
"tests/e2e/onboarding-resume.spec.ts": 35200,
|
||||
"tests/e2e/onboarding.spec.ts": 40100,
|
||||
"tests/e2e/paused-composer.spec.ts": 55850,
|
||||
"tests/e2e/plan-task-fixture.spec.ts": 11100,
|
||||
"tests/e2e/project-pinning.spec.ts": 7000,
|
||||
"tests/e2e/project-repositories.spec.ts": 20950,
|
||||
"tests/e2e/railway-catalog.spec.ts": 7400,
|
||||
"tests/e2e/runner-e2e-dashboard.spec.ts": 3492,
|
||||
"tests/e2e/runner-task-creation.spec.ts": 46950,
|
||||
"tests/e2e/sidebar-takeover.spec.ts": 18450,
|
||||
"tests/e2e/signoff-policy.spec.ts": 73155,
|
||||
"tests/e2e/smoke-lab-p1-p4.spec.ts": 19650,
|
||||
"tests/e2e/smoke-lab-p5-p7.spec.ts": 13450,
|
||||
"tests/e2e/task-loading-frame.spec.ts": 50100,
|
||||
"tests/e2e/task-reload.spec.ts": 40550,
|
||||
"tests/e2e/text-attachment-tabs.spec.ts": 26950,
|
||||
"tests/e2e/unikraft-connector.spec.ts": 6750
|
||||
}
|
||||
}
|
||||
+26
-9
@@ -1,4 +1,5 @@
|
||||
import { readdirSync } from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
@@ -22,7 +23,9 @@ export const IGNORED_SPECS = ["in-feed-native/**", "multi-user.spec.ts", "multi-
|
||||
export const SERIAL_SPECS = [
|
||||
"agent-chat-projects-handoff.spec.ts",
|
||||
"agent-chat-projects.spec.ts",
|
||||
"agent-chat-sessions-navigation.spec.ts",
|
||||
"agent-chat-sessions.spec.ts",
|
||||
"agent-configuration-revisions.spec.ts",
|
||||
"agent-configuration.spec.ts",
|
||||
"ai-personal-connection-recovery.spec.ts",
|
||||
"cases-read-only.spec.ts",
|
||||
@@ -30,19 +33,23 @@ export const SERIAL_SPECS = [
|
||||
"composer-stop.spec.ts",
|
||||
"connection-intents.spec.ts",
|
||||
"document-image-gallery.spec.ts",
|
||||
"onboarding-resume.spec.ts",
|
||||
"onboarding.spec.ts",
|
||||
"smoke-lab-p1-p4.spec.ts",
|
||||
"smoke-lab-p5-p7.spec.ts",
|
||||
];
|
||||
|
||||
// Matches the 4-vCPU CI worker count in tests/e2e/playwright.config.ts for
|
||||
// shards that contain only parallel-safe specs. Empirical wall-clock speedup
|
||||
// on 4-vCPU runners with 2 Chromium workers sharing one server + non-durable
|
||||
// Postgres is ~1.85x (measured 1.78x-1.91x across shards 4-8 on run
|
||||
// 45440355579); using the empirical factor keeps serial and parallel shards
|
||||
// balanced across 12 shards.
|
||||
export const DEFAULT_PARALLEL_WORKERS = 2;
|
||||
export const EFFECTIVE_PARALLEL_SPEEDUP = 1.85;
|
||||
export const EFFECTIVE_PARALLEL_SPEEDUP_4W = 3.2;
|
||||
|
||||
export function resolveEffectiveParallelSpeedup(cpus = os.availableParallelism()) {
|
||||
const workers = Math.max(1, Math.min(4, Math.floor(cpus / 2)));
|
||||
if (workers >= 4) return EFFECTIVE_PARALLEL_SPEEDUP_4W;
|
||||
if (workers === 3) return 2.55;
|
||||
if (workers === 2) return EFFECTIVE_PARALLEL_SPEEDUP;
|
||||
return 1;
|
||||
}
|
||||
|
||||
export function isSerialE2eSpec(file) {
|
||||
return SERIAL_SPECS.includes(path.posix.basename(file.split(path.sep).join("/")));
|
||||
@@ -117,26 +124,36 @@ export function selectE2eShard(files, shardIndex, shardCount, durations = {}, op
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = { shardIndex: 0, shardCount: 1 };
|
||||
const args = { shardIndex: 0, shardCount: 1, parallelSpeedup: null };
|
||||
for (let index = 0; index < argv.length; index += 1) {
|
||||
if (argv[index] === "--shard-index") args.shardIndex = Number(argv[index + 1]);
|
||||
if (argv[index] === "--shard-count") args.shardCount = Number(argv[index + 1]);
|
||||
if (argv[index] === "--parallel-speedup") args.parallelSpeedup = Number(argv[index + 1]);
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
function main(argv) {
|
||||
const { shardIndex, shardCount } = parseArgs(argv);
|
||||
const { shardIndex, shardCount, parallelSpeedup } = parseArgs(argv);
|
||||
if (!Number.isInteger(shardCount) || shardCount < 1) {
|
||||
throw new Error(`--shard-count must be a positive integer, got ${shardCount}`);
|
||||
}
|
||||
if (!Number.isInteger(shardIndex) || shardIndex < 0 || shardIndex >= shardCount) {
|
||||
throw new Error(`--shard-index must be in [0, ${shardCount}), got ${shardIndex}`);
|
||||
}
|
||||
const envSpeedup = Number.parseFloat(process.env.PAPERCLIP_E2E_PARALLEL_SPEEDUP ?? "");
|
||||
const effectiveSpeedup =
|
||||
Number.isFinite(parallelSpeedup) && parallelSpeedup > 0
|
||||
? parallelSpeedup
|
||||
: Number.isFinite(envSpeedup) && envSpeedup > 0
|
||||
? envSpeedup
|
||||
: resolveEffectiveParallelSpeedup();
|
||||
|
||||
const specs = listE2eSpecs();
|
||||
const durations = loadShardDurations(DURATIONS_MANIFEST);
|
||||
process.stdout.write(`${selectE2eShard(specs, shardIndex, shardCount, durations).join(" ")}\n`);
|
||||
process.stdout.write(
|
||||
`${selectE2eShard(specs, shardIndex, shardCount, durations, { parallelWorkers: effectiveSpeedup }).join(" ")}\n`,
|
||||
);
|
||||
}
|
||||
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
|
||||
@@ -515,7 +515,7 @@ export async function executeFixtureTool(toolName, input = {}, state = createFix
|
||||
if (!options.secrets?.MISSING_FIXTURE_SECRET) return missingSecretResult("MISSING_FIXTURE_SECRET");
|
||||
return { ok: true, result: { value: "configured" } };
|
||||
case "fixture.schemaFlip":
|
||||
state.schemaVariant = "changed";
|
||||
state.schemaVariant = state.schemaVariant === "changed" ? "baseline" : "changed";
|
||||
return { ok: true, result: { schemaVariant: state.schemaVariant, toolName: input.toolName } };
|
||||
default:
|
||||
return { ok: false, error: { code: "unknown_tool", message: `Unknown fixture tool ${toolName}.` } };
|
||||
|
||||
@@ -0,0 +1,248 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import { createLocalAgentJwt } from "../../server/src/agent-auth-jwt";
|
||||
|
||||
import { idle, json, send, setup } from "./agent-chat.shared";
|
||||
|
||||
test.use({ trace: "retain-on-failure" });
|
||||
test.setTimeout(120_000);
|
||||
|
||||
/**
|
||||
* Agent chat session reset and sidebar navigation coverage split out of
|
||||
* agent-chat-sessions.spec.ts so serial E2E shards stay under 75s.
|
||||
*/
|
||||
test("Stop then queued /new resets unpause the conversation without losing history", async ({
|
||||
page,
|
||||
request,
|
||||
}) => {
|
||||
const f = await setup(request);
|
||||
try {
|
||||
await page.goto(f.route);
|
||||
await send(page, { action: "hold" });
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const chat = await json(await request.get(f.chatPath));
|
||||
return (
|
||||
chat &&
|
||||
(
|
||||
await json(await request.get(`/api/issues/${chat.id}/comments`))
|
||||
).some(
|
||||
(c: any) => c.body === "Provider is streaming and ready to stop.",
|
||||
)
|
||||
);
|
||||
}, { timeout: 30_000 })
|
||||
.toBe(true);
|
||||
const issue = await json(await request.get(f.chatPath));
|
||||
const active = (
|
||||
await json(await request.get(`/api/issues/${issue.id}/live-runs`))
|
||||
)[0];
|
||||
await page.getByTestId("task-chat-composer-stop").click();
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
(await json(await request.get(`/api/heartbeat-runs/${active.id}`)))
|
||||
.status,
|
||||
)
|
||||
.toBe("cancelled");
|
||||
const staleToken = createLocalAgentJwt(
|
||||
f.agent.id,
|
||||
f.company.id,
|
||||
"process",
|
||||
active.id,
|
||||
);
|
||||
expect(staleToken).toBeTruthy();
|
||||
const late = await request.post(`/api/issues/${issue.id}/comments`, {
|
||||
headers: { Authorization: `Bearer ${staleToken}` },
|
||||
data: { body: "Forbidden late response" },
|
||||
});
|
||||
expect([403, 409]).toContain(late.status());
|
||||
const mutation = await request.post(
|
||||
`/api/companies/${f.company.id}/projects`,
|
||||
{
|
||||
headers: { Authorization: `Bearer ${staleToken}` },
|
||||
data: { name: "Cancelled project" },
|
||||
},
|
||||
);
|
||||
expect([403, 409]).toContain(mutation.status());
|
||||
expect(
|
||||
await json(await request.get(`/api/companies/${f.company.id}/projects`)),
|
||||
).toHaveLength(0);
|
||||
await send(page, "/new");
|
||||
await send(page, "/new");
|
||||
await send(page, "Fresh followup");
|
||||
await idle(request, f.chatPath, 2);
|
||||
const fresh = await json(await request.get(f.chatPath));
|
||||
expect(fresh.id).toBe(issue.id);
|
||||
expect(fresh.conversationSessionGeneration).toBe(2);
|
||||
await expect(
|
||||
page.getByText("Reply generation 2: Fresh followup", { exact: true }),
|
||||
).toBeVisible();
|
||||
await page.reload();
|
||||
await expect(page.getByText("New session", { exact: true })).toHaveCount(2);
|
||||
await expect(
|
||||
page.getByRole("separator", { name: "Run completed", exact: true }),
|
||||
).toHaveCount(0);
|
||||
const runs = await json(
|
||||
await request.get(`/api/companies/${f.company.id}/heartbeat-runs`),
|
||||
);
|
||||
const detailed = await Promise.all(
|
||||
runs.map((run: any) =>
|
||||
request.get(`/api/heartbeat-runs/${run.id}`).then(json),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
detailed.filter((run) => run.contextSnapshot?.conversationReset),
|
||||
).toHaveLength(2);
|
||||
expect(
|
||||
detailed
|
||||
.filter((run) => run.contextSnapshot?.conversationReset)
|
||||
.every((run) => !run.sessionIdAfter),
|
||||
).toBe(true);
|
||||
} finally {
|
||||
await f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test("Coordinator agent switching preserves drafts and opens one conversation only on send", async ({ page, request }) => {
|
||||
const f = await setup(request, { agentCount: 2 });
|
||||
try {
|
||||
await page.goto(f.route);
|
||||
await expect(page.getByRole("navigation", { name: "Workspace navigation" })).toBeVisible();
|
||||
const editor = page.getByTestId("task-chat-composer-input").locator('[contenteditable="true"]');
|
||||
const contacts = page.getByRole("complementary", { name: "Chat contacts", exact: true });
|
||||
const switchTo = async (name: string) => {
|
||||
const contact = contacts.getByRole("link", { name: new RegExp(`^${name}`) });
|
||||
await contact.click();
|
||||
await expect(contact).toHaveAttribute("aria-current", "page");
|
||||
};
|
||||
await expect(page.getByRole("heading", { name: "Chat", exact: true })).toBeVisible();
|
||||
await expect(contacts.getByRole("button", { name: "Add chat", exact: true })).toHaveCount(0);
|
||||
await editor.fill("Unsent Coordinator draft for Alpha");
|
||||
await switchTo("Beta");
|
||||
await expect(editor).toHaveText("");
|
||||
expect(await json(await request.get(`/api/companies/${f.company.id}/chats/${f.agents[1].id}`))).toBeNull();
|
||||
await switchTo("Alpha");
|
||||
await expect(editor).toContainText("Unsent Coordinator draft for Alpha");
|
||||
await page.reload();
|
||||
await expect(editor).toContainText("Unsent Coordinator draft for Alpha");
|
||||
expect(await json(await request.get(f.chatPath))).toBeNull();
|
||||
await editor.fill("");
|
||||
await send(page, "Coordinator conversation acceptance");
|
||||
await idle(request, f.chatPath);
|
||||
const chat = await json(await request.get(f.chatPath));
|
||||
await switchTo("Beta");
|
||||
await switchTo("Alpha");
|
||||
await expect(page.getByText("Coordinator conversation acceptance", { exact: true })).toBeVisible();
|
||||
expect((await json(await request.get(f.chatPath))).id).toBe(chat.id);
|
||||
expect(await json(await request.get(`/api/companies/${f.company.id}/chats`))).toHaveLength(1);
|
||||
} finally {
|
||||
await f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test("secondary chat navigation preserves layout, unique conversations, history, and drafts", async ({
|
||||
page,
|
||||
request,
|
||||
}) => {
|
||||
const originalExperimental = await json(await request.get("/api/instance/settings/experimental"));
|
||||
const f = await setup(request, { agentCount: 6 });
|
||||
const originalWorkspace = await json(await request.get("/api/workspace-preferences/me"));
|
||||
try {
|
||||
await page.route("**/api/workspace-preferences/me", (route) =>
|
||||
route.fulfill({
|
||||
json: { ...originalWorkspace, coordinatorWorkspaceEnabled: false },
|
||||
}),
|
||||
);
|
||||
await page.route("**/api/instance/settings/experimental", (route) =>
|
||||
route.fulfill({
|
||||
json: { ...originalExperimental, enableStreamlinedUi: true },
|
||||
}),
|
||||
);
|
||||
await page.goto(`/${f.company.issuePrefix}/dashboard`);
|
||||
await page.getByRole("link", { name: /^Chat(?:\s|$)/ }).click();
|
||||
expect(await json(await request.get(`/api/companies/${f.company.id}/primary-agent/me`))).toMatchObject({
|
||||
primaryAgentId: f.agents[0].id, initialized: true,
|
||||
});
|
||||
const sidebar = page.getByRole("complementary", { name: "Chat contacts", exact: true });
|
||||
const nav = sidebar.getByRole("navigation", { name: "Agent conversations" });
|
||||
const alphaLink = nav.getByRole("link", { name: /^Alpha/ });
|
||||
const betaLink = nav.getByRole("link", { name: /^Beta/ });
|
||||
await expect(alphaLink).toHaveAttribute("aria-current", "page");
|
||||
expect(await json(await request.get(f.chatPath))).toBeNull();
|
||||
expect(await json(await request.get(`/api/companies/${f.company.id}/heartbeat-runs`))).toHaveLength(0);
|
||||
await expect(nav.getByRole("link")).toHaveText([/^Alpha/, /^Beta/, /^Delta/, /^Epsilon/, /^Gamma/, /^Zeta/]);
|
||||
const landingBounds = await sidebar.boundingBox();
|
||||
const chatListPath = `/api/companies/${f.company.id}/chats`;
|
||||
const betaPath = `${chatListPath}/${f.agents[1].id}`;
|
||||
await betaLink.click();
|
||||
await expect(betaLink).toHaveAttribute("aria-current", "page");
|
||||
expect(await sidebar.boundingBox()).toEqual(landingBounds);
|
||||
expect(await json(await request.get(betaPath))).toBeNull();
|
||||
expect(await json(await request.get(chatListPath))).toHaveLength(0);
|
||||
expect(await json(await request.get(`/api/companies/${f.company.id}/heartbeat-runs`))).toHaveLength(0);
|
||||
await betaLink.click();
|
||||
expect(await json(await request.get(betaPath))).toBeNull();
|
||||
await send(page, "Beta conversation acceptance");
|
||||
const beta = await idle(request, betaPath);
|
||||
expect(beta.conversationAgentId).toBe(f.agents[1].id);
|
||||
expect(await json(await request.get(chatListPath))).toHaveLength(1);
|
||||
await alphaLink.click();
|
||||
await expect(alphaLink).toHaveAttribute("aria-current", "page");
|
||||
await betaLink.click();
|
||||
await expect(betaLink).toHaveAttribute("aria-current", "page");
|
||||
expect((await json(await request.get(betaPath))).id).toBe(beta.id);
|
||||
expect(await json(await request.get(chatListPath))).toHaveLength(1);
|
||||
await alphaLink.click();
|
||||
await expect(alphaLink).toHaveAttribute("aria-current", "page");
|
||||
await expect(nav.getByRole("link")).toHaveText([/^Alpha/, /^Beta/, /^Delta/, /^Epsilon/, /^Gamma/, /^Zeta/]);
|
||||
const editor = page.getByTestId("task-chat-composer-input").locator('[contenteditable="true"]');
|
||||
await editor.fill("Unsent draft for Alpha");
|
||||
await betaLink.click();
|
||||
await expect(editor).toHaveText("");
|
||||
await alphaLink.click();
|
||||
await expect(editor).toContainText("Unsent draft for Alpha");
|
||||
|
||||
const search = sidebar.getByRole("textbox", { name: "Search chats", exact: true });
|
||||
await search.fill("No matching agent");
|
||||
await expect(sidebar.getByText("No agents found", { exact: true })).toBeVisible();
|
||||
await search.fill("Beta");
|
||||
await expect(nav.getByRole("link")).toHaveCount(1);
|
||||
await expect(betaLink).toBeVisible();
|
||||
await search.press("Escape");
|
||||
await expect(nav.getByRole("link")).toHaveCount(6);
|
||||
await page.reload();
|
||||
await expect(editor).toContainText("Unsent draft for Alpha");
|
||||
await expect(nav.getByRole("link")).toHaveCount(6);
|
||||
|
||||
await page.getByRole("link", { name: /^Chat(?:\s|$)/ }).click();
|
||||
await expect(alphaLink).toHaveAttribute("aria-current", "page");
|
||||
await expect(editor).toContainText("Unsent draft for Alpha");
|
||||
expect(await sidebar.boundingBox()).toEqual(landingBounds);
|
||||
await page.goto(`/${f.company.issuePrefix}/dashboard`);
|
||||
await expect(page).toHaveURL(/\/dashboard$/);
|
||||
await json(await request.post(`/api/issues/${beta.id}/comments`, {
|
||||
data: {
|
||||
body: "Background activity",
|
||||
clientRequestId: "00000000-0000-4000-8000-000000000099",
|
||||
},
|
||||
}));
|
||||
await idle(request, betaPath);
|
||||
await page.getByRole("link", { name: /^Chat(?:\s|$)/ }).click();
|
||||
await expect(alphaLink).toHaveAttribute("aria-current", "page");
|
||||
await betaLink.click();
|
||||
await expect(betaLink).toHaveAttribute("aria-current", "page");
|
||||
await expect(page.getByText("Background activity", { exact: true })).toBeVisible();
|
||||
expect((await json(await request.get(betaPath))).id).toBe(beta.id);
|
||||
expect(await json(await request.get(chatListPath))).toHaveLength(1);
|
||||
await json(await request.post(`/api/agents/${f.agents[1].id}/terminate`));
|
||||
await page.goto(`/${f.company.issuePrefix}/chats`);
|
||||
await expect(betaLink).toContainText("Terminated");
|
||||
await betaLink.click();
|
||||
await expect(page).toHaveURL(new RegExp(`/chats/${f.agents[1].id}$`));
|
||||
await expect(page.getByText("Background activity", { exact: true })).toBeVisible();
|
||||
await page.reload();
|
||||
await expect(page.getByText("Background activity", { exact: true })).toBeVisible();
|
||||
} finally {
|
||||
await f.restore();
|
||||
}
|
||||
});
|
||||
@@ -1,17 +1,16 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import { createLocalAgentJwt } from "../../server/src/agent-auth-jwt";
|
||||
|
||||
import { idle, json, send, setup } from "./agent-chat.shared";
|
||||
|
||||
test.use({ trace: "retain-on-failure" });
|
||||
test.setTimeout(120_000);
|
||||
|
||||
/**
|
||||
* Agent chat session lifecycle coverage: first-open semantics, the feature
|
||||
* flag, Stop + queued /new resets, and sidebar discovery. Shared fixtures
|
||||
* live in ./agent-chat.shared.ts; project, attachment, and history flows run
|
||||
* in agent-chat-projects.spec.ts.
|
||||
* Agent chat session lifecycle coverage: service-worker boot, first-open
|
||||
* semantics, and retired opt-outs. Shared fixtures live in
|
||||
* ./agent-chat.shared.ts; Stop + /new reset and sidebar navigation run in
|
||||
* agent-chat-sessions-navigation.spec.ts; project/history flows run in
|
||||
* agent-chat-projects.spec.ts.
|
||||
*/
|
||||
test("built chat initializes after service worker takeover and reload with a slow CPU", async ({
|
||||
page,
|
||||
@@ -158,241 +157,3 @@ test("retired Chat opt-outs allow sends and resets while preserving existing his
|
||||
await f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test("Stop then queued /new resets unpause the conversation without losing history", async ({
|
||||
page,
|
||||
request,
|
||||
}) => {
|
||||
const f = await setup(request);
|
||||
try {
|
||||
await page.goto(f.route);
|
||||
await send(page, { action: "hold" });
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const chat = await json(await request.get(f.chatPath));
|
||||
return (
|
||||
chat &&
|
||||
(
|
||||
await json(await request.get(`/api/issues/${chat.id}/comments`))
|
||||
).some(
|
||||
(c: any) => c.body === "Provider is streaming and ready to stop.",
|
||||
)
|
||||
);
|
||||
}, { timeout: 30_000 })
|
||||
.toBe(true);
|
||||
const issue = await json(await request.get(f.chatPath));
|
||||
const active = (
|
||||
await json(await request.get(`/api/issues/${issue.id}/live-runs`))
|
||||
)[0];
|
||||
await page.getByTestId("task-chat-composer-stop").click();
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
(await json(await request.get(`/api/heartbeat-runs/${active.id}`)))
|
||||
.status,
|
||||
)
|
||||
.toBe("cancelled");
|
||||
const staleToken = createLocalAgentJwt(
|
||||
f.agent.id,
|
||||
f.company.id,
|
||||
"process",
|
||||
active.id,
|
||||
);
|
||||
expect(staleToken).toBeTruthy();
|
||||
const late = await request.post(`/api/issues/${issue.id}/comments`, {
|
||||
headers: { Authorization: `Bearer ${staleToken}` },
|
||||
data: { body: "Forbidden late response" },
|
||||
});
|
||||
expect([403, 409]).toContain(late.status());
|
||||
const mutation = await request.post(
|
||||
`/api/companies/${f.company.id}/projects`,
|
||||
{
|
||||
headers: { Authorization: `Bearer ${staleToken}` },
|
||||
data: { name: "Cancelled project" },
|
||||
},
|
||||
);
|
||||
expect([403, 409]).toContain(mutation.status());
|
||||
expect(
|
||||
await json(await request.get(`/api/companies/${f.company.id}/projects`)),
|
||||
).toHaveLength(0);
|
||||
await send(page, "/new");
|
||||
await send(page, "/new");
|
||||
await send(page, "Fresh followup");
|
||||
await idle(request, f.chatPath, 2);
|
||||
const fresh = await json(await request.get(f.chatPath));
|
||||
expect(fresh.id).toBe(issue.id);
|
||||
expect(fresh.conversationSessionGeneration).toBe(2);
|
||||
await expect(
|
||||
page.getByText("Reply generation 2: Fresh followup", { exact: true }),
|
||||
).toBeVisible();
|
||||
await page.reload();
|
||||
await expect(page.getByText("New session", { exact: true })).toHaveCount(2);
|
||||
await expect(
|
||||
page.getByRole("separator", { name: "Run completed", exact: true }),
|
||||
).toHaveCount(0);
|
||||
const runs = await json(
|
||||
await request.get(`/api/companies/${f.company.id}/heartbeat-runs`),
|
||||
);
|
||||
const detailed = await Promise.all(
|
||||
runs.map((run: any) =>
|
||||
request.get(`/api/heartbeat-runs/${run.id}`).then(json),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
detailed.filter((run) => run.contextSnapshot?.conversationReset),
|
||||
).toHaveLength(2);
|
||||
expect(
|
||||
detailed
|
||||
.filter((run) => run.contextSnapshot?.conversationReset)
|
||||
.every((run) => !run.sessionIdAfter),
|
||||
).toBe(true);
|
||||
} finally {
|
||||
await f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test("Coordinator agent switching preserves drafts and opens one conversation only on send", async ({ page, request }) => {
|
||||
const f = await setup(request, { agentCount: 2 });
|
||||
try {
|
||||
await page.goto(f.route);
|
||||
await expect(page.getByRole("navigation", { name: "Workspace navigation" })).toBeVisible();
|
||||
const editor = page.getByTestId("task-chat-composer-input").locator('[contenteditable="true"]');
|
||||
const contacts = page.getByRole("complementary", { name: "Chat contacts", exact: true });
|
||||
const switchTo = async (name: string) => {
|
||||
const contact = contacts.getByRole("link", { name: new RegExp(`^${name}`) });
|
||||
await contact.click();
|
||||
await expect(contact).toHaveAttribute("aria-current", "page");
|
||||
};
|
||||
await expect(page.getByRole("heading", { name: "Chat", exact: true })).toBeVisible();
|
||||
await expect(contacts.getByRole("button", { name: "Add chat", exact: true })).toHaveCount(0);
|
||||
await editor.fill("Unsent Coordinator draft for Alpha");
|
||||
await switchTo("Beta");
|
||||
await expect(editor).toHaveText("");
|
||||
expect(await json(await request.get(`/api/companies/${f.company.id}/chats/${f.agents[1].id}`))).toBeNull();
|
||||
await switchTo("Alpha");
|
||||
await expect(editor).toContainText("Unsent Coordinator draft for Alpha");
|
||||
await page.reload();
|
||||
await expect(editor).toContainText("Unsent Coordinator draft for Alpha");
|
||||
expect(await json(await request.get(f.chatPath))).toBeNull();
|
||||
await editor.fill("");
|
||||
await send(page, "Coordinator conversation acceptance");
|
||||
await idle(request, f.chatPath);
|
||||
const chat = await json(await request.get(f.chatPath));
|
||||
await switchTo("Beta");
|
||||
await switchTo("Alpha");
|
||||
await expect(page.getByText("Coordinator conversation acceptance", { exact: true })).toBeVisible();
|
||||
expect((await json(await request.get(f.chatPath))).id).toBe(chat.id);
|
||||
expect(await json(await request.get(`/api/companies/${f.company.id}/chats`))).toHaveLength(1);
|
||||
} finally {
|
||||
await f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test("secondary chat navigation preserves layout, unique conversations, history, and drafts", async ({
|
||||
page,
|
||||
request,
|
||||
}) => {
|
||||
const originalExperimental = await json(await request.get("/api/instance/settings/experimental"));
|
||||
const f = await setup(request, { agentCount: 6 });
|
||||
const originalWorkspace = await json(await request.get("/api/workspace-preferences/me"));
|
||||
try {
|
||||
await page.route("**/api/workspace-preferences/me", (route) =>
|
||||
route.fulfill({
|
||||
json: { ...originalWorkspace, coordinatorWorkspaceEnabled: false },
|
||||
}),
|
||||
);
|
||||
await page.route("**/api/instance/settings/experimental", (route) =>
|
||||
route.fulfill({
|
||||
json: { ...originalExperimental, enableStreamlinedUi: true },
|
||||
}),
|
||||
);
|
||||
await page.goto(`/${f.company.issuePrefix}/dashboard`);
|
||||
await page.getByRole("link", { name: /^Chat(?:\s|$)/ }).click();
|
||||
// With no recent conversation, Chat opens the first human-created primary.
|
||||
// Navigation alone must not create a conversation or start execution.
|
||||
expect(await json(await request.get(`/api/companies/${f.company.id}/primary-agent/me`))).toMatchObject({
|
||||
primaryAgentId: f.agents[0].id, initialized: true,
|
||||
});
|
||||
const sidebar = page.getByRole("complementary", { name: "Chat contacts", exact: true });
|
||||
const nav = sidebar.getByRole("navigation", { name: "Agent conversations" });
|
||||
const alphaLink = nav.getByRole("link", { name: /^Alpha/ });
|
||||
const betaLink = nav.getByRole("link", { name: /^Beta/ });
|
||||
await expect(alphaLink).toHaveAttribute("aria-current", "page");
|
||||
expect(await json(await request.get(f.chatPath))).toBeNull();
|
||||
expect(await json(await request.get(`/api/companies/${f.company.id}/heartbeat-runs`))).toHaveLength(0);
|
||||
await expect(nav.getByRole("link")).toHaveText([/^Alpha/, /^Beta/, /^Delta/, /^Epsilon/, /^Gamma/, /^Zeta/]);
|
||||
const landingBounds = await sidebar.boundingBox();
|
||||
const chatListPath = `/api/companies/${f.company.id}/chats`;
|
||||
const betaPath = `${chatListPath}/${f.agents[1].id}`;
|
||||
await betaLink.click();
|
||||
await expect(betaLink).toHaveAttribute("aria-current", "page");
|
||||
expect(await sidebar.boundingBox()).toEqual(landingBounds);
|
||||
expect(await json(await request.get(betaPath))).toBeNull();
|
||||
expect(await json(await request.get(chatListPath))).toHaveLength(0);
|
||||
expect(await json(await request.get(`/api/companies/${f.company.id}/heartbeat-runs`))).toHaveLength(0);
|
||||
await betaLink.click();
|
||||
expect(await json(await request.get(betaPath))).toBeNull();
|
||||
await send(page, "Beta conversation acceptance");
|
||||
const beta = await idle(request, betaPath);
|
||||
expect(beta.conversationAgentId).toBe(f.agents[1].id);
|
||||
expect(await json(await request.get(chatListPath))).toHaveLength(1);
|
||||
await alphaLink.click();
|
||||
await expect(alphaLink).toHaveAttribute("aria-current", "page");
|
||||
await betaLink.click();
|
||||
await expect(betaLink).toHaveAttribute("aria-current", "page");
|
||||
expect((await json(await request.get(betaPath))).id).toBe(beta.id);
|
||||
expect(await json(await request.get(chatListPath))).toHaveLength(1);
|
||||
await alphaLink.click();
|
||||
await expect(alphaLink).toHaveAttribute("aria-current", "page");
|
||||
await expect(nav.getByRole("link")).toHaveText([/^Alpha/, /^Beta/, /^Delta/, /^Epsilon/, /^Gamma/, /^Zeta/]);
|
||||
const editor = page.getByTestId("task-chat-composer-input").locator('[contenteditable="true"]');
|
||||
await editor.fill("Unsent draft for Alpha");
|
||||
await betaLink.click();
|
||||
await expect(editor).toHaveText("");
|
||||
await alphaLink.click();
|
||||
await expect(editor).toContainText("Unsent draft for Alpha");
|
||||
|
||||
const search = sidebar.getByRole("textbox", { name: "Search chats", exact: true });
|
||||
await search.fill("No matching agent");
|
||||
await expect(sidebar.getByText("No agents found", { exact: true })).toBeVisible();
|
||||
await search.fill("Beta");
|
||||
await expect(nav.getByRole("link")).toHaveCount(1);
|
||||
await expect(betaLink).toBeVisible();
|
||||
await search.press("Escape");
|
||||
await expect(nav.getByRole("link")).toHaveCount(6);
|
||||
await page.reload();
|
||||
await expect(editor).toContainText("Unsent draft for Alpha");
|
||||
await expect(nav.getByRole("link")).toHaveCount(6);
|
||||
|
||||
await page.getByRole("link", { name: /^Chat(?:\s|$)/ }).click();
|
||||
await expect(alphaLink).toHaveAttribute("aria-current", "page");
|
||||
await expect(editor).toContainText("Unsent draft for Alpha");
|
||||
expect(await sidebar.boundingBox()).toEqual(landingBounds);
|
||||
await page.goto(`/${f.company.issuePrefix}/dashboard`);
|
||||
await expect(page).toHaveURL(/\/dashboard$/);
|
||||
await json(await request.post(`/api/issues/${beta.id}/comments`, {
|
||||
data: {
|
||||
body: "Background activity",
|
||||
clientRequestId: "00000000-0000-4000-8000-000000000099",
|
||||
},
|
||||
}));
|
||||
await idle(request, betaPath);
|
||||
await page.getByRole("link", { name: /^Chat(?:\s|$)/ }).click();
|
||||
await expect(alphaLink).toHaveAttribute("aria-current", "page");
|
||||
await betaLink.click();
|
||||
await expect(betaLink).toHaveAttribute("aria-current", "page");
|
||||
await expect(page.getByText("Background activity", { exact: true })).toBeVisible();
|
||||
expect((await json(await request.get(betaPath))).id).toBe(beta.id);
|
||||
expect(await json(await request.get(chatListPath))).toHaveLength(1);
|
||||
await json(await request.post(`/api/agents/${f.agents[1].id}/terminate`));
|
||||
await page.goto(`/${f.company.issuePrefix}/chats`);
|
||||
await expect(betaLink).toContainText("Terminated");
|
||||
await betaLink.click();
|
||||
await expect(page).toHaveURL(new RegExp(`/chats/${f.agents[1].id}$`));
|
||||
await expect(page.getByText("Background activity", { exact: true })).toBeVisible();
|
||||
await page.reload();
|
||||
await expect(page.getByText("Background activity", { exact: true })).toBeVisible();
|
||||
} finally {
|
||||
await f.restore();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,112 @@
|
||||
import { mkdtemp, readFile, writeFile } from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { stringify } from "yaml";
|
||||
import { document, edit, expect, json, save, setup, test } from "./agent-configuration.shared";
|
||||
|
||||
test("stale drafts and invalid commands leave saved configuration unchanged", async ({ page, request }) => {
|
||||
const { agent, url } = await setup(request);
|
||||
await page.goto(`${url}/advanced`);
|
||||
await edit(page, value => { value.spec.title = "Local draft"; });
|
||||
await json(await request.patch(`/api/agents/${agent.id}`, { data: { title: "Other operator" } }));
|
||||
await page.getByRole("button", { name: "Save changes", exact: true }).click();
|
||||
await expect(page.getByRole("alert")).toContainText("changed while you were editing");
|
||||
expect((await document(page)).spec.title).toBe("Local draft");
|
||||
expect((await json(await request.get(`/api/agents/${agent.id}/configuration`))).title).toBe("Other operator");
|
||||
await page.getByRole("button", { name: "Reload saved", exact: true }).click();
|
||||
await expect.poll(async () => (await document(page)).spec.title).toBe("Other operator");
|
||||
await edit(page, value => { value.observed = {}; });
|
||||
await expect(page.getByRole("alert")).toContainText("observed is read-only");
|
||||
await expect(page.getByRole("button", { name: "Save changes", exact: true })).toBeDisabled();
|
||||
});
|
||||
|
||||
test("renaming an agent keeps newly created key tokens visible through the route change", async ({ page, request }) => {
|
||||
const { agent, url } = await setup(request);
|
||||
await page.goto(`${url}/advanced`);
|
||||
await edit(page, value => {
|
||||
value.spec.name = "Renamed YAML engineer";
|
||||
value.spec.apiKeys = { create: [{ name: "Rename key", scope: { kind: "standard" } }] };
|
||||
});
|
||||
await save(page);
|
||||
await expect(page).toHaveURL(/\/agents\/renamed-yaml-engineer\/advanced$/);
|
||||
const token = page.getByRole("textbox", { name: "API key: Rename key token" });
|
||||
await expect(token).toBeVisible();
|
||||
const created = await token.inputValue();
|
||||
expect(created).toMatch(/^pcp_/);
|
||||
expect(stringify(await document(page))).not.toContain(created);
|
||||
expect(await json(await request.get(`/api/agents/${agent.id}/keys`))).toHaveLength(1);
|
||||
await edit(page, value => { value.spec.title = "Another saved edit"; });
|
||||
await save(page);
|
||||
await expect(token).toHaveValue(created);
|
||||
});
|
||||
|
||||
test("a lost creation response requires reload and cannot blindly replay commands", async ({ page, request }) => {
|
||||
const { agent, url } = await setup(request);
|
||||
let creates = 0;
|
||||
await page.route(`**/api/agents/${agent.id}/keys?*`, async route => {
|
||||
if (route.request().method() !== "POST") return route.continue();
|
||||
creates++;
|
||||
if (creates === 1) return route.continue();
|
||||
await route.fetch();
|
||||
return route.abort("failed");
|
||||
});
|
||||
await page.goto(`${url}/advanced`);
|
||||
await edit(page, value => {
|
||||
value.spec.name = "Partially renamed YAML engineer";
|
||||
value.spec.title = "Saved before lost response";
|
||||
value.spec.apiKeys = { create: ["First key", "Second key"].map(name => ({ name, scope: { kind: "standard" } })) };
|
||||
});
|
||||
await page.getByRole("button", { name: "Save changes", exact: true }).click();
|
||||
await expect(page.getByRole("alert")).toContainText("Reload saved before saving again");
|
||||
await expect(page.getByRole("textbox", { name: "API key: First key token" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Save changes", exact: true })).toBeDisabled();
|
||||
expect((await json(await request.get(`/api/agents/${agent.id}/configuration`))).title).toBe("Saved before lost response");
|
||||
expect(await json(await request.get(`/api/agents/${agent.id}/keys`))).toHaveLength(2);
|
||||
await page.evaluate(() => window.document.addEventListener("copy", event => {
|
||||
event.clipboardData?.setData("text/plain", "Skip to Main Content\napiVersion: paperclip/v1\nCopied surrounding page text");
|
||||
event.preventDefault();
|
||||
}, { capture: true, once: true }));
|
||||
expect((await document(page)).spec.apiKeys!.create).toHaveLength(2);
|
||||
await page.getByRole("button", { name: "Reload saved", exact: true }).click();
|
||||
await expect(page).toHaveURL(/\/agents\/partially-renamed-yaml-engineer\/advanced$/);
|
||||
await expect(page.getByRole("button", { name: "Reload saved", exact: true })).toBeEnabled();
|
||||
expect((await document(page)).spec.apiKeys).toBeUndefined();
|
||||
await expect(page.getByRole("textbox", { name: "API key: First key token" })).toBeVisible();
|
||||
await edit(page, value => { value.spec.title = "Recovered save"; });
|
||||
await save(page);
|
||||
expect(creates).toBe(2);
|
||||
expect(await json(await request.get(`/api/agents/${agent.id}/keys`))).toHaveLength(2);
|
||||
});
|
||||
|
||||
test("switching instructions location loads existing destination files without overwriting them", async ({ page, request }) => {
|
||||
const { agent, url } = await setup(request);
|
||||
await json(await request.patch(`/api/agents/${agent.id}/instructions-bundle`, { data: { mode: "managed" } }));
|
||||
const destination = await mkdtemp(path.join(os.tmpdir(), "agent-yaml-instructions-"));
|
||||
await writeFile(path.join(destination, "AGENTS.md"), "Keep destination instructions.\n");
|
||||
await page.goto(`${url}/advanced`);
|
||||
await edit(page, value => { value.spec.instructions!.mode = "external"; value.spec.instructions!.rootPath = destination; });
|
||||
await save(page);
|
||||
expect((await document(page)).spec.instructions).not.toHaveProperty("files");
|
||||
expect(await readFile(path.join(destination, "AGENTS.md"), "utf8")).toBe("Keep destination instructions.\n");
|
||||
});
|
||||
|
||||
test("revision restore is an explicit separate save and reloads the restored configuration", async ({ page, request }) => {
|
||||
const { agent, url } = await setup(request);
|
||||
await page.goto(`${url}/advanced`);
|
||||
await edit(page, value => { value.spec.title = "Before restore"; });
|
||||
await save(page);
|
||||
const revisions = await json(await request.get(`/api/agents/${agent.id}/config-revisions`));
|
||||
const revision = revisions.find((row: { changedKeys: string[] }) => row.changedKeys.includes("title"));
|
||||
expect(revision).toBeTruthy();
|
||||
await edit(page, value => { value.spec.title = "After restore target"; });
|
||||
await save(page);
|
||||
await edit(page, value => { value.spec.revisions = { restore: revision.id }; value.spec.title = "Conflicting edit"; });
|
||||
await expect(page.getByRole("alert")).toContainText("Restore a revision in its own save");
|
||||
await expect(page.getByRole("button", { name: "Save changes", exact: true })).toBeDisabled();
|
||||
await edit(page, value => { value.spec.title = "After restore target"; });
|
||||
await save(page);
|
||||
await page.reload();
|
||||
const restored = await document(page);
|
||||
expect(restored.spec.title).toBe("Before restore");
|
||||
expect(restored.spec.revisions).toBeUndefined();
|
||||
});
|
||||
@@ -0,0 +1,83 @@
|
||||
import { expect, test as base, type APIRequestContext, type APIResponse, type Page } from "@playwright/test";
|
||||
import { parse, stringify } from "yaml";
|
||||
import type { AgentConfigurationInput } from "@paperclipai/shared";
|
||||
import { startReviewProvider } from "../fixtures/connection-review-provider";
|
||||
|
||||
export { expect };
|
||||
|
||||
export const test = base.extend<{ toolProvider: Awaited<ReturnType<typeof startReviewProvider>>; settings: void }>({
|
||||
settings: [async ({ request }, use) => {
|
||||
const previous = await json(await request.get("/api/instance/settings/experimental"));
|
||||
try {
|
||||
await json(await request.patch("/api/instance/settings/experimental", { data: { enableBetaSkills: true, enableChatConnectors: true } }));
|
||||
await use();
|
||||
} finally {
|
||||
await json(await request.patch("/api/instance/settings/experimental", { data: {
|
||||
enableBetaSkills: previous.enableBetaSkills, enableChatConnectors: previous.enableChatConnectors,
|
||||
} }));
|
||||
}
|
||||
}, { auto: true }],
|
||||
toolProvider: async ({}, use) => {
|
||||
const provider = await startReviewProvider();
|
||||
try { await use(provider); }
|
||||
finally { await provider.close(); }
|
||||
},
|
||||
});
|
||||
|
||||
export async function json(response: APIResponse) {
|
||||
expect(response.ok(), `${response.status()}: ${await response.text()}`).toBe(true);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function setup(request: APIRequestContext) {
|
||||
const company = await json(await request.post("/api/companies", { data: { name: `Agent YAML ${Date.now()}` } }));
|
||||
const agent = await json(await request.post(`/api/companies/${company.id}/agents`, { data: {
|
||||
name: "YAML engineer", role: "engineer", adapterType: "process", adapterConfig: { command: "true", removable: "old value" },
|
||||
runtimeConfig: { heartbeat: { enabled: false, wakeOnDemand: false } },
|
||||
} }));
|
||||
return { company, agent, url: `/${company.issuePrefix}/agents/${agent.urlKey}` };
|
||||
}
|
||||
|
||||
export const editor = (page: Page) => page.getByRole("textbox", { name: "Agent YAML configuration" });
|
||||
|
||||
export async function document(page: Page): Promise<AgentConfigurationInput> {
|
||||
await expect(editor(page)).toBeVisible();
|
||||
await expect(editor(page)).toHaveAttribute("contenteditable", "true");
|
||||
let source = "";
|
||||
// Keep the selection inside the editor across configuration rerenders.
|
||||
// Never parse a whole-page selection or a prior clipboard value as YAML.
|
||||
await expect.poll(async () => {
|
||||
await editor(page).click();
|
||||
await editor(page).press("ControlOrMeta+a");
|
||||
const selectedEditor = await editor(page).evaluate(element => {
|
||||
const selection = window.getSelection();
|
||||
return window.document.activeElement === element && !!selection?.anchorNode && !!selection.focusNode
|
||||
&& element.contains(selection.anchorNode) && element.contains(selection.focusNode);
|
||||
});
|
||||
if (!selectedEditor) return false;
|
||||
// Capture the editor's copy event without sharing the OS clipboard with
|
||||
// other browser tests or the person using this computer.
|
||||
source = await editor(page).evaluate(element => {
|
||||
const clipboardData = new DataTransfer();
|
||||
element.dispatchEvent(new ClipboardEvent("copy", { clipboardData, bubbles: true, cancelable: true }));
|
||||
return clipboardData.getData("text/plain");
|
||||
});
|
||||
return /^apiVersion: paperclip\/v1(?:\r?\n|$)/.test(source);
|
||||
}, { message: "Copy the current YAML from the focused editor" }).toBe(true);
|
||||
return parse(source);
|
||||
}
|
||||
|
||||
export async function edit(page: Page, change: (value: AgentConfigurationInput) => void) {
|
||||
const value = await document(page);
|
||||
change(value);
|
||||
await editor(page).press("ControlOrMeta+a");
|
||||
await page.keyboard.insertText(stringify(value, { lineWidth: 0 }));
|
||||
}
|
||||
|
||||
export async function save(page: Page) {
|
||||
await page.getByRole("button", { name: "Save changes", exact: true }).click();
|
||||
await expect(page.getByText("Unsaved changes", { exact: true })).toHaveCount(0);
|
||||
await expect(page.getByRole("button", { name: "Save changes", exact: true })).toBeDisabled({ timeout: 30_000 });
|
||||
await expect(page.getByRole("button", { name: "Reload saved", exact: true })).toBeEnabled();
|
||||
await expect(page.getByRole("alert")).toHaveCount(0);
|
||||
}
|
||||
@@ -1,84 +1,5 @@
|
||||
import { mkdtemp, readFile, writeFile } from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { expect, test as base, type APIRequestContext, type APIResponse, type Page } from "@playwright/test";
|
||||
import { parse, stringify } from "yaml";
|
||||
import type { AgentConfigurationInput } from "@paperclipai/shared";
|
||||
import { startReviewProvider } from "../fixtures/connection-review-provider";
|
||||
|
||||
const test = base.extend<{ toolProvider: Awaited<ReturnType<typeof startReviewProvider>>; settings: void }>({
|
||||
settings: [async ({ request }, use) => {
|
||||
const previous = await json(await request.get("/api/instance/settings/experimental"));
|
||||
try {
|
||||
await json(await request.patch("/api/instance/settings/experimental", { data: { enableBetaSkills: true, enableChatConnectors: true } }));
|
||||
await use();
|
||||
} finally {
|
||||
await json(await request.patch("/api/instance/settings/experimental", { data: {
|
||||
enableBetaSkills: previous.enableBetaSkills, enableChatConnectors: previous.enableChatConnectors,
|
||||
} }));
|
||||
}
|
||||
}, { auto: true }],
|
||||
toolProvider: async ({}, use) => {
|
||||
const provider = await startReviewProvider();
|
||||
try { await use(provider); }
|
||||
finally { await provider.close(); }
|
||||
},
|
||||
});
|
||||
|
||||
async function json(response: APIResponse) {
|
||||
expect(response.ok(), `${response.status()}: ${await response.text()}`).toBe(true);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function setup(request: APIRequestContext) {
|
||||
const company = await json(await request.post("/api/companies", { data: { name: `Agent YAML ${Date.now()}` } }));
|
||||
const agent = await json(await request.post(`/api/companies/${company.id}/agents`, { data: {
|
||||
name: "YAML engineer", role: "engineer", adapterType: "process", adapterConfig: { command: "true", removable: "old value" },
|
||||
runtimeConfig: { heartbeat: { enabled: false, wakeOnDemand: false } },
|
||||
} }));
|
||||
return { company, agent, url: `/${company.issuePrefix}/agents/${agent.urlKey}` };
|
||||
}
|
||||
|
||||
const editor = (page: Page) => page.getByRole("textbox", { name: "Agent YAML configuration" });
|
||||
async function document(page: Page): Promise<AgentConfigurationInput> {
|
||||
await expect(editor(page)).toBeVisible();
|
||||
await expect(editor(page)).toHaveAttribute("contenteditable", "true");
|
||||
let source = "";
|
||||
// Keep the selection inside the editor across configuration rerenders.
|
||||
// Never parse a whole-page selection or a prior clipboard value as YAML.
|
||||
await expect.poll(async () => {
|
||||
await editor(page).click();
|
||||
await editor(page).press("ControlOrMeta+a");
|
||||
const selectedEditor = await editor(page).evaluate(element => {
|
||||
const selection = window.getSelection();
|
||||
return window.document.activeElement === element && !!selection?.anchorNode && !!selection.focusNode
|
||||
&& element.contains(selection.anchorNode) && element.contains(selection.focusNode);
|
||||
});
|
||||
if (!selectedEditor) return false;
|
||||
// Capture the editor's copy event without sharing the OS clipboard with
|
||||
// other browser tests or the person using this computer.
|
||||
source = await editor(page).evaluate(element => {
|
||||
const clipboardData = new DataTransfer();
|
||||
element.dispatchEvent(new ClipboardEvent("copy", { clipboardData, bubbles: true, cancelable: true }));
|
||||
return clipboardData.getData("text/plain");
|
||||
});
|
||||
return /^apiVersion: paperclip\/v1(?:\r?\n|$)/.test(source);
|
||||
}, { message: "Copy the current YAML from the focused editor" }).toBe(true);
|
||||
return parse(source);
|
||||
}
|
||||
async function edit(page: Page, change: (value: AgentConfigurationInput) => void) {
|
||||
const value = await document(page);
|
||||
change(value);
|
||||
await editor(page).press("ControlOrMeta+a");
|
||||
await page.keyboard.insertText(stringify(value, { lineWidth: 0 }));
|
||||
}
|
||||
async function save(page: Page) {
|
||||
await page.getByRole("button", { name: "Save changes", exact: true }).click();
|
||||
await expect(page.getByText("Unsaved changes", { exact: true })).toHaveCount(0);
|
||||
await expect(page.getByRole("button", { name: "Save changes", exact: true })).toBeDisabled({ timeout: 30_000 });
|
||||
await expect(page.getByRole("button", { name: "Reload saved", exact: true })).toBeEnabled();
|
||||
await expect(page.getByRole("alert")).toHaveCount(0);
|
||||
}
|
||||
import { stringify } from "yaml";
|
||||
import { document, edit, expect, json, save, setup, test } from "./agent-configuration.shared";
|
||||
|
||||
test("Secrets shows masked inline variables and preserves them when another variable is saved", async ({ page, request }) => {
|
||||
const { company, agent, url } = await setup(request);
|
||||
@@ -243,113 +164,3 @@ test("Advanced YAML persists settings and commands through their real resource A
|
||||
expect((await json(await request.get(`/api/agents/${agent.id}/keys`))).find((row: { id: string }) => row.id === key.id).revokedAt).not.toBeNull();
|
||||
await page.screenshot({ path: info.outputPath("saved-agent-yaml.png") });
|
||||
});
|
||||
|
||||
test("stale drafts and invalid commands leave saved configuration unchanged", async ({ page, request }) => {
|
||||
const { agent, url } = await setup(request);
|
||||
await page.goto(`${url}/advanced`);
|
||||
await edit(page, value => { value.spec.title = "Local draft"; });
|
||||
await json(await request.patch(`/api/agents/${agent.id}`, { data: { title: "Other operator" } }));
|
||||
await page.getByRole("button", { name: "Save changes", exact: true }).click();
|
||||
await expect(page.getByRole("alert")).toContainText("changed while you were editing");
|
||||
expect((await document(page)).spec.title).toBe("Local draft");
|
||||
expect((await json(await request.get(`/api/agents/${agent.id}/configuration`))).title).toBe("Other operator");
|
||||
await page.getByRole("button", { name: "Reload saved", exact: true }).click();
|
||||
await expect.poll(async () => (await document(page)).spec.title).toBe("Other operator");
|
||||
await edit(page, value => { value.observed = {}; });
|
||||
await expect(page.getByRole("alert")).toContainText("observed is read-only");
|
||||
await expect(page.getByRole("button", { name: "Save changes", exact: true })).toBeDisabled();
|
||||
});
|
||||
|
||||
test("renaming an agent keeps newly created key tokens visible through the route change", async ({ page, request }) => {
|
||||
const { agent, url } = await setup(request);
|
||||
await page.goto(`${url}/advanced`);
|
||||
await edit(page, value => {
|
||||
value.spec.name = "Renamed YAML engineer";
|
||||
value.spec.apiKeys = { create: [{ name: "Rename key", scope: { kind: "standard" } }] };
|
||||
});
|
||||
await save(page);
|
||||
await expect(page).toHaveURL(/\/agents\/renamed-yaml-engineer\/advanced$/);
|
||||
const token = page.getByRole("textbox", { name: "API key: Rename key token" });
|
||||
await expect(token).toBeVisible();
|
||||
const created = await token.inputValue();
|
||||
expect(created).toMatch(/^pcp_/);
|
||||
expect(stringify(await document(page))).not.toContain(created);
|
||||
expect(await json(await request.get(`/api/agents/${agent.id}/keys`))).toHaveLength(1);
|
||||
await edit(page, value => { value.spec.title = "Another saved edit"; });
|
||||
await save(page);
|
||||
await expect(token).toHaveValue(created);
|
||||
});
|
||||
|
||||
test("a lost creation response requires reload and cannot blindly replay commands", async ({ page, request }) => {
|
||||
const { agent, url } = await setup(request);
|
||||
let creates = 0;
|
||||
await page.route(`**/api/agents/${agent.id}/keys?*`, async route => {
|
||||
if (route.request().method() !== "POST") return route.continue();
|
||||
creates++;
|
||||
if (creates === 1) return route.continue();
|
||||
await route.fetch();
|
||||
return route.abort("failed");
|
||||
});
|
||||
await page.goto(`${url}/advanced`);
|
||||
await edit(page, value => {
|
||||
value.spec.name = "Partially renamed YAML engineer";
|
||||
value.spec.title = "Saved before lost response";
|
||||
value.spec.apiKeys = { create: ["First key", "Second key"].map(name => ({ name, scope: { kind: "standard" } })) };
|
||||
});
|
||||
await page.getByRole("button", { name: "Save changes", exact: true }).click();
|
||||
await expect(page.getByRole("alert")).toContainText("Reload saved before saving again");
|
||||
await expect(page.getByRole("textbox", { name: "API key: First key token" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Save changes", exact: true })).toBeDisabled();
|
||||
expect((await json(await request.get(`/api/agents/${agent.id}/configuration`))).title).toBe("Saved before lost response");
|
||||
expect(await json(await request.get(`/api/agents/${agent.id}/keys`))).toHaveLength(2);
|
||||
// Reproduce the observed CI failure once: a copy contains surrounding page
|
||||
// text as well as the YAML header. The read helper must reacquire a clean
|
||||
// editor copy instead of accepting the header and parsing the whole page.
|
||||
await page.evaluate(() => window.document.addEventListener("copy", event => {
|
||||
event.clipboardData?.setData("text/plain", "Skip to Main Content\napiVersion: paperclip/v1\nCopied surrounding page text");
|
||||
event.preventDefault();
|
||||
}, { capture: true, once: true }));
|
||||
expect((await document(page)).spec.apiKeys!.create).toHaveLength(2);
|
||||
await page.getByRole("button", { name: "Reload saved", exact: true }).click();
|
||||
await expect(page).toHaveURL(/\/agents\/partially-renamed-yaml-engineer\/advanced$/);
|
||||
await expect(page.getByRole("button", { name: "Reload saved", exact: true })).toBeEnabled();
|
||||
expect((await document(page)).spec.apiKeys).toBeUndefined();
|
||||
await expect(page.getByRole("textbox", { name: "API key: First key token" })).toBeVisible();
|
||||
await edit(page, value => { value.spec.title = "Recovered save"; });
|
||||
await save(page);
|
||||
expect(creates).toBe(2);
|
||||
expect(await json(await request.get(`/api/agents/${agent.id}/keys`))).toHaveLength(2);
|
||||
});
|
||||
|
||||
test("switching instructions location loads existing destination files without overwriting them", async ({ page, request }) => {
|
||||
const { agent, url } = await setup(request);
|
||||
await json(await request.patch(`/api/agents/${agent.id}/instructions-bundle`, { data: { mode: "managed" } }));
|
||||
const destination = await mkdtemp(path.join(os.tmpdir(), "agent-yaml-instructions-"));
|
||||
await writeFile(path.join(destination, "AGENTS.md"), "Keep destination instructions.\n");
|
||||
await page.goto(`${url}/advanced`);
|
||||
await edit(page, value => { value.spec.instructions!.mode = "external"; value.spec.instructions!.rootPath = destination; });
|
||||
await save(page);
|
||||
expect((await document(page)).spec.instructions).not.toHaveProperty("files");
|
||||
expect(await readFile(path.join(destination, "AGENTS.md"), "utf8")).toBe("Keep destination instructions.\n");
|
||||
});
|
||||
|
||||
test("revision restore is an explicit separate save and reloads the restored configuration", async ({ page, request }) => {
|
||||
const { agent, url } = await setup(request);
|
||||
await page.goto(`${url}/advanced`);
|
||||
await edit(page, value => { value.spec.title = "Before restore"; });
|
||||
await save(page);
|
||||
const revisions = await json(await request.get(`/api/agents/${agent.id}/config-revisions`));
|
||||
const revision = revisions.find((row: { changedKeys: string[] }) => row.changedKeys.includes("title"));
|
||||
expect(revision).toBeTruthy();
|
||||
await edit(page, value => { value.spec.title = "After restore target"; });
|
||||
await save(page);
|
||||
await edit(page, value => { value.spec.revisions = { restore: revision.id }; value.spec.title = "Conflicting edit"; });
|
||||
await expect(page.getByRole("alert")).toContainText("Restore a revision in its own save");
|
||||
await expect(page.getByRole("button", { name: "Save changes", exact: true })).toBeDisabled();
|
||||
await edit(page, value => { value.spec.title = "After restore target"; });
|
||||
await save(page);
|
||||
await page.reload();
|
||||
const restored = await document(page);
|
||||
expect(restored.spec.title).toBe("Before restore");
|
||||
expect(restored.spec.revisions).toBeUndefined();
|
||||
});
|
||||
@@ -0,0 +1,364 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { mockOnboardingLocalAiConnection } from "./helpers/onboarding-ai-connection";
|
||||
|
||||
/**
|
||||
* E2E: Onboarding wizard reload resume, probe-failure gating, and duplicate
|
||||
* draft handling split out of onboarding.spec.ts so serial E2E shards stay
|
||||
* under 75s.
|
||||
*/
|
||||
|
||||
const COMPANY_NAME = `E2E-Test-${Date.now()}`;
|
||||
|
||||
test.describe("Onboarding wizard", () => {
|
||||
test("a reload during a login resumes the same session", async ({ page }) => {
|
||||
const pageErrors: string[] = [];
|
||||
page.on("pageerror", (err) => pageErrors.push(err.message));
|
||||
const loginSessionReads: string[] = [];
|
||||
page.on("request", (request) => {
|
||||
const match = new URL(request.url()).pathname.match(/\/setup-token-login-sessions\/([^/]+)(?:\/prompt)?$/);
|
||||
if (match && match[1] !== "active") loginSessionReads.push(match[1]);
|
||||
});
|
||||
let hireCalls = 0;
|
||||
await page.route("**/agent-hires", (route) => {
|
||||
hireCalls += 1;
|
||||
return route.fulfill({ status: 400, json: { error: "Unexpected hire while login is pending." } });
|
||||
});
|
||||
|
||||
const flagRes = await page.request.patch("/api/instance/settings/experimental", {
|
||||
data: { enableConferenceRoomChat: true },
|
||||
});
|
||||
expect(flagRes.ok()).toBe(true);
|
||||
|
||||
const FAKE_SANDBOX_ENVIRONMENT_ID = "a6d2e530-1e8b-4f0b-9c94-42f1d23e8750";
|
||||
const FAKE_SANDBOX_PROVIDER = "e2e-fake-provider-reload";
|
||||
|
||||
await page.route("**/environments", async (route) => {
|
||||
const response = await route.fetch();
|
||||
const environments = await response.json();
|
||||
environments.push({
|
||||
id: FAKE_SANDBOX_ENVIRONMENT_ID,
|
||||
name: "E2E fake sandbox",
|
||||
description: null,
|
||||
driver: "sandbox",
|
||||
status: "active",
|
||||
config: { provider: FAKE_SANDBOX_PROVIDER },
|
||||
envVars: {},
|
||||
metadata: {},
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
});
|
||||
await route.fulfill({ response, json: environments });
|
||||
});
|
||||
|
||||
await page.route("**/environments/capabilities", async (route) => {
|
||||
const response = await route.fetch();
|
||||
const capabilities = await response.json();
|
||||
capabilities.sandboxProviders[FAKE_SANDBOX_PROVIDER] = {
|
||||
status: "supported",
|
||||
supportsSavedProbe: true,
|
||||
supportsUnsavedProbe: true,
|
||||
supportsRunExecution: true,
|
||||
supportsReusableLeases: false,
|
||||
supportsInteractiveSetup: false,
|
||||
interactiveSetupConnectionTypes: [],
|
||||
supportsTemplateCapture: false,
|
||||
supportsTemplateDelete: false,
|
||||
supportsLoginPty: true,
|
||||
source: "plugin",
|
||||
};
|
||||
await route.fulfill({ response, json: capabilities });
|
||||
});
|
||||
|
||||
await page.route("**/instance/settings", async (route) => {
|
||||
const response = await route.fetch();
|
||||
const settings = await response.json();
|
||||
settings.defaultEnvironmentId = FAKE_SANDBOX_ENVIRONMENT_ID;
|
||||
await route.fulfill({ response, json: settings });
|
||||
});
|
||||
|
||||
await page.route("**/adapters/*/auth-signal*", (route) =>
|
||||
route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ status: "absent" }),
|
||||
}),
|
||||
);
|
||||
|
||||
await page.route("**/api/adapters?**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
if (url.searchParams.get("environmentId") !== FAKE_SANDBOX_ENVIRONMENT_ID) return route.continue();
|
||||
url.searchParams.delete("environmentId");
|
||||
const response = await route.fetch({ url: url.toString() });
|
||||
expect(response.ok()).toBe(true);
|
||||
await route.fulfill({ response });
|
||||
});
|
||||
|
||||
await page.route("**/api/agents/*", async (route) => {
|
||||
if (route.request().method() !== "PATCH") return route.continue();
|
||||
const body = route.request().postDataJSON();
|
||||
if (body.defaultEnvironmentId !== FAKE_SANDBOX_ENVIRONMENT_ID) return route.continue();
|
||||
const response = await route.fetch({ postData: JSON.stringify({ ...body, defaultEnvironmentId: null }) });
|
||||
await route.fulfill({ response });
|
||||
});
|
||||
|
||||
const SESSION_ID = "e2e-reload-setup-token-session";
|
||||
const AUTHORIZATION_URL = "https://claude.ai/oauth/authorize?code=true&client=e2e-reload";
|
||||
let startCalls = 0;
|
||||
let sessionStarted = false;
|
||||
const resumedCompanyIds: string[] = [];
|
||||
let aiConnection: Record<string, unknown> | undefined;
|
||||
await page.route("**/setup-token-login-sessions", (route) => {
|
||||
if (route.request().method() === "POST") {
|
||||
startCalls += 1;
|
||||
sessionStarted = true;
|
||||
aiConnection = route.request().postDataJSON().aiConnection;
|
||||
}
|
||||
return route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
sessionId: SESSION_ID,
|
||||
environmentId: FAKE_SANDBOX_ENVIRONMENT_ID,
|
||||
aiConnection,
|
||||
status: "pending",
|
||||
expiresAt: new Date(Date.now() + 600_000).toISOString(),
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route(`**/setup-token-login-sessions/${SESSION_ID}/prompt`, (route) =>
|
||||
route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
authorizationUrl: AUTHORIZATION_URL,
|
||||
transportAdvisory: null,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
await page.route(`**/setup-token-login-sessions/${SESSION_ID}`, (route) => {
|
||||
if (route.request().method() !== "GET") return route.continue();
|
||||
return route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
sessionId: SESSION_ID,
|
||||
environmentId: FAKE_SANDBOX_ENVIRONMENT_ID,
|
||||
aiConnection,
|
||||
status: "pending",
|
||||
expiresAt: new Date(Date.now() + 600_000).toISOString(),
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route("**/setup-token-login-sessions/active", (route) => {
|
||||
if (!sessionStarted) {
|
||||
return route.fulfill({
|
||||
status: 404,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ error: "Setup-token login session not found." }),
|
||||
});
|
||||
}
|
||||
resumedCompanyIds.push(new URL(route.request().url()).pathname.split("/")[3]);
|
||||
return route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
sessionId: SESSION_ID,
|
||||
environmentId: FAKE_SANDBOX_ENVIRONMENT_ID,
|
||||
aiConnection,
|
||||
status: "pending",
|
||||
expiresAt: new Date(Date.now() + 600_000).toISOString(),
|
||||
panelMode: "submitted_browser_code",
|
||||
prompt: { authorizationUrl: AUTHORIZATION_URL, transportAdvisory: null },
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto("/onboarding");
|
||||
|
||||
const startBtn = page.getByRole("button", {
|
||||
name: /Start Onboarding|New Organization|Add Agent/,
|
||||
});
|
||||
if (await startBtn.count()) {
|
||||
await startBtn.first().click();
|
||||
}
|
||||
const createCard = page.getByRole("button", { name: /Build a new organization/ });
|
||||
if (await createCard.count()) {
|
||||
await createCard.first().click();
|
||||
}
|
||||
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "What is the name of your organization?" }),
|
||||
).toBeVisible({ timeout: 15_000 });
|
||||
await page.getByPlaceholder("e.g. Northwind Labs").fill(`${COMPANY_NAME}-reload`);
|
||||
await page.getByRole("button", { name: /^Continue/ }).click();
|
||||
|
||||
await page.waitForSelector("#onboarding-agent-name", { timeout: 30_000 });
|
||||
await page.locator("#onboarding-agent-name").fill("Ada");
|
||||
await page.getByRole("button", { name: "Next" }).click();
|
||||
|
||||
const source = page.getByRole("radio").first();
|
||||
await source.waitFor({ timeout: 30_000 });
|
||||
await source.click();
|
||||
|
||||
const cardInstruction = page.getByText("then come back and enter authorization code");
|
||||
const authorizationLink = page.getByRole("link", { name: /^Sign in to / });
|
||||
|
||||
await expect(cardInstruction).toBeVisible({ timeout: 30_000 });
|
||||
await expect(authorizationLink).toBeVisible({ timeout: 15_000 });
|
||||
await expect(authorizationLink).toHaveAttribute("href", AUTHORIZATION_URL);
|
||||
expect(startCalls).toBe(1);
|
||||
|
||||
const companiesRes = await page.request.get("/api/companies");
|
||||
expect(companiesRes.ok()).toBe(true);
|
||||
const companies = await companiesRes.json();
|
||||
const company = companies.find(
|
||||
(c: { name: string }) => c.name === `${COMPANY_NAME}-reload`,
|
||||
);
|
||||
expect(company, "the created company should exist").toBeTruthy();
|
||||
|
||||
const savedSelection = {
|
||||
step: 4,
|
||||
companyName: `${COMPANY_NAME}-reload`,
|
||||
agentName: "Ada",
|
||||
adapterType: "claude_local",
|
||||
runner: "auto",
|
||||
credentialMode: "subscription",
|
||||
credentialModeChoice: null,
|
||||
createdCompanyId: company.id,
|
||||
createdCompanyPrefix: company.issuePrefix,
|
||||
createdAgentId: null,
|
||||
};
|
||||
const readDraft = () => page.evaluate(() => JSON.parse(localStorage.getItem("paperclip-onboarding-state") ?? "null"));
|
||||
await expect.poll(readDraft).toMatchObject(savedSelection);
|
||||
const { setupAgentId } = await readDraft();
|
||||
await expect.poll(async () => (await (await page.request.get(`/api/agents/${setupAgentId}?companyId=${company.id}`)).json()).metadata?.setupAdapterPending).toBe(false);
|
||||
const setupResponse = await page.request.get(`/api/agents/${setupAgentId}?companyId=${company.id}`);
|
||||
expect(setupResponse.ok()).toBe(true);
|
||||
const setup = await setupResponse.json();
|
||||
expect(setup).toMatchObject({ id: setupAgentId, name: "Ada", pauseReason: "setup" });
|
||||
const resumedSelection = { ...savedSelection, setupAgentId,
|
||||
runner: setup.adapterType === "paperclip_runner" ? "paperclip" : "legacy" };
|
||||
const assertResumedLogin = async () => {
|
||||
await expect(page.getByRole("heading", { name: "Connect a model", exact: true })).toBeVisible({ timeout: 15_000 });
|
||||
await expect(page.getByTestId("onboarding-wizard").getByText("Ada", { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("radio", { name: "Claude Subscription", exact: true })).toBeChecked();
|
||||
await expect(cardInstruction).toBeVisible({ timeout: 15_000 });
|
||||
await expect(authorizationLink).toBeVisible({ timeout: 15_000 });
|
||||
await expect(authorizationLink).toHaveAttribute("href", AUTHORIZATION_URL);
|
||||
await expect.poll(readDraft).toMatchObject(resumedSelection);
|
||||
expect(startCalls, "reopening must resume the session without a second source choice").toBe(1);
|
||||
expect(hireCalls, "a pending login must not hire an agent").toBe(0);
|
||||
expect(loginSessionReads.length).toBeGreaterThan(0);
|
||||
expect(new Set(loginSessionReads)).toEqual(new Set([SESSION_ID]));
|
||||
expect(new Set(resumedCompanyIds)).toEqual(new Set([company.id]));
|
||||
};
|
||||
|
||||
const beforeReopenReads = resumedCompanyIds.length;
|
||||
await page.goto(`/${company.issuePrefix}/onboarding`);
|
||||
await expect.poll(() => resumedCompanyIds.length, { timeout: 15_000 }).toBeGreaterThan(beforeReopenReads);
|
||||
await assertResumedLogin();
|
||||
|
||||
const beforeReloadReads = resumedCompanyIds.length;
|
||||
await page.reload();
|
||||
await expect.poll(() => resumedCompanyIds.length, { timeout: 15_000 }).toBeGreaterThan(beforeReloadReads);
|
||||
await assertResumedLogin();
|
||||
|
||||
expect(pageErrors, pageErrors.join("\n")).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("connect step blocks the hire when the environment probe fails after account connection", async ({
|
||||
page,
|
||||
}) => {
|
||||
await mockOnboardingLocalAiConnection(page);
|
||||
const pageErrors: string[] = [];
|
||||
page.on("pageerror", (err) => pageErrors.push(err.message));
|
||||
|
||||
const flagRes = await page.request.patch("/api/instance/settings/experimental", {
|
||||
data: { enableConferenceRoomChat: true },
|
||||
});
|
||||
expect(flagRes.ok()).toBe(true);
|
||||
|
||||
await page.route("**/test-environment", (route) =>
|
||||
route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
adapterType: "claude_local",
|
||||
status: "fail",
|
||||
checks: [
|
||||
{
|
||||
code: "claude_cli_not_found",
|
||||
level: "fail",
|
||||
message: "The claude CLI was not found on this host.",
|
||||
},
|
||||
],
|
||||
testedAt: new Date().toISOString(),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
let hireCalled = false;
|
||||
await page.route("**/agent-hires", (route) => {
|
||||
hireCalled = true;
|
||||
return route.continue();
|
||||
});
|
||||
|
||||
await page.goto("/onboarding");
|
||||
|
||||
const startBtn = page.getByRole("button", {
|
||||
name: /Start Onboarding|New Organization|Add Agent/,
|
||||
});
|
||||
if (await startBtn.count()) {
|
||||
await startBtn.first().click();
|
||||
}
|
||||
const createCard = page.getByRole("button", { name: /Build a new organization/ });
|
||||
if (await createCard.count()) {
|
||||
await createCard.first().click();
|
||||
}
|
||||
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "What is the name of your organization?" }),
|
||||
).toBeVisible({ timeout: 15_000 });
|
||||
await page.getByPlaceholder("e.g. Northwind Labs").fill(`${COMPANY_NAME}-probe-gate`);
|
||||
await page.getByRole("button", { name: /^Continue/ }).click();
|
||||
|
||||
await page.waitForSelector("#onboarding-agent-name", { timeout: 30_000 });
|
||||
await page.locator("#onboarding-agent-name").fill("Ada");
|
||||
await page.getByRole("button", { name: "Next" }).click();
|
||||
|
||||
const source = page.getByRole("radio").first();
|
||||
await source.waitFor({ timeout: 30_000 });
|
||||
await source.click();
|
||||
|
||||
const connect = page.getByRole("button", { name: "Connect", exact: true });
|
||||
await expect(connect).toBeEnabled({ timeout: 30_000 });
|
||||
await connect.click();
|
||||
|
||||
await expect(page.getByText("The claude CLI was not found on this host.")).toBeVisible({
|
||||
timeout: 15_000,
|
||||
});
|
||||
expect(hireCalled).toBe(false);
|
||||
|
||||
expect(pageErrors, pageErrors.join("\n")).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("duplicate name drafts can select Copilot before connecting a GitHub account", async ({ page }) => {
|
||||
const response = await page.request.post("/api/companies", { data: { name: `${COMPANY_NAME}-duplicate-copilot` } });
|
||||
expect(response.ok()).toBe(true);
|
||||
const company = await response.json();
|
||||
await page.goto(`/${company.issuePrefix}/agents/all`);
|
||||
let duplicate: { id: string; name: string };
|
||||
for (let attempt = 0; attempt < 2; attempt++) {
|
||||
await page.getByRole("toolbar", { name: "Agents controls" }).getByRole("button", { name: "New Agent", exact: true }).click();
|
||||
await page.getByLabel("Agent name", { exact: true }).fill("Echo");
|
||||
const setupResponse = page.waitForResponse(result => result.request().method() === "POST" && result.url().endsWith(`/api/companies/${company.id}/agents`));
|
||||
await page.getByRole("button", { name: "Choose adapter", exact: true }).click();
|
||||
duplicate = await (await setupResponse).json();
|
||||
await expect(page.getByRole("heading", { name: "Choose an adapter", exact: true })).toBeVisible();
|
||||
if (attempt === 0) await page.keyboard.press("Escape");
|
||||
}
|
||||
expect(duplicate!.name).toBe("Echo 2");
|
||||
await expect(page.getByText("How should Echo 2 work?", { exact: true })).toBeVisible();
|
||||
await page.locator("label").filter({ has: page.locator('input[name="new-agent-adapter"][value="copilot_runtime"]') }).click();
|
||||
await page.getByRole("button", { name: "Configure agent", exact: true }).click();
|
||||
await expect(page.getByRole("heading", { name: "Configure your agent", exact: true })).toBeVisible();
|
||||
expect(new URL(page.url()).searchParams.get("setupAgentId")).toBe(duplicate!.id);
|
||||
const saved = await (await page.request.get(`/api/agents/${duplicate!.id}?companyId=${company.id}`)).json();
|
||||
expect(saved).toMatchObject({ id: duplicate!.id, name: "Echo 2", pauseReason: "setup", adapterConfig: { provider: "acpx", acpxAgent: "copilot" } });
|
||||
expect(saved.runtimeConfig.aiConnection).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,4 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { mockOnboardingLocalAiConnection } from "./helpers/onboarding-ai-connection";
|
||||
|
||||
/**
|
||||
* E2E: Onboarding wizard flow (NUX Phase 2 expanded wizard).
|
||||
@@ -409,346 +408,7 @@ test.describe("Onboarding wizard", () => {
|
||||
|
||||
expect(pageErrors, pageErrors.join("\n")).toHaveLength(0);
|
||||
});
|
||||
test("a reload during a login resumes the same session", async ({ page }) => {
|
||||
const pageErrors: string[] = [];
|
||||
page.on("pageerror", (err) => pageErrors.push(err.message));
|
||||
const loginSessionReads: string[] = [];
|
||||
page.on("request", (request) => {
|
||||
const match = new URL(request.url()).pathname.match(/\/setup-token-login-sessions\/([^/]+)(?:\/prompt)?$/);
|
||||
if (match && match[1] !== "active") loginSessionReads.push(match[1]);
|
||||
});
|
||||
let hireCalls = 0;
|
||||
await page.route("**/agent-hires", (route) => {
|
||||
hireCalls += 1;
|
||||
return route.fulfill({ status: 400, json: { error: "Unexpected hire while login is pending." } });
|
||||
});
|
||||
|
||||
const flagRes = await page.request.patch("/api/instance/settings/experimental", {
|
||||
data: { enableConferenceRoomChat: true },
|
||||
});
|
||||
expect(flagRes.ok()).toBe(true);
|
||||
|
||||
const FAKE_SANDBOX_ENVIRONMENT_ID = "a6d2e530-1e8b-4f0b-9c94-42f1d23e8750";
|
||||
const FAKE_SANDBOX_PROVIDER = "e2e-fake-provider-reload";
|
||||
|
||||
await page.route("**/environments", async (route) => {
|
||||
const response = await route.fetch();
|
||||
const environments = await response.json();
|
||||
environments.push({
|
||||
id: FAKE_SANDBOX_ENVIRONMENT_ID,
|
||||
name: "E2E fake sandbox",
|
||||
description: null,
|
||||
driver: "sandbox",
|
||||
status: "active",
|
||||
config: { provider: FAKE_SANDBOX_PROVIDER },
|
||||
envVars: {},
|
||||
metadata: {},
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
});
|
||||
await route.fulfill({ response, json: environments });
|
||||
});
|
||||
|
||||
await page.route("**/environments/capabilities", async (route) => {
|
||||
const response = await route.fetch();
|
||||
const capabilities = await response.json();
|
||||
capabilities.sandboxProviders[FAKE_SANDBOX_PROVIDER] = {
|
||||
status: "supported",
|
||||
supportsSavedProbe: true,
|
||||
supportsUnsavedProbe: true,
|
||||
supportsRunExecution: true,
|
||||
supportsReusableLeases: false,
|
||||
supportsInteractiveSetup: false,
|
||||
interactiveSetupConnectionTypes: [],
|
||||
supportsTemplateCapture: false,
|
||||
supportsTemplateDelete: false,
|
||||
supportsLoginPty: true,
|
||||
source: "plugin",
|
||||
};
|
||||
await route.fulfill({ response, json: capabilities });
|
||||
});
|
||||
|
||||
await page.route("**/instance/settings", async (route) => {
|
||||
const response = await route.fetch();
|
||||
const settings = await response.json();
|
||||
settings.defaultEnvironmentId = FAKE_SANDBOX_ENVIRONMENT_ID;
|
||||
await route.fulfill({ response, json: settings });
|
||||
});
|
||||
|
||||
await page.route("**/adapters/*/auth-signal*", (route) =>
|
||||
route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ status: "absent" }),
|
||||
}),
|
||||
);
|
||||
|
||||
await page.route("**/api/adapters?**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
if (url.searchParams.get("environmentId") !== FAKE_SANDBOX_ENVIRONMENT_ID) return route.continue();
|
||||
url.searchParams.delete("environmentId");
|
||||
const response = await route.fetch({ url: url.toString() });
|
||||
expect(response.ok()).toBe(true);
|
||||
await route.fulfill({ response });
|
||||
});
|
||||
|
||||
// The synthetic sandbox only drives the login UI; persist configuration
|
||||
// against the real local default so a failed fixture write cannot mask restore behavior.
|
||||
await page.route("**/api/agents/*", async (route) => {
|
||||
if (route.request().method() !== "PATCH") return route.continue();
|
||||
const body = route.request().postDataJSON();
|
||||
if (body.defaultEnvironmentId !== FAKE_SANDBOX_ENVIRONMENT_ID) return route.continue();
|
||||
const response = await route.fetch({ postData: JSON.stringify({ ...body, defaultEnvironmentId: null }) });
|
||||
await route.fulfill({ response });
|
||||
});
|
||||
|
||||
const SESSION_ID = "e2e-reload-setup-token-session";
|
||||
const AUTHORIZATION_URL = "https://claude.ai/oauth/authorize?code=true&client=e2e-reload";
|
||||
let startCalls = 0;
|
||||
// Flips once the login actually starts, so the owner-scoped resume read
|
||||
// below answers "no active session" until then — matching the real
|
||||
// route, and keeping the pre-Connect part of this test the same as the
|
||||
// ordinary sign-in test above.
|
||||
let sessionStarted = false;
|
||||
const resumedCompanyIds: string[] = [];
|
||||
let aiConnection: Record<string, unknown> | undefined;
|
||||
await page.route("**/setup-token-login-sessions", (route) => {
|
||||
if (route.request().method() === "POST") {
|
||||
startCalls += 1;
|
||||
sessionStarted = true;
|
||||
aiConnection = route.request().postDataJSON().aiConnection;
|
||||
}
|
||||
return route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
sessionId: SESSION_ID,
|
||||
environmentId: FAKE_SANDBOX_ENVIRONMENT_ID,
|
||||
aiConnection,
|
||||
status: "pending",
|
||||
expiresAt: new Date(Date.now() + 600_000).toISOString(),
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route(`**/setup-token-login-sessions/${SESSION_ID}/prompt`, (route) =>
|
||||
route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
authorizationUrl: AUTHORIZATION_URL,
|
||||
transportAdvisory: null,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
await page.route(`**/setup-token-login-sessions/${SESSION_ID}`, (route) => {
|
||||
if (route.request().method() !== "GET") return route.continue();
|
||||
return route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
sessionId: SESSION_ID,
|
||||
environmentId: FAKE_SANDBOX_ENVIRONMENT_ID,
|
||||
aiConnection,
|
||||
status: "pending",
|
||||
expiresAt: new Date(Date.now() + 600_000).toISOString(),
|
||||
}),
|
||||
});
|
||||
});
|
||||
// The owner-scoped resume read. Both the wizard's own step-restore effect
|
||||
// and the panel's own resume-on-mount read use this, with no session id
|
||||
// in the URL — the caller rediscovers its own session.
|
||||
await page.route("**/setup-token-login-sessions/active", (route) => {
|
||||
if (!sessionStarted) {
|
||||
return route.fulfill({
|
||||
status: 404,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ error: "Setup-token login session not found." }),
|
||||
});
|
||||
}
|
||||
resumedCompanyIds.push(new URL(route.request().url()).pathname.split("/")[3]);
|
||||
return route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
sessionId: SESSION_ID,
|
||||
environmentId: FAKE_SANDBOX_ENVIRONMENT_ID,
|
||||
aiConnection,
|
||||
status: "pending",
|
||||
expiresAt: new Date(Date.now() + 600_000).toISOString(),
|
||||
panelMode: "submitted_browser_code",
|
||||
prompt: { authorizationUrl: AUTHORIZATION_URL, transportAdvisory: null },
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto("/onboarding");
|
||||
|
||||
const startBtn = page.getByRole("button", {
|
||||
name: /Start Onboarding|New Organization|Add Agent/,
|
||||
});
|
||||
if (await startBtn.count()) {
|
||||
await startBtn.first().click();
|
||||
}
|
||||
const createCard = page.getByRole("button", { name: /Build a new organization/ });
|
||||
if (await createCard.count()) {
|
||||
await createCard.first().click();
|
||||
}
|
||||
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "What is the name of your organization?" }),
|
||||
).toBeVisible({ timeout: 15_000 });
|
||||
await page.getByPlaceholder("e.g. Northwind Labs").fill(`${COMPANY_NAME}-reload`);
|
||||
await page.getByRole("button", { name: /^Continue/ }).click();
|
||||
|
||||
await page.waitForSelector("#onboarding-agent-name", { timeout: 30_000 });
|
||||
await page.locator("#onboarding-agent-name").fill("Ada");
|
||||
await page.getByRole("button", { name: "Next" }).click();
|
||||
|
||||
const source = page.getByRole("radio").first();
|
||||
await source.waitFor({ timeout: 30_000 });
|
||||
|
||||
// Answering the row is what starts the sign-in now — there is no separate
|
||||
// Connect press between choosing a source and being signed in.
|
||||
await source.click();
|
||||
|
||||
const cardInstruction = page.getByText("then come back and enter authorization code");
|
||||
const authorizationLink = page.getByRole("link", { name: /^Sign in to / });
|
||||
|
||||
await expect(cardInstruction).toBeVisible({ timeout: 30_000 });
|
||||
await expect(authorizationLink).toBeVisible({ timeout: 15_000 });
|
||||
await expect(authorizationLink).toHaveAttribute("href", AUTHORIZATION_URL);
|
||||
expect(startCalls).toBe(1);
|
||||
|
||||
const companiesRes = await page.request.get("/api/companies");
|
||||
expect(companiesRes.ok()).toBe(true);
|
||||
const companies = await companiesRes.json();
|
||||
const company = companies.find(
|
||||
(c: { name: string }) => c.name === `${COMPANY_NAME}-reload`,
|
||||
);
|
||||
expect(company, "the created company should exist").toBeTruthy();
|
||||
|
||||
const savedSelection = {
|
||||
step: 4,
|
||||
companyName: `${COMPANY_NAME}-reload`,
|
||||
agentName: "Ada",
|
||||
adapterType: "claude_local",
|
||||
runner: "auto",
|
||||
credentialMode: "subscription",
|
||||
credentialModeChoice: null,
|
||||
createdCompanyId: company.id,
|
||||
createdCompanyPrefix: company.issuePrefix,
|
||||
createdAgentId: null,
|
||||
};
|
||||
const readDraft = () => page.evaluate(() => JSON.parse(localStorage.getItem("paperclip-onboarding-state") ?? "null"));
|
||||
await expect.poll(readDraft).toMatchObject(savedSelection);
|
||||
const { setupAgentId } = await readDraft();
|
||||
await expect.poll(async () => (await (await page.request.get(`/api/agents/${setupAgentId}?companyId=${company.id}`)).json()).metadata?.setupAdapterPending).toBe(false);
|
||||
const setupResponse = await page.request.get(`/api/agents/${setupAgentId}?companyId=${company.id}`);
|
||||
expect(setupResponse.ok()).toBe(true);
|
||||
const setup = await setupResponse.json();
|
||||
expect(setup).toMatchObject({ id: setupAgentId, name: "Ada", pauseReason: "setup" });
|
||||
const resumedSelection = { ...savedSelection, setupAgentId,
|
||||
runner: setup.adapterType === "paperclip_runner" ? "paperclip" : "legacy" };
|
||||
const assertResumedLogin = async () => {
|
||||
await expect(page.getByRole("heading", { name: "Connect a model", exact: true })).toBeVisible({ timeout: 15_000 });
|
||||
await expect(page.getByTestId("onboarding-wizard").getByText("Ada", { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("radio", { name: "Claude Subscription", exact: true })).toBeChecked();
|
||||
await expect(cardInstruction).toBeVisible({ timeout: 15_000 });
|
||||
await expect(authorizationLink).toBeVisible({ timeout: 15_000 });
|
||||
await expect(authorizationLink).toHaveAttribute("href", AUTHORIZATION_URL);
|
||||
await expect.poll(readDraft).toMatchObject(resumedSelection);
|
||||
expect(startCalls, "reopening must resume the session without a second source choice").toBe(1);
|
||||
expect(hireCalls, "a pending login must not hire an agent").toBe(0);
|
||||
expect(loginSessionReads.length).toBeGreaterThan(0);
|
||||
expect(new Set(loginSessionReads)).toEqual(new Set([SESSION_ID]));
|
||||
expect(new Set(resumedCompanyIds)).toEqual(new Set([company.id]));
|
||||
};
|
||||
|
||||
const beforeReopenReads = resumedCompanyIds.length;
|
||||
await page.goto(`/${company.issuePrefix}/onboarding`);
|
||||
await expect.poll(() => resumedCompanyIds.length, { timeout: 15_000 }).toBeGreaterThan(beforeReopenReads);
|
||||
await assertResumedLogin();
|
||||
|
||||
const beforeReloadReads = resumedCompanyIds.length;
|
||||
await page.reload();
|
||||
await expect.poll(() => resumedCompanyIds.length, { timeout: 15_000 }).toBeGreaterThan(beforeReloadReads);
|
||||
await assertResumedLogin();
|
||||
|
||||
expect(pageErrors, pageErrors.join("\n")).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("connect step blocks the hire when the environment probe fails after account connection", async ({
|
||||
page,
|
||||
}) => {
|
||||
// A successful local account connection still requires a passing
|
||||
// environment probe before the wizard may hire the agent.
|
||||
await mockOnboardingLocalAiConnection(page);
|
||||
const pageErrors: string[] = [];
|
||||
page.on("pageerror", (err) => pageErrors.push(err.message));
|
||||
|
||||
const flagRes = await page.request.patch("/api/instance/settings/experimental", {
|
||||
data: { enableConferenceRoomChat: true },
|
||||
});
|
||||
expect(flagRes.ok()).toBe(true);
|
||||
|
||||
await page.route("**/test-environment", (route) =>
|
||||
route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
adapterType: "claude_local",
|
||||
status: "fail",
|
||||
checks: [
|
||||
{
|
||||
code: "claude_cli_not_found",
|
||||
level: "fail",
|
||||
message: "The claude CLI was not found on this host.",
|
||||
},
|
||||
],
|
||||
testedAt: new Date().toISOString(),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
let hireCalled = false;
|
||||
await page.route("**/agent-hires", (route) => {
|
||||
hireCalled = true;
|
||||
return route.continue();
|
||||
});
|
||||
|
||||
await page.goto("/onboarding");
|
||||
|
||||
const startBtn = page.getByRole("button", {
|
||||
name: /Start Onboarding|New Organization|Add Agent/,
|
||||
});
|
||||
if (await startBtn.count()) {
|
||||
await startBtn.first().click();
|
||||
}
|
||||
const createCard = page.getByRole("button", { name: /Build a new organization/ });
|
||||
if (await createCard.count()) {
|
||||
await createCard.first().click();
|
||||
}
|
||||
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "What is the name of your organization?" }),
|
||||
).toBeVisible({ timeout: 15_000 });
|
||||
await page.getByPlaceholder("e.g. Northwind Labs").fill(`${COMPANY_NAME}-probe-gate`);
|
||||
await page.getByRole("button", { name: /^Continue/ }).click();
|
||||
|
||||
await page.waitForSelector("#onboarding-agent-name", { timeout: 30_000 });
|
||||
await page.locator("#onboarding-agent-name").fill("Ada");
|
||||
await page.getByRole("button", { name: "Next" }).click();
|
||||
|
||||
const source = page.getByRole("radio").first();
|
||||
await source.waitFor({ timeout: 30_000 });
|
||||
await source.click();
|
||||
|
||||
const connect = page.getByRole("button", { name: "Connect", exact: true });
|
||||
await expect(connect).toBeEnabled({ timeout: 30_000 });
|
||||
await connect.click();
|
||||
|
||||
// The failed probe blocks the hire and shows its own checks.
|
||||
await expect(page.getByText("The claude CLI was not found on this host.")).toBeVisible({
|
||||
timeout: 15_000,
|
||||
});
|
||||
expect(hireCalled).toBe(false);
|
||||
|
||||
expect(pageErrors, pageErrors.join("\n")).toHaveLength(0);
|
||||
});
|
||||
test("name-only setup saves the Grok Build adapter on the same record without an advanced picker", async ({ page }) => {
|
||||
const previous = await (await page.request.get("/api/instance/settings/experimental")).json();
|
||||
await page.request.patch("/api/instance/settings/experimental", { data: { enableNativeRunner: true } });
|
||||
@@ -785,31 +445,4 @@ test.describe("Onboarding wizard", () => {
|
||||
await page.request.patch("/api/instance/settings/experimental", { data: { enableNativeRunner: previous.enableNativeRunner === true } });
|
||||
}
|
||||
});
|
||||
|
||||
test("duplicate name drafts can select Copilot before connecting a GitHub account", async ({ page }) => {
|
||||
const response = await page.request.post("/api/companies", { data: { name: `${COMPANY_NAME}-duplicate-copilot` } });
|
||||
expect(response.ok()).toBe(true);
|
||||
const company = await response.json();
|
||||
await page.goto(`/${company.issuePrefix}/agents/all`);
|
||||
let duplicate: { id: string; name: string };
|
||||
for (let attempt = 0; attempt < 2; attempt++) {
|
||||
await page.getByRole("toolbar", { name: "Agents controls" }).getByRole("button", { name: "New Agent", exact: true }).click();
|
||||
await page.getByLabel("Agent name", { exact: true }).fill("Echo");
|
||||
const setupResponse = page.waitForResponse(result => result.request().method() === "POST" && result.url().endsWith(`/api/companies/${company.id}/agents`));
|
||||
await page.getByRole("button", { name: "Choose adapter", exact: true }).click();
|
||||
duplicate = await (await setupResponse).json();
|
||||
await expect(page.getByRole("heading", { name: "Choose an adapter", exact: true })).toBeVisible();
|
||||
if (attempt === 0) await page.keyboard.press("Escape");
|
||||
}
|
||||
expect(duplicate!.name).toBe("Echo 2");
|
||||
await expect(page.getByText("How should Echo 2 work?", { exact: true })).toBeVisible();
|
||||
await page.locator("label").filter({ has: page.locator('input[name="new-agent-adapter"][value="copilot_runtime"]') }).click();
|
||||
await page.getByRole("button", { name: "Configure agent", exact: true }).click();
|
||||
await expect(page.getByRole("heading", { name: "Configure your agent", exact: true })).toBeVisible();
|
||||
expect(new URL(page.url()).searchParams.get("setupAgentId")).toBe(duplicate!.id);
|
||||
const saved = await (await page.request.get(`/api/agents/${duplicate!.id}?companyId=${company.id}`)).json();
|
||||
expect(saved).toMatchObject({ id: duplicate!.id, name: "Echo 2", pauseReason: "setup", adapterConfig: { provider: "acpx", acpxAgent: "copilot" } });
|
||||
expect(saved.runtimeConfig.aiConnection).toBeUndefined();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -51,7 +51,9 @@ if (SKIP_UI_BUILD && !fs.existsSync(UI_DIST_INDEX)) {
|
||||
export const SERIAL_SPECS = [
|
||||
"agent-chat-projects-handoff.spec.ts",
|
||||
"agent-chat-projects.spec.ts",
|
||||
"agent-chat-sessions-navigation.spec.ts",
|
||||
"agent-chat-sessions.spec.ts",
|
||||
"agent-configuration-revisions.spec.ts",
|
||||
"agent-configuration.spec.ts",
|
||||
"ai-personal-connection-recovery.spec.ts",
|
||||
"cases-read-only.spec.ts",
|
||||
@@ -59,6 +61,7 @@ export const SERIAL_SPECS = [
|
||||
"composer-stop.spec.ts",
|
||||
"connection-intents.spec.ts",
|
||||
"document-image-gallery.spec.ts",
|
||||
"onboarding-resume.spec.ts",
|
||||
"onboarding.spec.ts",
|
||||
"smoke-lab-p1-p4.spec.ts",
|
||||
"smoke-lab-p5-p7.spec.ts",
|
||||
@@ -122,13 +125,9 @@ function resolveExecutionMode(): { workers: number; fullyParallel: boolean } {
|
||||
}
|
||||
|
||||
const EXECUTION_MODE = resolveExecutionMode();
|
||||
const UI_BUILD_COMMAND =
|
||||
"node ui/node_modules/vite/bin/vite.js build ui --outDir ../server/ui-dist --emptyOutDir --minify false";
|
||||
const SERVER_START_COMMAND =
|
||||
"node cli/node_modules/tsx/dist/cli.mjs tests/e2e/start-e2e-server.ts";
|
||||
const WEB_SERVER_COMMAND = SKIP_UI_BUILD
|
||||
? SERVER_START_COMMAND
|
||||
: `${UI_BUILD_COMMAND} && ${SERVER_START_COMMAND}`;
|
||||
const WEB_SERVER_COMMAND = SERVER_START_COMMAND;
|
||||
|
||||
export default defineConfig({
|
||||
testDir: ".",
|
||||
@@ -179,6 +178,7 @@ export default defineConfig({
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_ENV: "test",
|
||||
PAPERCLIP_E2E_BUILD_UI: SKIP_UI_BUILD ? "0" : "1",
|
||||
PAPERCLIP_UI_DEV_MIDDLEWARE: "false",
|
||||
HEARTBEAT_SCHEDULER_INTERVAL_MS: process.env.HEARTBEAT_SCHEDULER_INTERVAL_MS ?? "10000",
|
||||
NODE_OPTIONS: `${process.env.NODE_OPTIONS ?? ""} --import=${path.resolve(import.meta.dirname, "fixtures/agent-chat-github.mjs")} --import=${path.resolve(import.meta.dirname, "fixtures/ai-connection-provider.mjs")}`,
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { spawn, type ChildProcess } from "node:child_process";
|
||||
import { randomBytes } from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import net from "node:net";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import {
|
||||
applyPendingMigrations,
|
||||
closeRegisteredClients,
|
||||
@@ -63,10 +65,49 @@ const DISPOSABLE_PG_CONF = [
|
||||
"autovacuum = off",
|
||||
"checkpoint_timeout = 1h",
|
||||
"max_wal_size = 1GB",
|
||||
"maintenance_work_mem = 128MB",
|
||||
"work_mem = 32MB",
|
||||
"log_min_messages = warning",
|
||||
"",
|
||||
].join("\n");
|
||||
|
||||
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
||||
const UI_BUILD_ARGS = [
|
||||
"ui/node_modules/vite/bin/vite.js",
|
||||
"build",
|
||||
"ui",
|
||||
"--outDir",
|
||||
"../server/ui-dist",
|
||||
"--emptyOutDir",
|
||||
"--minify",
|
||||
"false",
|
||||
];
|
||||
|
||||
function startParallelUiBuild(): { child: ChildProcess; done: Promise<void> } | null {
|
||||
if (process.env.PAPERCLIP_E2E_BUILD_UI !== "1") return null;
|
||||
const child = spawn(process.execPath, UI_BUILD_ARGS, {
|
||||
cwd: REPO_ROOT,
|
||||
stdio: "inherit",
|
||||
env: process.env,
|
||||
});
|
||||
const done = new Promise<void>((resolve, reject) => {
|
||||
child.once("error", reject);
|
||||
child.once("close", (code, signal) => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
reject(
|
||||
new Error(
|
||||
`E2E UI build failed (${signal ? `signal ${signal}` : `exit code ${code ?? "unknown"}`})`,
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
done.catch(() => {});
|
||||
return { child, done };
|
||||
}
|
||||
|
||||
const MAX_START_ATTEMPTS = 5;
|
||||
|
||||
async function getAvailablePort(): Promise<number> {
|
||||
@@ -266,6 +307,15 @@ process.env.PAPERCLIP_DB_BACKUP_ENABLED = "false";
|
||||
let db: DisposableDatabase | undefined;
|
||||
let shutdownServer: ((signal?: "SIGINT" | "SIGTERM") => Promise<void>) | undefined;
|
||||
let shuttingDown = false;
|
||||
let uiBuild: { child: ChildProcess; done: Promise<void> } | null = null;
|
||||
|
||||
function stopUiBuild() {
|
||||
if (!uiBuild || uiBuild.child.exitCode !== null || uiBuild.child.signalCode !== null) return;
|
||||
try {
|
||||
uiBuild.child.kill("SIGTERM");
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
function hasWarmEmbeddedPostgresTemplate(): boolean {
|
||||
if (process.env.PAPERCLIP_TEST_POSTGRES_TEMPLATE === "0") return false;
|
||||
@@ -304,6 +354,7 @@ if (usesExternalPostgres) {
|
||||
const shutdownExternal = async (signal: "SIGINT" | "SIGTERM") => {
|
||||
if (shuttingDown) return;
|
||||
shuttingDown = true;
|
||||
stopUiBuild();
|
||||
try {
|
||||
await shutdownServer?.(signal);
|
||||
} finally {
|
||||
@@ -318,6 +369,7 @@ if (usesExternalPostgres) {
|
||||
stop: async (signal) => {
|
||||
if (shuttingDown) return;
|
||||
shuttingDown = true;
|
||||
stopUiBuild();
|
||||
await shutdownServer?.(signal === "SIGINT" ? "SIGINT" : "SIGTERM");
|
||||
if (db) await closeRegisteredClients(db.connectionString).catch(() => {});
|
||||
},
|
||||
@@ -328,28 +380,43 @@ if (usesExternalPostgres) {
|
||||
});
|
||||
}
|
||||
|
||||
let dbPromise: Promise<DisposableDatabase> | undefined;
|
||||
|
||||
try {
|
||||
uiBuild = startParallelUiBuild();
|
||||
const uiReady = uiBuild?.done ?? Promise.resolve();
|
||||
let startedDb: DisposableDatabase;
|
||||
let serverModule: typeof import("../../server/src/index.js");
|
||||
|
||||
if (usesExternalPostgres) {
|
||||
startedDb = await startEmbeddedPostgresTestDatabase("paperclip-e2e-pg-");
|
||||
serverModule = await import("../../server/src/index.js");
|
||||
dbPromise = startEmbeddedPostgresTestDatabase("paperclip-e2e-pg-");
|
||||
[startedDb, serverModule] = await Promise.all([
|
||||
dbPromise,
|
||||
import("../../server/src/index.js"),
|
||||
uiReady,
|
||||
]).then(([pg, mod]) => [pg, mod] as const);
|
||||
} else if (useWarmTemplate) {
|
||||
startedDb = await startEmbeddedPostgresTestDatabase("paperclip-e2e-pg-");
|
||||
await tuneDisposableCluster(startedDb.connectionString);
|
||||
serverModule = await import("../../server/src/index.js");
|
||||
dbPromise = (async () => {
|
||||
const pg = await startEmbeddedPostgresTestDatabase("paperclip-e2e-pg-");
|
||||
await tuneDisposableCluster(pg.connectionString);
|
||||
return pg;
|
||||
})();
|
||||
[startedDb, serverModule] = await Promise.all([
|
||||
dbPromise,
|
||||
import("../../server/src/index.js"),
|
||||
uiReady,
|
||||
]).then(([pg, mod]) => [pg, mod] as const);
|
||||
} else {
|
||||
// Load `embedded-postgres` and spawn `initdb` BEFORE calling
|
||||
// `import("../../server/src/index.js")` so synchronous `createRequire`
|
||||
// never races `tsx`'s ESM loader AND `initdb` runs in a separate OS
|
||||
// process while `tsx` transpiles the server graph.
|
||||
const embeddedPostgresCtor = await loadEmbeddedPostgresCtor();
|
||||
const fastPg = await startFastDisposablePostgres(embeddedPostgresCtor);
|
||||
dbPromise = fastPg.ready;
|
||||
[startedDb, serverModule] = await Promise.all([
|
||||
fastPg.ready,
|
||||
dbPromise,
|
||||
import("../../server/src/index.js"),
|
||||
]);
|
||||
uiReady,
|
||||
]).then(([pg, mod]) => [pg, mod] as const);
|
||||
}
|
||||
db = startedDb;
|
||||
|
||||
@@ -397,6 +464,8 @@ try {
|
||||
const started = await serverModule.startServer();
|
||||
shutdownServer = started.shutdown;
|
||||
} catch (error) {
|
||||
await db?.cleanup();
|
||||
stopUiBuild();
|
||||
const cleanupDb = db ?? (await dbPromise?.catch(() => undefined));
|
||||
await cleanupDb?.cleanup();
|
||||
throw error;
|
||||
}
|
||||
Reference in new issue
Block a user