Skip to content

refactor(test): fold the section test mirror into test/sections - #402

Merged
Vivswan merged 1 commit into
mainfrom
wt/test-mirror-fold
Sep 22, 2026
Merged

Vivswan merged 1 commit into
mainfrom
wt/test-mirror-fold

Conversation

@Vivswan

@Vivswan Vivswan commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Before / After

before                                          after
test/                                           test/
  src/sections/labels/                            sections/
    labels.test.ts                                  contract.test.ts        (cross-section, stays flat)
    mock.ts                                         list-section.test.ts    (cross-section, stays flat)
    mock.test.ts                                    ...
    generators.ts                                   labels/
    scenarios/*.yml                                   labels.test.ts
  sections/                                           schema.test.ts        (was labels-schema.test.ts)
    labels-schema.test.ts                             mock.ts
    contract.test.ts                                  mock.test.ts
    list-section.test.ts                              generators.ts
    ...                                               scenarios/*.yml
$ git ls-files test/src | wc -l
0

How

  • 26 directory moves: test/src/sections/<key>/ to test/sections/<key>/; the test/src/ tree is gone.
  • 7 folds, all pure renames (no key directory already had a schema.test.ts, so no merge):
flat file in test/sections/ new home
check-suite-preferences-schema.test.ts check_suite_preferences/schema.test.ts
interaction-limits-schema.test.ts interaction_limits/schema.test.ts
labels-schema.test.ts labels/schema.test.ts
rulesets-schema.test.ts rulesets/schema.test.ts
secret-scanning-custom-patterns-schema.test.ts secret_scanning_custom_patterns/schema.test.ts
teams-schema.test.ts teams/schema.test.ts
webhooks-schema.test.ts webhooks/schema.test.ts
  • Import rewrite: moved files drop one ../ toward the repo root; sibling imports unchanged; ../../sections/x.js inside a key directory normalized to ../x.js. The folded suites gain one ../; the rulesets suite imports ./generators.js as a sibling.
  • Consumers, by group:
    • e2e harness importers: test/e2e/mock/sections.ts, state.ts, state.test.ts, server.test.ts, server-multi.test.ts, test/e2e/generators.ts, test/sections/list-section.test.ts.
    • path constants: the scenarioRoots default in test/e2e/schema.ts, test/schema-corpus.test.ts, test/sections/scenario-set.test.ts, the mock glob in test/e2e/foundation.test.ts.
    • messages and comments: the missing-handler pointer in test/e2e/mock/handlers.ts and its assertion in graphql-pipeline.test.ts; mock/support.ts, gen-support.ts.
    • prose: AGENTS.md, CONTRIBUTING.md, docs/reference/architecture.md (hand-written regions; no generated file embeds the path, bun run build:check is clean).
  • Selector rule (.github/scripts/changed-sections.ts):
test/sections/<key>/...              -> <key>
test/sections/<flat file>            -> none   (cross-section suites; unchanged from before this PR)
test/sections/snapshot-rows/...      -> none   (CROSS_SECTION_TEST_DIRS)
test/sections/labels.test.ts         -> throws (a flat file named after a section is misplaced)
test/sections/<key>_x.test.ts or <slug>_x.test.ts -> throws (interaction_limits_schema.test.ts, interaction-limits_schema.test.ts)
test/sections/labels-schema.test.ts  -> none when deleted (this PR's own --no-renames diff), throws when present
test/sections/<other dir>/...        -> throws

Proof

  • Static gates: typecheck, knip, lint, lint:arch, build:check all green; cross-model review converged clean.
  • Targeted tests: labels, branches, environments, scenario-set, schema-corpus, foundation, changed-sections, graphql-pipeline, state, generators suites: 534 pass, 0 fail (changed-sections alone: 42 pass).
  • e2e slice: bun run test:e2e --sections labels,environments: 100/100 passed.
  • Trap: injecting an e2e/constants.js import into test/sections/labels/mock.ts turned the foundation ban red naming that file; reverting turned it green.
  • Selector on this PR's own diff: bun .github/scripts/changed-sections.ts origin/main prints all and does not throw on the seven deleted flat suites.
Technical details
  • Line accounting by kind (git diff --stat -M origin/main...HEAD): 404 files, 384 renames. 299 renames are byte-identical (scenarios, mock.test.ts, and every file with no relative import to fix). 85 renames carry import-specifier edits only, +378/-381. 20 files modified in place, +160/-104: the selector and its tests +90/-29, the e2e harness importers and path constants +64/-69, prose +6/-6.
  • Reviewer note: the seven folds are pure renames plus one import line each; no merge was needed. The cross-section suites in test/sections/ stay flat on purpose. There is no compat path or fallback lookup under test/src/.
  • Selector guard: the old mirror root threw on any non-key path. The flat cross-section suites now share the root, so the successor guard is name-based: a flat file whose stem is a section key or its dashed slug, alone or before a dash or underscore, throws unless the record is a deletion. Misspelled flat names (e.g. lables-schema.test.ts) are recorded, not built.

BEGIN_COMMIT_OVERRIDE
refactor(test): fold the section test mirror into test/sections

The 26 per-section test directories move from test/src/sections// to test/sections//, so test/ mirrors src/ without a src segment, as test/engine already does.
The seven flat per-key schema suites in test/sections/ join their key directory as schema.test.ts, beside the branches precedent; none needed a merge.
Import specifiers inside the moved files drop one ../ toward the repo root, the folded suites gain one, and the rulesets schema suite now imports its generators as a sibling.
The e2e harness importers, the scenarioRoots default, the corpus and scenario-set path constants, the mock-fragment glob, and the missing-handler message all name the new root.
The changed-sections selector maps test/sections// to its section and keeps the flat cross-section suites and snapshot-rows selecting none as before.
It throws on any other directory and on a flat file whose stem is a section key or its dashed slug, alone or before a dash or underscore.
AGENTS.md, CONTRIBUTING.md, and the architecture reference name the new layout; no lookup under test/src remains.
END_COMMIT_OVERRIDE

Copilot AI balanced review requested due to automatic review settings September 22, 2026 03:14
@github-actions

Copy link
Copy Markdown
Contributor

File size check

0 over a hard cap (fails), 30 warning(s).

File Size Tier Cap
.github/scripts/release-pipeline.ts:6 156 chars warn 150
.github/scripts/release-pipeline.ts:477 151 chars warn 150
.github/scripts/release-pipeline.ts:1447 153 chars warn 150
.github/scripts/release-pipeline.ts:1 30 comment lines (header) warn 25
.github/scripts/release-pipeline.ts:473 14 comment lines warn 10
.github/workflows/post-green.yml:27 153 chars warn 150
.github/workflows/post-green.yml:140 16 comment lines warn 10
docs/upgrading/v2-to-v3.md 1257 lines warn 1040
src/engine/layers.ts:217 157 chars warn 150
src/flows/settings-write.ts:142 159 chars warn 150
src/flows/settings-write.ts:30 11 comment lines warn 10
src/flows/snapshot.ts:189 13 comment lines warn 10
src/github/secret-scan.ts:42 11 comment lines warn 10
src/schema.ts:186 153 chars warn 150
src/schema.ts:197 176 chars warn 150
src/sections/contract/errors.ts:14 14 comment lines warn 10
src/sections/contract/module.ts:963 185 chars warn 150
src/sections/contract/module.ts:627 12 comment lines warn 10
src/sections/contract/module.ts:897 12 comment lines warn 10
src/sections/secret_scanning_custom_patterns/compilable-form.ts:382 161 chars warn 150
src/sections/shared/roles.ts:43 13 comment lines warn 10
src/types.ts:16 156 chars warn 150
test/docs/guides.test.ts:451 155 chars warn 150
test/e2e/generators.ts 2633 lines warn 2560
test/e2e/generators.ts:1703 166 chars warn 150
test/e2e/generators.ts:1857 161 chars warn 150
test/e2e/generators.ts:1666 12 comment lines warn 10
test/engine/execute.test.ts:617 152 chars warn 150
test/flows/merge-parity.test.ts:63 164 chars warn 150
test/scripts/auto-fix-allowlist.test.ts:8 12 comment lines warn 10

Split the file, wrap the line, shorten or exempt the comment, or list the path in .file-size-allow.local with a # reason.

5 managed file(s) skipped; repo-platform owns them.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The relocation, import rewrites, consumers, documentation, and selector safeguards are consistent with no unresolved defects found.

Review effort: Balanced
Findings: None

What changed in this PR

Consolidates section-specific tests under test/sections/<key>/ while preserving test discovery and changed-section selection.

Changes:

  • Moves 26 section test trees and folds seven schema suites into their sections.
  • Rewrites imports, scenario roots, harness paths, and documentation.
  • Updates and tests changed-section selection for the consolidated layout.
File Description
.github/​scripts/​changed-sections.ts Supports the consolidated test layout and validates misplaced paths.
AGENTS.md Documents the new layout.
CONTRIBUTING.md Updates test-location guidance.
docs/​reference/​architecture.md Updates test links and architecture prose.
test/​e2e/​foundation.test.ts Updates the mock-fragment glob.
test/​e2e/​gen-support.ts Updates path documentation.
test/​e2e/​generators.ts Repoints generator imports.
test/​e2e/​mock/​graphql-pipeline.test.ts Updates the expected handler guidance.
test/​e2e/​mock/​handlers.ts Points missing handlers to the new location.
test/​e2e/​mock/​sections.ts Repoints all mock-fragment imports.
test/​e2e/​mock/​server-multi.test.ts Repoints the teams mock import.
test/​e2e/​mock/​server.test.ts Repoints the teams mock import.
test/​e2e/​mock/​state.test.ts Repoints the teams mock imports.
test/​e2e/​mock/​state.ts Repoints list mock imports.
test/​e2e/​mock/​support.ts Updates path documentation.
test/​e2e/​schema.ts Uses the new scenario root.
test/​schema-corpus.test.ts Discovers scenarios under the new root.
test/​scripts/​changed-sections.test.ts Covers the new selector behavior.
test/​sections/​list-section.test.ts Uses the relocated labels mock.
test/​sections/​scenario-set.test.ts Checks scenarios under the new root.
test/​sections/​actions/​** Relocates Actions tests, mocks, generators, and scenarios.
test/​sections/​actions_secrets/​** Relocates Actions secrets tests and fixtures.
test/​sections/​actions_variables/​** Relocates Actions variables tests and fixtures.
test/​sections/​agents_secrets/​** Relocates agents secrets tests and fixtures.
test/​sections/​agents_variables/​** Relocates agents variables tests and fixtures.
test/​sections/​autolinks/​** Relocates autolinks tests and fixtures.
test/​sections/​branches/​** Relocates branches tests and fixtures.
test/​sections/​check_suite_preferences/​** Relocates tests and folds the schema suite.
test/​sections/​code_quality_setup/​** Relocates code-quality tests and fixtures.
test/​sections/​code_scanning_default_setup/​** Relocates code-scanning tests and fixtures.
test/​sections/​codespaces_secrets/​** Relocates Codespaces secrets tests and fixtures.
test/​sections/​collaborators/​** Relocates collaborators tests and fixtures.
test/​sections/​custom_properties/​** Relocates custom-property tests and fixtures.
test/​sections/​dependabot_secrets/​** Relocates Dependabot secrets tests and fixtures.
test/​sections/​deploy_keys/​** Relocates deploy-key tests and fixtures.
test/​sections/​environments/​** Relocates environment tests and fixtures.
test/​sections/​interaction_limits/​** Relocates tests and folds the schema suite.
test/​sections/​labels/​** Relocates tests and folds the schema suite.
test/​sections/​milestones/​** Relocates milestone tests and fixtures.
test/​sections/​pages/​** Relocates Pages tests and fixtures.
test/​sections/​repository/​** Relocates repository tests and fixtures.
test/​sections/​rulesets/​** Relocates tests and folds the schema suite.
test/​sections/​secret_scanning_custom_patterns/​** Relocates tests and folds the schema suite.
test/​sections/​teams/​** Relocates tests and folds the schema suite.
test/​sections/​webhooks/​** Relocates tests and folds the schema suite.
test/​sections/​workflows/​** Relocates workflow tests and fixtures.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 22, 2026 04:04
@Vivswan
Vivswan force-pushed the wt/test-mirror-fold branch from 01c2379 to ec347c3 Compare September 22, 2026 04:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The selector misses dashed section slugs followed by an underscore, allowing affected tests to be skipped.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)

Comment thread .github/scripts/changed-sections.ts
Copilot AI review requested due to automatic review settings September 22, 2026 04:11
@Vivswan
Vivswan force-pushed the wt/test-mirror-fold branch from ec347c3 to 5e97dc7 Compare September 22, 2026 04:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The relocation is consistently applied, old-path references are removed, imports resolve, and selector behavior is comprehensively covered.

Review effort: Balanced
Findings: 1 High severity

Open (1)

@Vivswan
Vivswan marked this pull request as ready for review September 22, 2026 04:17
Copilot AI review requested due to automatic review settings September 22, 2026 06:55
@Vivswan
Vivswan force-pushed the wt/test-mirror-fold branch from 5e97dc7 to bb4e2c1 Compare September 22, 2026 06:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The relocation is consistently applied, stale paths are absent, and selector edge cases are covered.

Review effort: Balanced
Findings: None

Resolved since last review (1)

The 26 per-section test directories move from test/src/sections/<key>/ to test/sections/<key>/, so test/ mirrors src/ without a src segment, as test/engine already does.
The seven flat per-key schema suites in test/sections/ join their key directory as schema.test.ts, beside the branches precedent; none needed a merge.
Import specifiers inside the moved files drop one ../ toward the repo root, the folded suites gain one, and the rulesets schema suite now imports its generators as a sibling.
The e2e harness importers, the scenarioRoots default, the corpus and scenario-set path constants, the mock-fragment glob, and the missing-handler message all name the new root.
The changed-sections selector maps test/sections/<key>/ to its section and keeps the flat cross-section suites and snapshot-rows selecting none as before.
It throws on any other directory and on a flat file whose stem is a section key or its dashed slug, alone or before a dash or underscore.
AGENTS.md, CONTRIBUTING.md, and the architecture reference name the new layout; no lookup under test/src remains.
Copilot AI review requested due to automatic review settings September 22, 2026 09:11
@Vivswan
Vivswan force-pushed the wt/test-mirror-fold branch from bb4e2c1 to 7baf608 Compare September 22, 2026 09:11
@Vivswan Vivswan added the merge-when-green Owner approved: merge once every gate is green label Sep 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The relocation, consumers, selector safeguards, scenario discovery, and documentation are consistently updated with no unresolved defects found.

Review effort: Balanced
Findings: None

@Vivswan
Vivswan merged commit dc167bf into main Sep 22, 2026
33 checks passed
@Vivswan
Vivswan deleted the wt/test-mirror-fold branch September 22, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-when-green Owner approved: merge once every gate is green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants