Skip to content

Commit 1eede9a

Browse files
imnasnainaecalex-rawlings-yyc
authored andcommitted
Use non-default book for test; Fix capitalization
1 parent db24eb3 commit 1eede9a

6 files changed

Lines changed: 25 additions & 29 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ The general file structure for an extension is as follows:
9999
- `*.web-view.tsx` files will be treated as React WebViews
100100
- `*.web-view.scss` files provide styles for WebViews
101101
- `*.web-view.html` files are a conventional way to provide HTML WebViews (no special functionality)
102-
- `src/__tests__/` contains unit tests (Jest) for the extension, including parser tests (valid and invalid XML, edge cases) and web-view tests
102+
- `src/__tests__/` contains unit tests (Jest) for the extension, including parser tests (valid and invalid XML, edge cases) and WebView tests
103103
- `__mocks__/` contains Jest mocks for the PAPI, file modules, and test fixtures used by tests in `src/__tests__/`. The `@papi/backend` and `@papi/frontend` mocks are used mutually exclusively (backend for main.ts tests, frontend for WebView tests); each mock file ends with `export {}` so TypeScript treats it as a module.
104104
- `assets/` contains asset files the extension and its WebViews can retrieve using the `papi-extension:` protocol, as well as textual descriptions in various languages. It is copied into the build folder
105105
- `assets/displayData.json` contains (optionally) a path to the extension's icon file as well as text for the extension's display name, short summary, and path to the full description file

src/__tests__/interlinearizer.web-view.test.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ describe('InterlinearizerWebView', () => {
6868
});
6969

7070
it('shows the book and projectId when a project is linked', () => {
71-
mockBookData({
72-
type: 'USJ',
73-
version: '3.1',
74-
content: [{ type: 'book', marker: 'id', code: 'GEN' }],
75-
});
71+
mockBookData({ type: 'USJ', version: '3.1', content: [] });
7672
render(<InterlinearizerWebView {...makeProps('test-project-id')} />);
7773

7874
expect(screen.getByText(/test-project-id/)).toBeInTheDocument();
@@ -100,11 +96,11 @@ describe('InterlinearizerWebView', () => {
10096
mockBookData({
10197
type: 'USJ',
10298
version: '3.1',
103-
content: [{ type: 'book', marker: 'id', code: 'GEN' }],
99+
content: [{ type: 'book', marker: 'id', code: 'EXO' }],
104100
});
105101
render(<InterlinearizerWebView {...makeProps('test-project-id')} />);
106102

107-
expect(screen.getByText(/"code": "GEN"/)).toBeInTheDocument();
103+
expect(screen.getByText(/"code": "EXO"/)).toBeInTheDocument();
108104
});
109105

110106
it('shows an error heading and message when book data is a PlatformError', () => {

src/__tests__/main.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ describe('main', () => {
264264
});
265265
});
266266

267-
it('reuses the webview ID on subsequent opens of the same project', async () => {
267+
it('reuses the WebView ID on subsequent opens of the same project', async () => {
268268
__mockOpenWebView.mockResolvedValue('saved-webview-id');
269269
const open = await getOpenHandler();
270270

@@ -332,7 +332,7 @@ describe('main', () => {
332332
);
333333
});
334334

335-
it('returns the webview ID when the webview opens successfully', async () => {
335+
it('returns the WebView ID when the WebView opens successfully', async () => {
336336
__mockOpenWebView.mockResolvedValue('new-webview-id');
337337
const open = await getOpenHandler();
338338

@@ -356,7 +356,7 @@ describe('main', () => {
356356
};
357357
}
358358

359-
it('looks up the projectId from the given webview and opens the interlinearizer', async () => {
359+
it('looks up the projectId from the given WebView and opens the Interlinearizer', async () => {
360360
__mockGetOpenWebViewDefinition.mockResolvedValue({
361361
id: 'some-webview',
362362
webViewType: 'someExtension.view',
@@ -375,7 +375,7 @@ describe('main', () => {
375375
);
376376
});
377377

378-
it('shows a project picker when the webview has no projectId', async () => {
378+
it('shows a project picker when the WebView has no projectId', async () => {
379379
__mockGetOpenWebViewDefinition.mockResolvedValue({
380380
id: 'some-webview',
381381
webViewType: 'someExtension.view',
@@ -393,7 +393,7 @@ describe('main', () => {
393393
);
394394
});
395395

396-
it('shows a project picker when the webview definition is not found', async () => {
396+
it('shows a project picker when the WebView definition is not found', async () => {
397397
__mockGetOpenWebViewDefinition.mockResolvedValue(undefined);
398398
__mockSelectProject.mockResolvedValue('picker-project');
399399
const openForWebView = await getOpenForWebViewHandler();
@@ -429,7 +429,7 @@ describe('main', () => {
429429
expect(__mockOpenWebView).not.toHaveBeenCalled();
430430
});
431431

432-
it('returns the webview ID when the interlinearizer opens successfully', async () => {
432+
it('returns the WebView ID when the Interlinearizer opens successfully', async () => {
433433
__mockGetOpenWebViewDefinition.mockResolvedValue({
434434
id: 'src-webview',
435435
webViewType: 'someExtension.view',
@@ -444,7 +444,7 @@ describe('main', () => {
444444
});
445445
});
446446

447-
describe('webview lifecycle event subscriptions', () => {
447+
describe('WebView lifecycle event subscriptions', () => {
448448
type WebViewEvent = (event: {
449449
webView: { webViewType: string; id: string; projectId?: string };
450450
}) => void;
@@ -458,7 +458,7 @@ describe('main', () => {
458458
expect(__mockOnDidCloseWebView).toHaveBeenCalledTimes(1);
459459
});
460460

461-
it('populates openWebViewsByProject when a matching webview opens', async () => {
461+
it('populates openWebViewsByProject when a matching WebView opens', async () => {
462462
const context = createTestActivationContext();
463463
await activate(context);
464464
const onOpen: WebViewEvent = __mockOnDidOpenWebView.mock.calls[0][0];
@@ -476,7 +476,7 @@ describe('main', () => {
476476
);
477477
});
478478

479-
it('ignores onDidOpenWebView events for other webview types', async () => {
479+
it('ignores onDidOpenWebView events for other WebView types', async () => {
480480
const context = createTestActivationContext();
481481
await activate(context);
482482
const onOpen: WebViewEvent = __mockOnDidOpenWebView.mock.calls[0][0];
@@ -512,7 +512,7 @@ describe('main', () => {
512512
);
513513
});
514514

515-
it('removes the entry from the map when the matching webview closes', async () => {
515+
it('removes the entry from the map when the matching WebView closes', async () => {
516516
__mockOpenWebView.mockResolvedValue('wv-close');
517517
const context = createTestActivationContext();
518518
await activate(context);
@@ -536,7 +536,7 @@ describe('main', () => {
536536
);
537537
});
538538

539-
it('does not remove the entry when a different webview ID closes for the same project', async () => {
539+
it('does not remove the entry when a different WebView ID closes for the same project', async () => {
540540
__mockOpenWebView.mockResolvedValue('wv-current');
541541
const context = createTestActivationContext();
542542
await activate(context);
@@ -559,7 +559,7 @@ describe('main', () => {
559559
);
560560
});
561561

562-
it('ignores onDidCloseWebView events for other webview types', async () => {
562+
it('ignores onDidCloseWebView events for other WebView types', async () => {
563563
__mockOpenWebView.mockResolvedValue('wv-other-type');
564564
const context = createTestActivationContext();
565565
await activate(context);

src/interlinearizer.web-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ globalThis.webViewComponent = function InterlinearizerWebView({
6363
<ProjectBookFetcher projectId={projectId} scrRef={scrRef} />
6464
) : (
6565
<p className="tw-text-sm tw-text-muted-foreground">
66-
Open this webview from a Paratext project to load its source book.
66+
Open this WebView from a Paratext project to load its source book.
6767
</p>
6868
)}
6969
</div>

src/main.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import interlinearizerReact from './interlinearizer.web-view?inline';
1010
import interlinearizerStyles from './interlinearizer.web-view.scss?inline';
1111

1212
/**
13-
* WebView type identifier for the interlinearizer. Used when registering the provider and when
13+
* WebView type identifier for the Interlinearizer. Used when registering the provider and when
1414
* opening the WebView from the platform.
1515
*/
1616
const mainWebViewType = 'interlinearizer.mainWebView';
@@ -20,16 +20,16 @@ export interface InterlinearizerOpenOptions extends OpenWebViewOptions {
2020
projectId?: string;
2121
}
2222

23-
/** WebView provider that provides the interlinearizer React WebView when Platform.Bible requests it. */
23+
/** WebView provider that provides the Interlinearizer React WebView when Platform.Bible requests it. */
2424
const mainWebViewProvider: IWebViewProvider = {
2525
/**
26-
* Returns the interlinearizer WebView definition (React component + styles) for the given saved
26+
* Returns the Interlinearizer WebView definition (React component + styles) for the given saved
2727
* definition. Rejects if the requested webViewType does not match this provider's type.
2828
*
2929
* @param savedWebView - Platform-provided definition (webViewType, etc.).
3030
* @param openWebViewOptions - Options passed by the caller; may include a projectId to link.
3131
* @returns WebView definition with title, content, and styles, or undefined.
32-
* @throws {Error} When savedWebView.webViewType is not the interlinearizer type.
32+
* @throws {Error} When savedWebView.webViewType is not the Interlinearizer type.
3333
*/
3434
async getWebView(
3535
savedWebView: SavedWebViewDefinition,
@@ -85,7 +85,7 @@ async function openInterlinearizer(projectId?: string): Promise<string | undefin
8585

8686
/**
8787
* Opens the Interlinearizer for the project associated with the given WebView. Called from the
88-
* webview context menu, which passes the tab's webView ID as the argument.
88+
* WebView context menu, which passes the tab's WebView ID as the argument.
8989
*/
9090
async function openInterlinearizerForWebView(webViewId?: string): Promise<string | undefined> {
9191
if (!webViewId) return openInterlinearizer();
@@ -94,7 +94,7 @@ async function openInterlinearizerForWebView(webViewId?: string): Promise<string
9494
}
9595

9696
/**
97-
* Extension entry point. Registers the interlinearizer WebView provider and the open command.
97+
* Extension entry point. Registers the Interlinearizer WebView provider and the open command.
9898
* Called by the platform when the extension is loaded.
9999
*
100100
* @param context - Activation context; used to register disposables so the platform can clean them

src/types/interlinearizer.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ declare module 'papi-shared-types' {
1212
'interlinearizer.open': (projectId?: string) => Promise<string | undefined>;
1313
/**
1414
* Opens the Interlinearizer for the project associated with the given WebView ID. Called from
15-
* webview context menus, which pass the tab's webView ID as the argument. Falls back to a
16-
* project picker dialog if the webView has no project or no ID is given.
15+
* WebView context menus, which pass the tab's WebView ID as the argument. Falls back to a
16+
* project picker dialog if the WebView has no project or no ID is given.
1717
*/
1818
'interlinearizer.openForWebView': (webViewId?: string) => Promise<string | undefined>;
1919
}

0 commit comments

Comments
 (0)