Skip to content

Commit 202cc28

Browse files
test(plugin-approvals): boot the #38838 publish-refusal describe kernel once (#39002)
Fixes #38976 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户无感:只改一份审批流程测试的启动方式,产品行为不变。 - 为什么做:这份测试在繁忙的持续集成机器上偶尔超时,连累了好几个与它无关的合并请求排队失败。 - 出错会怎样:最坏是这组测试之间互相影响而误报,只影响测试结果,可直接撤回。 - 要你做什么:无。 ## What changes `packages/plugins/plugin-approvals/src/flow-route.integration.test.ts`, the describe "[#38838] a fan-out to two approval steps is refused at publish" only: the kernel boot moves from inside each case (`await boot()` in cases 1, 2 and 4, `afterEach` shutdown) to one `beforeAll(() => boot(), 30_000)` with an `afterAll` shutdown. The now-unused `afterEach` import is dropped. The first case was paying a cold `kernel.bootstrap()` inside vitest's 5 s default and timed out on loaded CI shards (4,383 to 5,235 ms measured on CI). Asserted behaviour is unchanged. Sharing is safe, checked by reading: each case saves under its own flow name (`fan_out_active`, `fan_out_draft`, `fan_out_conditional`) and reads back only that name; the two refusals write nothing; the engine case uses no kernel; the control's publish is the one write, and no other case reads that row. The text of this describe is byte-identical to the same describe on PR #38970's branch (`git diff origin/claude/issue-38875-conditioned-edge-pause-drop` shows no hunk inside it), so merging main into #38970 after this lands is trivial. ## Tests <details><summary>Per-case timings, verbose reporter, shared box</summary> Main (`38ab473c3e`), before: - active save refused: 964 ms - draft save refused: 71 ms - engine refuses to register: 3 ms - CONTROL conditional fan-out publishes: 167 ms This branch, after (the boot now lands in `beforeAll`, outside every case's 5 s budget): - active save refused: 18 ms - draft save refused: 6 ms - engine refuses to register: 4 ms - CONTROL conditional fan-out publishes: 119 ms Whole file: 24/24 passed before and after. </details> <details><summary>Package suite and typecheck</summary> - `pnpm --filter @objectstack/plugin-approvals test`: Test Files 144 passed (144), Tests 2275 passed (2275) - `pnpm --filter @objectstack/plugin-approvals typecheck`: `check:test-typecheck: OK` </details> ## Acceptance notes - Changeset: none. The test file is not in the package's `files[]` output. Built JS dist: 0 hits for the test's own strings, positive control `ApprovalsServicePlugin` 2 hits. Label `skip-changeset`. - The local `plugin-approvals` build's DTS step failed on `@objectstack/spec/contracts` declarations (a spec dist state on this shared box). It does not touch this diff and the JS emit used for the grep above succeeded. ## Verification Read first: the describe's `beforeAll`/`afterAll` block (the only hunk that carries risk). Two-minute check: `pnpm --filter @objectstack/plugin-approvals exec vitest run --reporter=verbose src/flow-route.integration.test.ts` shows 24 passed, and the first #38838 case finishes in tens of milliseconds instead of about a second. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 57657df commit 202cc28

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎packages/plugins/plugin-approvals/src/flow-route.integration.test.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* both sides on purpose: the trunk is served unchanged.
4646
*/
4747

48-
import { describe, it, expect, beforeAll, beforeEach, afterAll, afterEach } from 'vitest';
48+
import { describe, it, expect, beforeAll, beforeEach, afterAll } from 'vitest';
4949
import { ObjectKernel } from '@objectstack/core';
5050
import { ObjectQL, ObjectQLPlugin } from '@objectstack/objectql';
5151
import { SqlDriver } from '@objectstack/driver-sql';
@@ -789,7 +789,13 @@ describe('[#38838] a fan-out to two approval steps is refused at publish', () =>
789789
let ql: ObjectQL;
790790
let protocol: any;
791791

792-
afterEach(async () => {
792+
// ONE kernel for the describe (#38976): a cold `kernel.bootstrap()` per case
793+
// pushed the first case past vitest's 5 s default on loaded CI shards. The
794+
// cases share it safely: each saves under its own flow name and reads back
795+
// only that name; the refusals write nothing, and the one write (the
796+
// control's publish) is a row no other case reads.
797+
beforeAll(() => boot(), 30_000);
798+
afterAll(async () => {
793799
try { await kernel?.shutdown(); } catch { /* noop */ }
794800
});
795801

@@ -815,7 +821,6 @@ describe('[#38838] a fan-out to two approval steps is refused at publish', () =>
815821
const LEAD = 'Node `start` fans out to concurrent branches that each reach a node that parks the run';
816822

817823
it('an active save is refused with 422 INVALID_METADATA, naming the fan-out and both branches', async () => {
818-
await boot();
819824
const err = await protocol.saveMetaItem({
820825
type: 'flow', name: 'fan_out_active', item: unconditionalFanOut('fan_out_active'), packageId: PKG,
821826
}).catch((e: any) => e);
@@ -829,7 +834,6 @@ describe('[#38838] a fan-out to two approval steps is refused at publish', () =>
829834
it('a draft save is refused too: the flow schema is judged at every save, a draft included', async () => {
830835
// Measured: the schema half of the door runs on a draft (only the author-time
831836
// lint waits for the promotion), so this never reaches the publish step.
832-
await boot();
833837
const err = await protocol.saveMetaItem({
834838
type: 'flow', name: 'fan_out_draft', item: unconditionalFanOut('fan_out_draft'), packageId: PKG, mode: 'draft',
835839
}).catch((e: any) => e);
@@ -846,7 +850,6 @@ describe('[#38838] a fan-out to two approval steps is refused at publish', () =>
846850
});
847851

848852
it('CONTROL: the conditional fan-out (one edge taken) publishes', async () => {
849-
await boot();
850853
const out = await protocol.saveMetaItem({
851854
type: 'flow', name: 'fan_out_conditional', item: conditionalFanOut('fan_out_conditional'), packageId: PKG,
852855
});

0 commit comments

Comments
 (0)