Skip to content

test: collocate primitives tests and add BDD steps to OpenSpec tests#39

Open
stevenobiajulu wants to merge 3 commits intomainfrom
test/collocate-and-bdd-enrich
Open

test: collocate primitives tests and add BDD steps to OpenSpec tests#39
stevenobiajulu wants to merge 3 commits intomainfrom
test/collocate-and-bdd-enrich

Conversation

@stevenobiajulu
Copy link
Copy Markdown
Member

Summary

  • Collocate tests: Move all 34 test files from packages/docx-core/test-primitives/ into packages/docx-core/src/primitives/ so tests live next to the code they exercise. Eliminates the test-primitives/ directory entirely.
  • BDD enrichment: Add allureStep Given/When/Then calls to all 18 OpenSpec test files (across docx-core and docx-mcp) so Allure reports show visible BDD steps instead of "No test steps information available."
  • Fix duplicate label: Rename duplicate .openspec('Building footnote mapping')'Building footnote mapping preserves document order'
  • Lint fixes: Remove unused imports and add non-null assertions to satisfy TypeScript strict mode after the move.

What changed

Area Detail
test-primitives/src/primitives/ 34 files moved via git mv, preserving rename history
src/primitives/testing/allure-test.ts New helper with defaultEpic: 'DOCX Primitives'
vitest.config.ts / vitest.baseline.config.ts packageNameOverrides updated to key on src/primitives
validate_primitives_openspec_coverage.mjs TEST_ROOT updated to src/primitives
18 OpenSpec test files Added allureStep BDD steps to all .openspec() tests
normalization.test.ts Deleted (content previously merged into merge_runs.test.ts + simplify_redlines.test.ts)

Verification

  • validate_allure_test_quality.mjs --strict: 0 errors
  • check:spec-coverage --strict: all scenarios covered
  • npm run lint:workspaces: 0 TypeScript errors
  • docx-core: 792 pass, 1 skip | docx-mcp: 611 pass

Test plan

  • npm run build passes
  • npm run lint:workspaces — 0 errors
  • npx vitest run in docx-core — 793 tests pass
  • npx vitest run in docx-mcp — 611 tests pass
  • npm run check:spec-coverage -w @usejunior/docx-core -- --strict — all covered
  • node scripts/validate_allure_test_quality.mjs --strict — 0 errors
  • test-primitives/ directory no longer exists

…ntation

Move all 34 test files from packages/docx-core/test-primitives/ into
packages/docx-core/src/primitives/ so tests live alongside the code they
exercise. This eliminates the test-primitives/ directory entirely.

Key changes:
- Create src/primitives/testing/allure-test.ts with defaultEpic 'DOCX Primitives'
- Move 21 direct 1:1 test files with import path updates
- Move 7 suffixed test files (.branch, .traceability) preserving suffixes
- Rename delete_comment.test.ts → comments.delete.test.ts
- Rename insert_paragraph_style_source.traceability.test.ts → document.traceability.test.ts
- Split normalization.test.ts: mergeRuns tests → merge_runs.test.ts, simplifyRedlines tests → simplify_redlines.test.ts
- Split document_view_formatting.test.ts: computeModalBaseline tests → formatting_tags.test.ts, remainder → document_view.formatting.test.ts
- Merge test-primitives/comments.test.ts into existing src/primitives/comments.test.ts
- Merge unique UNSAFE_CONTAINER_BOUNDARY test from test-primitives/text.test.ts
- Update vitest.config.ts and vitest.baseline.config.ts packageNameOverrides
- Update validate_primitives_openspec_coverage.mjs TEST_ROOT and matrix path
- Update existing src/primitives tests to use primitives allure helper
- Delete test-primitives/ directory, helpers, and setup files

All 805 tests pass (804 + 1 skip). Spec coverage: 41/41 canonical scenarios.
- Add allureStep Given/When/Then calls to all 18 OpenSpec test files
  across docx-core and docx-mcp so Allure reports show visible BDD steps
- Fix duplicate .openspec() label: 'Building footnote mapping' →
  'Building footnote mapping preserves document order'
- Delete stale normalization.test.ts (content merged into
  merge_runs.test.ts and simplify_redlines.test.ts in prior commit)

validate_allure_test_quality.mjs --strict: 0 errors
docx-core: 804 pass, 1 skip | docx-mcp: 611 pass
…iles

Fix unused imports (itAllure, FontBaseline, serializeXml, W, getBody)
and add non-null assertions for array access in test assertions to
satisfy strict TypeScript checking after test collocation.
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
site Ready Ready Preview, Comment Mar 7, 2026 5:56pm

Request Review

@github-actions github-actions bot added the test label Mar 7, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant