Fix tests

GitOrigin-RevId: 739e1c1fccaa583bd3e13da96802b8c6d4164ad8
This commit is contained in:
Alf Eaton 2024-09-15 22:03:04 +01:00 committed by Copybot
parent 5e7f4feeb8
commit be45aec5b5

View file

@ -6,6 +6,10 @@ import { getContainerEl } from 'cypress/react'
import { unmountComponentAtNode } from 'react-dom' import { unmountComponentAtNode } from 'react-dom'
import { PdfPreviewProvider } from '../../../../frontend/js/features/pdf-preview/components/pdf-preview-provider' import { PdfPreviewProvider } from '../../../../frontend/js/features/pdf-preview/components/pdf-preview-provider'
// Unicode directional isolates, added around placeables by @fluent/bundle/esm/resolver
const FSI = '\u2068'
const PDI = '\u2069'
describe('<PdfJSViewer/>', function () { describe('<PdfJSViewer/>', function () {
beforeEach(function () { beforeEach(function () {
cy.interceptEvents() cy.interceptEvents()
@ -26,12 +30,12 @@ describe('<PdfJSViewer/>', function () {
</EditorProviders> </EditorProviders>
) )
cy.waitForCompile() cy.waitForCompile({ pdf: true })
cy.findByLabelText('Page 1') cy.findByRole('region', { name: `Page ${FSI}1${PDI}` })
cy.findByLabelText('Page 2') cy.findByRole('region', { name: `Page ${FSI}2${PDI}` })
cy.findByLabelText('Page 3') cy.findByRole('region', { name: `Page ${FSI}3${PDI}` })
cy.findByLabelText('Page 4').should('not.exist') cy.findByRole('region', { name: `Page ${FSI}4${PDI}` }).should('not.exist')
cy.contains('Your Paper') cy.contains('Your Paper')
}) })
@ -53,7 +57,7 @@ describe('<PdfJSViewer/>', function () {
cy.waitForCompile() cy.waitForCompile()
cy.findByLabelText('Loading…') cy.get('.page.loading')
}) })
it('can be unmounted while loading a document', function () { it('can be unmounted while loading a document', function () {
@ -91,9 +95,9 @@ describe('<PdfJSViewer/>', function () {
</EditorProviders> </EditorProviders>
) )
cy.waitForCompile() cy.waitForCompile({ pdf: true })
cy.findByLabelText('Page 1') cy.findByRole('region', { name: `Page ${FSI}1${PDI}` })
cy.then(() => unmountComponentAtNode(getContainerEl())) cy.then(() => unmountComponentAtNode(getContainerEl()))
}) })