Skip to content

Commit a7c90a6

Browse files
authored
platform: data-driven selection tests for USJ <-> Lexical conversion (#456)
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.
1 parent 4e5f73b commit a7c90a6

File tree

16 files changed

+27642
-4
lines changed

16 files changed

+27642
-4
lines changed

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@
2525
"node_modules": true,
2626
"demos/platform/lib": true
2727
},
28+
// Exclude auto-generated Lexical state fixtures from SonarLint analysis
29+
"sonarlint.analysisExcludesStandalone": ["**/test-data/src/data/2sa.lexical.*.ts"],
2830
"typescript.tsdk": "node_modules/typescript/lib"
2931
}

demos/platform/src/app/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ interface Annotations {
4949

5050
const isTesting = process.env.NODE_ENV === "testing";
5151
const webUsj = usxStringToUsj(isTesting ? WEB_PSA_USX : WEB_PSA_CH1_USX);
52-
const editorUsj = webUsj; // isTesting ? webUsj : TJ_USJ;
52+
const editorUsj = webUsj; // isTesting ? webUsj : usj2Sa;
5353
const defaultScrRef: SerializedVerseRef = { book: "PSA", chapterNum: 1, verseNum: 1 };
5454
// Word "man" inside first q1 of PSA 1:1.
5555
const annotationRange1: AnnotationRange = {

libs/shared-react/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"quill-delta": "^5.1.0"
4545
},
4646
"devDependencies": {
47-
"shared": "workspace:~"
47+
"shared": "workspace:~",
48+
"test-data": "workspace:~"
4849
},
4950
"repository": {
5051
"type": "git",

libs/shared-react/src/plugins/usj/annotation/selection.utils.data-driven.test.ts

Lines changed: 557 additions & 0 deletions
Large diffs are not rendered by default.

libs/shared-react/tsconfig.lib.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
},
4646
{
4747
"path": "../shared/tsconfig.lib.json"
48+
},
49+
{
50+
"path": "../test-data/tsconfig.lib.json"
4851
}
4952
]
5053
}

libs/test-data/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
},
1818
"dependencies": {
1919
"@eten-tech-foundation/scripture-utilities": "workspace:~",
20+
"lexical": "^0.40.0",
2021
"tslib": "^2.8.1"
2122
}
2223
}

0 commit comments

Comments
 (0)