From 2ed3c9b18d7640378d711adcded825977e138fd6 Mon Sep 17 00:00:00 2001 From: Jeremy Press Date: Mon, 11 Feb 2019 10:13:22 -0800 Subject: [PATCH] Chore: Responding to PR comments --- .../integration/document/Controls.e2e.test.js | 19 ++++++------------- .../document/PresentationViewer.e2e.test.js | 16 +++++----------- test/support/commands.js | 6 ++++++ 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/test/integration/document/Controls.e2e.test.js b/test/integration/document/Controls.e2e.test.js index 2cf7c2bc7..9d3c282b2 100644 --- a/test/integration/document/Controls.e2e.test.js +++ b/test/integration/document/Controls.e2e.test.js @@ -3,13 +3,6 @@ describe('Preview Document Controls', () => { const token = Cypress.env('ACCESS_TOKEN'); const fileId = Cypress.env('FILE_ID_DOC'); - /* eslint-disable */ - const showControls = () => { - cy.getByTestId('bp').trigger('mouseover'); - cy.getByTestId('controls-wrapper').should('be.visible'); - }; - /* eslint-enable */ - beforeEach(() => { cy.visit('/'); cy.showPreview(token, fileId); @@ -25,7 +18,7 @@ describe('Preview Document Controls', () => { cy.wrap($page[0].scrollHeight).as('originalHeight'); }); - showControls(); + cy.showControls(); cy.getByTitle('Zoom out').click(); @@ -40,7 +33,7 @@ describe('Preview Document Controls', () => { cy.wrap(zoomedOutHeight).as('zoomedOutHeight'); }); - showControls(); + cy.showControls(); cy.getByTitle('Zoom in').click(); @@ -58,14 +51,14 @@ describe('Preview Document Controls', () => { cy.contains('The Content Platform for Your Apps'); cy.get('@currentPage').invoke('text').should('equal', '1'); - showControls(); + cy.showControls(); cy.getByTitle('Next page').click(); cy.getPreviewPage(2).should('be.visible'); cy.contains('Discover how your business can use Box Platform'); cy.get('@currentPage').invoke('text').should('equal', '2'); - showControls(); + cy.showControls(); cy.getByTitle('Previous page').click(); cy.getPreviewPage(1).should('be.visible'); @@ -78,7 +71,7 @@ describe('Preview Document Controls', () => { cy.contains('The Content Platform for Your Apps'); cy.get('@currentPage').invoke('text').should('equal', '1'); - showControls(); + cy.showControls(); cy.getByTitle('Click to enter page number').click(); cy.getByTestId('page-num-input').should('be.visible').type('2').blur(); @@ -94,7 +87,7 @@ describe('Preview Document Controls', () => { // it('Should handle going fullscreen', () => { // cy.getPreviewPage(1).should('be.visible'); // cy.contains('The Content Platform for Your Apps'); - // showControls(); + // cy.showControls(); // cy.getByTitle('Enter fullscreen').should('be.visible').click(); // cy.getByTitle('Exit fullscreen').should('be.visible'); // }); diff --git a/test/integration/document/PresentationViewer.e2e.test.js b/test/integration/document/PresentationViewer.e2e.test.js index b5caa04ca..438ceae5c 100644 --- a/test/integration/document/PresentationViewer.e2e.test.js +++ b/test/integration/document/PresentationViewer.e2e.test.js @@ -3,12 +3,6 @@ describe('Presentation Viewer', () => { const token = Cypress.env('ACCESS_TOKEN'); const fileId = Cypress.env('FILE_ID_PRESENTATION'); - /* eslint-disable */ - const showControls = () => { - cy.getByTestId('bp').trigger('mouseover'); - cy.getByTestId('controls-wrapper').should('be.visible'); - }; - /* eslint-enable */ beforeEach(() => { cy.visit('/'); @@ -18,15 +12,15 @@ describe('Presentation Viewer', () => { it('Should initialize preview on the same page it was closed on', () => { // Assert document content is present cy.contains('For Teaching Economics'); - // Get the current dimensions of the page - showControls(); - // Navigate to the next page + + cy.showControls(); + + // Navigate to the second page so it gets cached cy.getByTitle('Next page').click(); - // Refresh the preview + // Refreshes preview cy.reload(); - // Page 2 should still be visible cy.getPreviewPage(2).should('be.visible'); }); diff --git a/test/support/commands.js b/test/support/commands.js index 086d12ba2..6e9f5b920 100644 --- a/test/support/commands.js +++ b/test/support/commands.js @@ -24,3 +24,9 @@ Cypress.Commands.add('showPreview', (token, fileId, options) => { // Wait for .bp to load viewer return cy.getByTestId('bp').should('have.class', 'bp-loaded'); }); + + +Cypress.Commands.add('showControls', () => { + cy.getByTestId('bp').trigger('mouseover'); + cy.getByTestId('controls-wrapper').should('be.visible'); +})