Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
{
"allowTestingFrameworkSetupHook": "beforeEach"
}
]
],
"testing-library/prefer-find-by": "off"
}
}
22 changes: 15 additions & 7 deletions __tests__/integration/mirador/tests/annotations.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest';
import { screen, fireEvent, within } from '@testing-library/react';
import { screen, fireEvent } from '@testing-library/react';
import { setupIntegrationTestViewer } from '@tests/utils/test-utils';
import config from '../mirador-configs/single-van-gogh';

Expand All @@ -13,7 +13,7 @@
setupIntegrationTestViewer(config);

it('Loads the manifest', async () => {
const element = await screen.findByRole('region', { name: /Window: Self-Portrait Dedicated to Paul Gauguin/i });
const element = await screen.findByLabelText(/Window: Self-Portrait Dedicated to Paul Gauguin/i);
expect(element).toBeInTheDocument();
});

Expand All @@ -40,17 +40,25 @@
const annotationButtons = await screen.findAllByLabelText(/annotations/i);
fireEvent.click(annotationButtons[0]);

expect(await screen.findByRole('heading', { name: 'Annotations' })).toBeInTheDocument();

Check failure on line 43 in __tests__/integration/mirador/tests/annotations.test.js

View workflow job for this annotation

GitHub Actions / build (22.x)

__tests__/integration/mirador/tests/annotations.test.js > Annotations in Mirador > renders annotation in a companion window/sidebar panel

TestingLibraryElementError: Unable to find role="heading" and name "Annotations" Ignored nodes: comments, script, style <body class="" style="padding-right: 1024px; overflow: hidden;" > <div aria-hidden="true" > <div data-testid="test-mirador" style="bottom: 0px; left: 0px; position: absolute; right: 0px; top: 0px;" > <div class="fullscreen" > <div class="mui-rvh6fe-WorkspaceArea-root" > <nav aria-label="Workspace navigation" class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation4 MuiAppBar-root MuiAppBar-colorDefault MuiAppBar-positionAbsolute mirador-workspace-control-panel mui-1n12hsf-MuiPaper-root-MuiAppBar-root-WorkspaceControlPanel-root" style="--Paper-shadow: 0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12);" > <div class="MuiToolbar-root MuiToolbar-regular mui-1seisq0-MuiToolbar-root-WorkspaceControlPanel-toolbar" > <button aria-label="Add resource" class="MuiButtonBase-root MuiFab-root MuiFab-circular MuiFab-sizeMedium MuiFab-primary MuiFab-root MuiFab-circular MuiFab-sizeMedium MuiFab-primary mui-1vcfsyx-MuiButtonBase-root-MuiFab-root-WorkspaceAddButton-root" data-mui-internal-clone-element="true" id="addBtn" tabindex="0" type="button" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium mui-1umw9bq-MuiSvgIcon-root" data-testid="AddSharpIcon" focusable="false" viewBox="0 0 24 24" > <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z" /> </svg> </button> <div class="mui-j0aotr-WorkspaceControlPanel-buttonArea" > <button aria-haspopup="true" aria-label="Jump to window" class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeLarge mui-12lzbui-MuiButtonBase-root-MuiIconButton-root-MiradorMenuButton-root" data-mui-internal-clone-element="true" tabindex="0" type="button" > <span class="MuiBadge-root mui-1k55d3o-MuiBadge-root" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium mui-1umw9bq-MuiSvgIcon-root" data-testid="BookmarksSharpIcon" focusable="false" viewBox="0 0 24 24" > <path d="m19 18 2 1V1H7v2h12zM17 5H3v18l7-3 7 3z" /> </svg> <span class="MuiBadge-badge MuiBadge-standard MuiBadge-anchorOriginTopRight MuiBadge-anchorOriginTopRightRectangular MuiBadge-overlapRectangular mui-2ao5rv-MuiBadge-badge" > 1 </span> </span> </button> <button aria-haspopup="true" aria-label="Workspace settings" class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeLarge mui-12lzbui-MuiButtonBase-root-MuiIconButton-root-MiradorMenuButton-root" data-mui-internal-clone-element="true" id="menuBtn" tabindex="0" type="button" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium mui-1umw9bq-MuiSvgIcon-root" data-testid="SettingsSharpIcon" focusable="false"

// Re. this regex: be sure that the number of annotations starts with a non zero digit
const annoCountSubtitle = await screen.findByText(/Showing [1-9]\d* annotations/);
expect(annoCountSubtitle).toBeInTheDocument();
const annotationCount = annoCountSubtitle.innerText.match(/\d+/)[0];
const annotationCount = annoCountSubtitle.textContent.match(/\d+/)[0];

const annotationPanel = await screen.findByRole('complementary', { name: /annotations/i });
expect(annotationPanel).toBeInTheDocument();
// NOTE: findByRole was causing mysterious failures so we are using querySelector
// for the rest of this test.
/* eslint-disable testing-library/no-node-access */
const annotationPanel = annoCountSubtitle.closest('aside');
const menu = annotationPanel.querySelector('[role="menu"]');

const listItems = await within(annotationPanel).findAllByRole('menuitem');
expect(listItems).toHaveLength(annotationCount);
// Find all menu items
const listItems = menu.querySelectorAll('[role="menuitem"]');
/* eslint-enable testing-library/no-node-access */

// Convert annotationCount (likely a string) to number
const expectedCount = Number(annotationCount);
expect(listItems.length).toBe(expectedCount);
});
});
2 changes: 1 addition & 1 deletion __tests__/integration/mirador/tests/minimalist.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
setupIntegrationTestViewer(config);

it('Loads a manifest and displays it without some of the default controls', async () => {
expect(await screen.findByRole('region', { name: /Window: Self-Portrait Dedicated to Paul Gauguin/i })).toBeInTheDocument();
expect(await screen.findByLabelText(/Window: Self-Portrait Dedicated to Paul Gauguin/i)).toBeInTheDocument();

const infoButton = await screen.findByRole('tab', { name: /Information/i });

Check failure on line 12 in __tests__/integration/mirador/tests/minimalist.test.js

View workflow job for this annotation

GitHub Actions / build (22.x)

__tests__/integration/mirador/tests/minimalist.test.js > Minimalist configuration to Mirador > Loads a manifest and displays it without some of the default controls

TestingLibraryElementError: Unable to find role="tab" and name `/Information/i` Ignored nodes: comments, script, style <body style="padding-right: 1024px; overflow: hidden;" > <div aria-hidden="true" > <div data-testid="test-mirador" style="bottom: 0px; left: 0px; position: absolute; right: 0px; top: 0px;" > <div class="fullscreen" > <div class="mui-rvh6fe-WorkspaceArea-root" > <main aria-label="Workspace" class="mirador-viewer mui-sb9can-WorkspaceArea-viewer" lang="en" > <div style="height: 100%; width: 100%;" > <div class="mirador-workspace-viewport mui-xu2fmc-Workspace-root" > <h1 class="MuiTypography-root MuiTypography-body1 mui-11ym71c-MuiTypography-root" style="border: 0px; height: 1px; margin: -1px; overflow: hidden; padding: 0px; position: absolute; white-space: nowrap; width: 1px;" > Mirador viewer </h1> <section aria-label="Window: Self-Portrait Dedicated to Paul Gauguin" class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 mirador-window mui-zkerac-MuiPaper-root-Window-root" data-testid="test-region" id="window-5b8cf8c5-9df0-4243-b560-e8ef473fdcef" style="--Paper-shadow: 0px 2px 1px -1px rgba(0,0,0,0.2),0px 1px 1px 0px rgba(0,0,0,0.14),0px 1px 3px 0px rgba(0,0,0,0.12);" > <nav aria-label="Window navigation" class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation4 MuiAppBar-root MuiAppBar-colorDefault MuiAppBar-positionRelative mui-1wz88s1-MuiPaper-root-MuiAppBar-root-WindowTopBar-root" style="--Paper-shadow: 0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12);" > <div class="MuiToolbar-root MuiToolbar-dense mirador-window-top-bar mui-155iw2x-MuiToolbar-root-WindowTopBar-toolbar" > <h2 class="MuiTypography-root MuiTypography-h2 MuiTypography-noWrap mui-13lc6qn-MuiTypography-root" > Self-Portrait Dedicated to Paul Gauguin </h2> <button aria-haspopup="true" aria-label="Window views & thumbnail display" class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeLarge mui-12lzbui-MuiButtonBase-root-MuiIconButton-root-MiradorMenuButton-root" data-mui-internal-clone-element="true" tabindex="0" type="button" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium mui-xbcal6-MuiSvgIcon-root" focusable="false" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" > <path d="M0,0H24V24H0Z" fill="none" /> <path d="M24.852,17.981,3,18V15.945l21.852-.019Z" transform="translate(-2 5)" /> <path d="M1,4V21H22.853V4.1ZM3,19V6h8V19Zm18,0H13V6h8Z" transform="translate(0 -2)" /> </svg> </button> <button
expect(infoButton).toBeInTheDocument();
const rightsButton = await screen.findByRole('tab', { name: /Rights/i });
expect(rightsButton).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ describe('Canvas navigation by clicking thumbnails', () => {
/* eslint-disable */
it.skip('navigates a manifest using thumbnail navigation', async (context) => {
// Make sure we have the manifest
const windowElement = await screen.findByRole('region', { name: /Window: Bodleian Library MS. Ind. Inst. Misc. 22/i });
const windowElement = await screen.findByLabelText(/Window: Bodleian Library MS. Ind. Inst. Misc. 22/i);

expect(windowElement).toBeInTheDocument();

const windowId = windowElement.getAttribute('id');
Expand Down
2 changes: 1 addition & 1 deletion __tests__/integration/mirador/tests/viewer-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('initialViewerConfig', () => {

describe('initialViewerConfig', () => {
it('allows initialViewerConfig to be passed', async (context) => {
expect(await screen.findByRole('region', { name: /Window: Self-Portrait Dedicated to Paul Gauguin/i })).toBeInTheDocument();
expect(await screen.findByLabelText(/Window: Self-Portrait Dedicated to Paul Gauguin/i)).toBeInTheDocument();

let viewerObject;
await waitFor(() => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/integration/mirador/tests/window-actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
setupIntegrationTestViewer(config);

it('Closes a Mirador window', async () => {
expect(await screen.findByRole('region', { name: /Window: Self-Portrait Dedicated to Paul Gauguin/i })).toBeInTheDocument();
expect(await screen.findByLabelText(/Window: Self-Portrait Dedicated to Paul Gauguin/i)).toBeInTheDocument();
const closeButton = screen.getByRole('button', { name: /Close window/i });

Check failure on line 11 in __tests__/integration/mirador/tests/window-actions.test.js

View workflow job for this annotation

GitHub Actions / build (22.x)

__tests__/integration/mirador/tests/window-actions.test.js > Window actions > Closes a Mirador window

TestingLibraryElementError: Unable to find an accessible element with the role "button" and name `/Close window/i` Here are the accessible roles: presentation: Name "": <div class="MuiDialog-root MuiModal-root mui-1424xw8-MuiModal-root-MuiDialog-root" id="error-dialog" role="presentation" /> Name "": <div class="MuiDialog-container MuiDialog-scrollPaper mui-19do60a-MuiDialog-container" role="presentation" style="opacity: 1; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;" tabindex="-1" /> -------------------------------------------------- dialog: Name "An error occurred": <div aria-labelledby="error-dialog-title" aria-modal="true" class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthSm mui-10d30g3-MuiPaper-root-MuiDialog-paper" role="dialog" style="--Paper-shadow: 0px 11px 15px -7px rgba(0,0,0,0.2),0px 24px 38px 3px rgba(0,0,0,0.14),0px 9px 46px 8px rgba(0,0,0,0.12);" /> -------------------------------------------------- heading: Name "An error occurred": <h2 class="MuiTypography-root MuiTypography-h6 MuiDialogTitle-root mui-1tc9yoq-MuiTypography-root-MuiDialogTitle-root" id="error-dialog-title" /> -------------------------------------------------- paragraph: Name "": <p class="MuiTypography-root MuiDialogContentText-root MuiTypography-body2 MuiTypography-noWrap MuiDialogContentText-root mui-8i6a47-MuiTypography-root-MuiDialogContentText-root" /> -------------------------------------------------- button: Name "OK": <button class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary mui-1pwtsp5-MuiButtonBase-root-MuiButton-root" tabindex="0" type="button" /> -------------------------------------------------- Ignored nodes: comments, script, style <body style="padding-right: 1024px; overflow: hidden;" > <div aria-hidden="true" > <div data-testid="test-mirador" style="bottom: 0px; left: 0px; position: absolute; right: 0px; top: 0px;" > <div class="fullscreen" > <div class="mui-rvh6fe-WorkspaceArea-root" > <nav aria-label="Workspace navigation" class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation4 MuiAppBar-root MuiAppBar-colorDefault MuiAppBar-positionAbsolute mirador-workspace-control-panel mui-1n12hsf-MuiPaper-root-MuiAppBar-root-WorkspaceControlPanel-root" style="--Paper-shadow: 0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12);" > <div class="MuiToolbar-root MuiToolbar-regular mui-1seisq0-MuiToolbar-root-WorkspaceControlPanel-toolbar" > <button aria-label="Add resource" class="MuiButtonBase-root MuiFab-root MuiFab-circular MuiFab-sizeMedium MuiFab-primary MuiFab-root MuiFab-circular MuiFab-sizeMedium MuiFab-primary mui-1vcfsyx-MuiButtonBase-root-MuiFab-root-WorkspaceAddButton-root" data-mui-internal-clone-element="true" id="addBtn" tabindex="0" type="button" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium mui-1umw9bq-MuiSvgIcon-root" data-testid="AddSharpIcon" focusable="false" viewBox="0 0 24 24" > <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z" /> </svg> </button> <div class="mui-j0aotr-WorkspaceControlPanel-buttonArea" >
fireEvent.click(closeButton);
await waitFor(() => expect(screen.queryByRole('region', { name: /Window: Self-Portrait Dedicated to Paul Gauguin/i })).not.toBeInTheDocument());

Expand Down
8 changes: 2 additions & 6 deletions __tests__/utils/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const setupMiradorViewer = async (config, plugins) => {

render(
<div
data-testid="mirador"
data-testid="test-mirador"
style={{
bottom: 0, left: 0, position: 'absolute', right: 0, top: 0,
}}
Expand All @@ -85,11 +85,7 @@ export const setupIntegrationTestViewer = (config, plugins) => {
context.miradorInstance = miradorInstance;

// Wait for the viewer to render
expect(await screen.findByTestId('mirador')).toBeInTheDocument();
expect(await screen.findByTestId('test-mirador')).toBeInTheDocument();
expect(await screen.findByLabelText('Workspace')).toBeInTheDocument();

if ((config.windows || []).length > 0) {
await screen.findAllByRole('region', { name: /Window:/i });
}
});
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"lint:translations": "node ./scripts/i18n-lint.js",
"size": "bundlewatch --config bundlewatch.config.json",
"start": "vite",
"test": "npm run build && npm run lint && npm run size && vitest run"
"test": "npm run build && npm run lint && npm run size && DEBUG_PRINT_LIMIT=70000 vitest run"
},
"license": "Apache-2.0",
"contributors": [
Expand Down Expand Up @@ -85,7 +85,7 @@
"@emotion/styled": "^11.10.6",
"@mui/material": "^7.x",
"@mui/system": "^7.x",
"@testing-library/dom": "^10.4.0",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.4.3",
Expand All @@ -104,7 +104,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-testing-library": "^6.2.0",
"glob": "^10.3.0",
"happy-dom": "^17.0",
"happy-dom": "^18.0.1",
"react": "^19.0.0",
"react-dnd-test-backend": "^16.0.1",
"react-dom": "^19.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/components/Window.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export function Window({
id={windowId}
className={ns('window')}
aria-label={t('window', { label })}
data-testid="test-region"
>
<WindowTopBar
component={workspaceType === 'mosaic' && windowDraggable ? DraggableNavBar : undefined}
Expand Down
Loading