Skip to content

platform: data-driven selection tests for USJ <-> Lexical conversion#456

Merged
irahopkinson merged 1 commit intomainfrom
data-tests
Mar 9, 2026
Merged

platform: data-driven selection tests for USJ <-> Lexical conversion#456
irahopkinson merged 1 commit intomainfrom
data-tests

Conversation

@irahopkinson
Copy link
Copy Markdown
Collaborator

@irahopkinson irahopkinson commented Mar 5, 2026

Add 612 data-driven tests (136 USJ locations x 3 marker modes + round-trips) for selection resolution and round-trip conversion between USJ document locations and Lexical editor selections.

Test data:

  • 2sa.usj-locations.ts: 136 location entries adapted from paranext-core's testUSFM-2SA-1-locations.ts covering all 7 UsjDocumentLocation subtypes
  • 2sa.lexical.{editable,visible,hidden}.ts: pre-generated serialized Lexical editor states for usj2Sa in each marker mode

Known implementation gaps are tracked with expect(() => ...).toThrow() inside regular it() tests so they stay visible without breaking CI or the VS Code test explorer. When a gap is fixed the toThrow() assertion fails, prompting removal of the entry from the KNOWN_*_GAPS set.

Generation:

  • generate-2sa-lexical-states.test.ts guarded by GENERATE_TEST_DATA env var (skipped during normal nx test runs)
  • pnpm generate:test-data in packages/platform to regenerate fixtures

Also adds test-data as a devDependency of shared-react and excludes the auto-generated Lexical state fixtures from SonarLint analysis.


Open with Devin

This change is Reviewable

@codesandbox
Copy link
Copy Markdown

codesandbox bot commented Mar 5, 2026

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

Add 612 data-driven tests (136 USJ locations x 3 marker modes + round-trips)
for selection resolution and round-trip conversion between USJ document
locations and Lexical editor selections.

Test data:
- 2sa.usj-locations.ts: 136 location entries adapted from paranext-core's
  testUSFM-2SA-1-locations.ts covering all 7 UsjDocumentLocation subtypes
- 2sa.lexical.{editable,visible,hidden}.ts: pre-generated serialized Lexical
  editor states for `usj2Sa` in each marker mode

Known implementation gaps are tracked with `expect(() => ...).toThrow()`
inside regular `it()` tests so they stay visible without breaking CI or
the VS Code test explorer. When a gap is fixed the `toThrow()` assertion
fails, prompting removal of the entry from the KNOWN_*_GAPS set.

Generation:
- generate-2sa-lexical-states.test.ts guarded by GENERATE_TEST_DATA env var
  (skipped during normal nx test runs)
- pnpm generate:test-data in packages/platform to regenerate fixtures

Also adds test-data as a devDependency of shared-react and excludes the
auto-generated Lexical state fixtures from SonarLint analysis.
Copy link
Copy Markdown
Contributor

@tjcouch-sil tjcouch-sil left a comment

Choose a reason for hiding this comment

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

Very nice!! Just one question about the tests.

@tjcouch-sil
Copy link
Copy Markdown
Contributor

Thanks! Merge when ready

@irahopkinson irahopkinson merged commit a7c90a6 into main Mar 9, 2026
6 checks passed
@irahopkinson irahopkinson deleted the data-tests branch March 9, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants