Skip to content

Commit

Permalink
update cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jackiequach committed Apr 10, 2024
1 parent c6434eb commit 354c1d9
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 60 deletions.
39 changes: 28 additions & 11 deletions cypress/integration/multi-pdf/navigations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,27 @@ describe('Multi PDF navigation', () => {
});

it('should navigate forward and backwards with page buttons', () => {
cy.findByText('Anthropology without Informants').should('be.visible');
cy.findByText(
'Anthropology without Informants: Collected Works in Paleoanthropology by L.G. Freeman.'
).should('be.visible');
cy.findByRole('button', { name: 'Next Page' }).click();
cy.get('#mainContent')
.find('div[class="react-pdf__Page__textContent"]')
.find('.react-pdf__Page__textContent')
.children()
.should('have.length', 0);
cy.findByText('Anthropology without Informants').should('not.exist');
cy.findByText(
'Anthropology without Informants: Collected Works in Paleoanthropology by L.G. Freeman.'
).should('not.exist');
cy.findByRole('button', { name: 'Previous Page' }).click();
cy.findByText('Anthropology without Informants').should('be.visible');
cy.findByText(
'Anthropology without Informants: Collected Works in Paleoanthropology by L.G. Freeman.'
).should('be.visible');
});

it('should switch to scrolling mode', () => {
cy.findByText('Anthropology without Informants').should('be.visible');
cy.findByText(
'Anthropology without Informants: Collected Works in Paleoanthropology by L.G. Freeman.'
).should('be.visible');
cy.findByRole('button', { name: 'Settings' }).click();
cy.findByText('Scrolling').click();
cy.findByRole('button', { name: 'Next Page' }).click();
Expand All @@ -56,27 +64,36 @@ describe('Multi PDF navigation', () => {
});

it('should navigate between resources with page buttons on scrolling mode', () => {
cy.findByText('Anthropology without Informants').should('be.visible');
cy.findByText(
'Anthropology without Informants: Collected Works in Paleoanthropology by L.G. Freeman.'
).should('be.visible');
cy.findByText('Settings').click();
cy.findByText('Scrolling').click();
cy.findByRole('button', { name: 'Next Page' }).click();
cy.findByText('Anthropology without Informants').should('not.exist');
cy.findByText(
'Anthropology without Informants: Collected Works in Paleoanthropology by L.G. Freeman.'
).should('not.exist');

cy.log('switch from paginated to scrolling');
cy.findByText('Settings').click();
cy.findByText('Paginated').click();
cy.findByRole('button', { name: 'Next Page' }).click();

cy.findByText('Anthropology without Informants').should('not.exist');
cy.findByText(
'Anthropology without Informants: Collected Works in Paleoanthropology by L.G. Freeman.'
).should('not.exist');

cy.findByText('Settings').click();
cy.findByText('Scrolling').click();
cy.findByRole('button', { name: 'Previous Page' }).click();

cy.wait('@pdf');
cy.findByText('Settings').click();
cy.findByText('Zoom Out').click();

cy.findByText('Anthropology without Informants', { timeout: 10000 }).should(
'be.visible'
);
cy.findByText(
'Anthropology without Informants: Collected Works in Paleoanthropology by L.G. Freeman.',
{ timeout: 10000 }
).should('be.visible');
});
});
4 changes: 3 additions & 1 deletion cypress/integration/multi-pdf/render-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ describe('Renders multi PDF', () => {
cy.findByRole('button', { name: 'Next Page' }).should('not.be.disabled');
cy.findByRole('button', { name: 'Previous Page' }).should('be.disabled');

cy.findByText('Anthropology without Informants').should('be.visible');
cy.findByText(
'Anthropology without Informants: Collected Works in Paleoanthropology by L.G. Freeman.'
).should('be.visible');
});
});
4 changes: 2 additions & 2 deletions cypress/integration/single-pdf/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ describe('Single PDF display settings', () => {
});

it('should zoom in and out', () => {
cy.get('div[class="react-pdf__Page__textContent"]')
cy.get('.react-pdf__Page__textContent')
.find('span')
.should(
'have.text',
'ECONOMICS – WORKING PAPERS 2021/03Assessing climate change risks at the country level: the EIB scoring model'
'ECONOMICS – WORKING PAPERS 2021/03Assessing climate changerisks at the country level:the EIB scoring model'
);

cy.get('.react-pdf__Page').then(($elm) => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Cypress.Commands.add(
});
cy.wait('@pdf', { timeout: 50000 });
cy.get('#mainContent')
.find('div[class="react-pdf__Page__textContent"]', { timeout: 10000 })
.find('.react-pdf__Page__textContent', { timeout: 10000 })
.should('have.attr', 'style');
}
);
159 changes: 124 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 354c1d9

Please sign in to comment.