Skip to content

finding(test-infra): CapabilityMultiSelectField.specParity-6285 resolves its source path against process.cwd(), so the package-level test script fails it — a FALSE RED that AGENTS.md says cannot happen #7791

Description

@os-sam

Found while verifying objectui#7747 (unrelated one-line change in packages/fields/src/index.tsx). Filed rather than fixed — out of that card's scope.

What happens

packages/fields/src/widgets/CapabilityMultiSelectField.specParity-6285.test.tsx reads the source it pins with the i18n gate's own readVocabulary, rooted at the process cwd:

packages/fields/src/widgets/CapabilityMultiSelectField.specParity-6285.test.tsx:96
const VOCABULARY_ROOT = '.';

The package-level test script leaves cwd at the package directory, not the repo root:

packages/fields/package.json → "test": "vitest run --root ../.. packages/fields/"

--root moves vitest's root back to the repo root, but it does not move process.cwd(). So the read resolves against packages/fields/ and misses.

Measured, one container, same tree, four invocations

invocation cwd result
pnpm exec vitest run packages/fields/ (repo root — the AGENTS.md canonical form, and CI) repo root 133 files / 2178 tests passed
pnpm exec vitest run ...specParity-6285.test.tsx (repo root, single file) repo root 7 passed (7)
pnpm --filter @object-ui/fields test packages/fields 1 file failed / 2 tests failed of 133 / 2178
cd packages/fields && pnpm exec vitest run --root ../.. ...specParity-6285.test.tsx (the package script's own form, isolated) packages/fields 2 failed / 5 passed (7)

The last row is the control: same file, same tree, and cwd is the only variable that changed — it reproduces the failure with nothing else moved.

The failure text names its own cause, which is how this was diagnosed:

Error: CURATED_CAPABILITY_LABELS is unreadable as a `set` in
packages/fields/src/widgets/CapabilityMultiSelectField.tsx — either the
declaration moved, was renamed, or was rewritten into a shape the i18n gate
cannot parse (which would silently downgrade `capability.label.` to a prefix
check), or this run's cwd is not the repo root and the file was never opened.

The third disjunct is the true one here. Two of the three read as a real regression in CapabilityMultiSelectField.tsx, so the failure invites a hunt for a defect that is not there.

Why this is worth a card

AGENTS.md (the 怎么跑测试 section) states:

pnpm --filter FIELD testturbo run test 现在是安全的(objectui#3240):每个包的 test 脚本都改成了显式指回仓根的 vitest run --root ../.. packages/FIELD/,跑的就是仓根那一份配置、和 CI 同一个结论

That claim does not hold for any test whose assertion reads the filesystem relative to cwd. objectui#3240 fixed vitest's root; it did not fix process.cwd(). The direction here is a false RED rather than objectui#3378's false GREEN, so it costs debugging time rather than coverage — but it also means the documented package-level form is not "和 CI 同一个结论", which is exactly what an agent is told it may rely on.

Two candidate fixes (not chosen here)

  1. Root the read at the test file, not at cwd — derive the repo root from import.meta.url (or import.meta.dirname plus ../../../..) and pass that as VOCABULARY_ROOT. Makes the pin invocation-independent, which is what it wanted; it is one line and touches only the test.
  2. Make the package test scripts also move cwd — so that vitest run --root ../.. packages/FIELD/ becomes a form that runs from the repo root. Fixes the whole class in one place, but touches 40-odd package.json files and is a devx-lane decision.

Fix 1 is the narrow one; whoever takes it should git grep "VOCABULARY_ROOT = '.'" first, since any sibling pin written from the same template has the same defect.

No assignee — PM triage.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions