Skip to content

Commit 2334608

Browse files
Update Jest configuration and enhance interlinearizer WebView functionality
- Modify Jest configuration to adjust file patterns for test exclusions, ensuring proper test coverage. - Update interlinearizer WebView to reference the correct XML files for testing, improving accuracy in unit tests. - Revise README to reflect changes in the file structure and clarify the usage of test data paths. - Refactor imports in the interlinearizer WebView for consistency and clarity, aligning with updated parser structure.
1 parent e2337c2 commit 2334608

24 files changed

+3414
-6051
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ The general file structure for an extension is as follows:
9696
- `src/main.ts` is the main entry file for the extension (registers commands and wires interlinear XML)
9797
- `src/types/interlinearizer.d.ts` is this extension's types file that defines how other extensions can use this extension through the `papi`. It is copied into the build folder
9898
- `src/types/` also holds shared enums and type modules (e.g. `interlinearizer-enums.ts`). Use the path alias `types/interlinearizer-enums` in imports instead of relative paths (see `tsconfig.json` paths).
99-
- `src/parsers/` contains all parsers and converters used when importing external data models sorted by source (e.g. Paratext 9 XML Files). Use the path alias `parsers/...` in imports instead of relative paths (see `tsconfig.json` paths).
99+
- `src/parsers/` contains all parsers and converters used when importing external data models, one directory per source (e.g. `paratext-9/`). Use the path alias `parsers/...` in imports instead of relative paths (see `tsconfig.json` paths). **Naming:** the program/source is identified only by the directory name (full name, kebab-case). Files inside each directory use generic names (e.g. `converter.ts`, `interlinearParser.ts`, `types.ts`, `lexiconParser.ts`); exported symbols use the full program name (e.g. `Paratext9Parser`, `convertParatext9ToInterlinearization`).
100100
- `*.web-view.tsx` files will be treated as React WebViews
101101
- `*.web-view.scss` files provide styles for WebViews
102102
- `*.web-view.html` files are a conventional way to provide HTML WebViews (no special functionality)
@@ -108,7 +108,7 @@ The general file structure for an extension is as follows:
108108
- `assets/descriptions/description-<locale>.md` contains a brief description of the extension in the language specified by `<locale>`
109109
- `contributions/` contains JSON files the platform uses to extend data structures for things like menus and settings. The JSON files are referenced from the manifest
110110
- `public/` contains other static files that are copied into the build folder
111-
- `test-data/` contains sample interlinear XML (e.g. `Interlinear_en_MAT.xml`) for development and tests. In tests, resolve paths via `getTestDataPath('Interlinear_en_MAT.xml')` from `src/__tests__/test-helpers`.
111+
- `test-data/` contains sample interlinear XML (e.g. `Interlinear_en_JHN.xml`) and Lexicon XML (e.g. `Lexicon.xml`) for development and tests. In tests, resolve paths via `getTestDataPath('Interlinear_en_JHN.xml')` (or `getTestDataPath('Lexicon.xml')`) from `src/__tests__/test-helpers`. Interlinear XML aligns **source** words/WordParses; Lexicon XML is the **target** (gloss) language. Word-level gloss is resolved in the **converter** from Lexicon entries (e.g. `Word:surfaceForm`); the webview Gloss row displays only that data (no surfaceText fallback).
112112
- `.github/` contains files to facilitate integration with GitHub
113113
- `.github/workflows` contains [GitHub Actions](https://github.com/features/actions) workflows for automating various processes in this repo (e.g. **Test** and **Lint** on push/PR to main, release-prep, hotfix-\*; **Publish** and **Bump Versions** manual dispatch; **CodeQL** for security)
114114
- `.github/assets/release-body.md` combined with a generated changelog becomes the body of [releases published using GitHub Actions](#publishing)
@@ -121,7 +121,7 @@ The general file structure for an extension is as follows:
121121

122122
### Requirements
123123

124-
- **Node.js >= 18** is required. The test suite uses the Web Crypto API (`globalThis.crypto.subtle`) for hashing in `paratext9Converter` tests (e.g. the `sha256HexWebCrypto` path in `src/__tests__/parsers/paratext-9/paratext9Converter.test.ts` when `convertParatext9ToInterlinearization` is called without the `hashSha256Hex` option). Node 18+ provides this API; older versions will cause those tests to fail. The same requirement is enforced in `package.json` via `engines.node` and is used by CI.
124+
- **Node.js >= 18** is required. The test suite uses the Web Crypto API (`globalThis.crypto.subtle`) for hashing in the paratext-9 converter tests (e.g. the `sha256HexWebCrypto` path in `src/__tests__/parsers/paratext-9/converter.test.ts` when `convertParatext9ToInterlinearization` is called without the `hashSha256Hex` option). Node 18+ provides this API; older versions will cause those tests to fail. The same requirement is enforced in `package.json` via `engines.node` and is used by CI.
125125

126126
### Install dependencies:
127127

__mocks__/interlinearXmlContent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
2-
* @file Jest mock for webpack ?raw XML import. Exports the contents of test-data/Interlinear_en_MAT.xml
2+
* @file Jest mock for webpack ?raw XML import. Exports the contents of test-data/Interlinear_en_JHN.xml
33
* so interlinearizer.web-view.tsx can parse it in unit tests without webpack.
44
*/
55
import fs from 'fs';
66
import path from 'path';
77

8-
const xmlPath = path.join(__dirname, '..', 'test-data', 'Interlinear_en_MAT.xml');
8+
const xmlPath = path.join(__dirname, '..', 'test-data', 'Interlinear_en_JHN.xml');
99
module.exports = fs.readFileSync(xmlPath, 'utf-8');

jest.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const config: Config = {
2727
'src/parsers/**/*.ts',
2828
'src/main.ts',
2929
'src/**/*.web-view.tsx',
30-
'!src/parsers/**/*-types.ts',
30+
'!src/parsers/**/types.ts',
3131
'!src/**/__tests__/**',
3232
'!src/**/*.test.{ts,tsx}',
3333
'!src/**/*.spec.{ts,tsx}',
@@ -94,7 +94,7 @@ const config: Config = {
9494
/** Resolve webpack ?inline imports: SCSS content. */
9595
'^(.+)\\.(scss|sass|css)\\?inline$': '<rootDir>/__mocks__/styleInlineMock.ts',
9696
/** Resolve webpack ?raw import for test XML in web-view. */
97-
'^(.+)/Interlinear_en_MAT\\.xml\\?raw$': '<rootDir>/__mocks__/interlinearXmlContent.ts',
97+
'^(.+)/Interlinear_en_JHN\\.xml\\?raw$': '<rootDir>/__mocks__/interlinearXmlContent.ts',
9898
/** Resolve webpack ?raw import for Lexicon XML in web-view. */
9999
'^(.+)/Lexicon\\.xml\\?raw$': '<rootDir>/__mocks__/lexiconXmlContent.ts',
100100
},

0 commit comments

Comments
 (0)