diff --git a/__mocks__/papi-frontend-react.ts b/__mocks__/papi-frontend-react.ts index e7f99bb6..8aea1ce2 100644 --- a/__mocks__/papi-frontend-react.ts +++ b/__mocks__/papi-frontend-react.ts @@ -62,6 +62,23 @@ const useLocalizedStrings = jest.fn().mockImplementation((keys: string[]) => [ false, ]); +/** + * Mock for `useSetting`. Returns `[defaultState, setSetting, resetSetting, false]`, passing + * `defaultState` through unchanged so callers receive a predictable initial value. + * + * @param _key - Ignored setting key. + * @param defaultState - Value surfaced as the current setting state. + * @returns Tuple of `[defaultState, jest.fn(), jest.fn(), false]`. + */ +const useSetting = jest + .fn() + .mockImplementation((_key: string, defaultState: unknown) => [ + defaultState, + jest.fn(), + jest.fn(), + false, + ]); + /** * Mock for `useRecentScriptureRefs`. Returns an empty history and a no-op `addRecentScriptureRef` * so components that display recent references render without errors. @@ -76,6 +93,7 @@ module.exports = { __esModule: true, useProjectData, useProjectSetting, + useSetting, useLocalizedStrings, useRecentScriptureRefs, }; diff --git a/__mocks__/platform-bible-react.tsx b/__mocks__/platform-bible-react.tsx index ba354760..3d1bd3e5 100644 --- a/__mocks__/platform-bible-react.tsx +++ b/__mocks__/platform-bible-react.tsx @@ -1,8 +1,6 @@ /** * @file Jest mock for platform-bible-react. The real package ships ESM which Jest cannot parse - * without extra transform configuration. This stub provides the subset used by extension - * components: `BookChapterControl`, `BOOK_CHAPTER_CONTROL_STRING_KEYS`, `TabToolbar`, and - * `ScrollGroupSelector`. + * without extra transform configuration. This stub provides the subset used by the extension. */ import type { ReactElement, ReactNode } from 'react'; diff --git a/src/__tests__/components/InterlinearizerLoader.test.tsx b/src/__tests__/components/InterlinearizerLoader.test.tsx index 4e422961..5be70998 100644 --- a/src/__tests__/components/InterlinearizerLoader.test.tsx +++ b/src/__tests__/components/InterlinearizerLoader.test.tsx @@ -2,7 +2,7 @@ /// /// -import { useLocalizedStrings } from '@papi/frontend/react'; +import { useLocalizedStrings, useSetting } from '@papi/frontend/react'; import type { SerializedVerseRef } from '@sillsdev/scripture'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; @@ -134,9 +134,11 @@ describe('InterlinearizerLoader', () => { mockBookData(); mockOptimisticSetting(); jest.mocked(useLocalizedStrings).mockReturnValue([{}, false]); + jest.mocked(useSetting).mockReturnValue(['simple', jest.fn(), jest.fn(), false]); }); - it('renders Interlinearizer and the nav controls when book data is available', () => { + it('shows nav controls when interface mode is power', () => { + jest.mocked(useSetting).mockReturnValue(['power', jest.fn(), jest.fn(), false]); render( { expect(screen.getByTestId('interlinearizer')).toBeInTheDocument(); }); + it('hides nav controls when interface mode is simple', () => { + render( + , + ); + + expect(screen.queryByTestId('scripture-nav-controls')).not.toBeInTheDocument(); + expect(screen.getByTestId('interlinearizer')).toBeInTheDocument(); + }); + it('shows Loading when book data has not arrived', () => { mockBookData({ book: undefined, isLoading: true }); render( diff --git a/src/components/InterlinearizerLoader.tsx b/src/components/InterlinearizerLoader.tsx index a3e8a1ec..56a011ec 100644 --- a/src/components/InterlinearizerLoader.tsx +++ b/src/components/InterlinearizerLoader.tsx @@ -1,5 +1,5 @@ import type { UseWebViewScrollGroupScrRefHook } from '@papi/core'; -import { useLocalizedStrings } from '@papi/frontend/react'; +import { useLocalizedStrings, useSetting } from '@papi/frontend/react'; import { TabToolbar } from 'platform-bible-react'; import { useMemo } from 'react'; import ContinuousScrollToggle from './ContinuousScrollToggle'; @@ -29,6 +29,8 @@ export default function InterlinearizerLoader({ }>) { const [scrRef, setScrRef, scrollGroupId, setScrollGroupId] = useWebViewScrollGroupScrRef(); + const [interfaceMode] = useSetting('platform.interfaceMode', 'simple'); + const { isLoading: isSettingLoading, onChange: handleContinuousScrollChange, @@ -51,12 +53,14 @@ export default function InterlinearizerLoader({ + interfaceMode === 'power' ? ( + + ) : undefined } endAreaChildren={