diff --git a/labware-library/README.md b/labware-library/README.md index 06982723d7d..3466de2cacf 100644 --- a/labware-library/README.md +++ b/labware-library/README.md @@ -83,3 +83,7 @@ Certain environment variables, when set, will affect the artifact output. | OT_LL_MIXPANEL_DEV_ID | some string ID | Mixpanel token for dev environment. | | OT_LL_VERSION | semver string eg "1.2.3" | reported to analytics. Read from package.json by default. | | OT_LL_BUILD_DATE | result of `new Date().toUTCString()` | reported to analytics. Uses current date-time by default. | + +## Cypress + +`npx cypress open` will open the Cypress test runner. From there, you can run the tests in the `labware-library` directory. diff --git a/labware-library/cypress/e2e/home.cy.js b/labware-library/cypress/e2e/home.cy.js index 79a39e8712e..20c8015e834 100644 --- a/labware-library/cypress/e2e/home.cy.js +++ b/labware-library/cypress/e2e/home.cy.js @@ -1,7 +1,8 @@ +import { navigateToUrl } from '../support/e2e' + describe('The Desktop Home Page', () => { beforeEach(() => { - cy.visit('/') - cy.viewport('macbook-15') + navigateToUrl('/') }) it('successfully loads', () => { diff --git a/labware-library/cypress/e2e/labware-creator/create.cy.js b/labware-library/cypress/e2e/labware-creator/create.cy.js index 845347a76e2..917b263cb78 100644 --- a/labware-library/cypress/e2e/labware-creator/create.cy.js +++ b/labware-library/cypress/e2e/labware-creator/create.cy.js @@ -2,11 +2,11 @@ // an element is in view before clicking or checking with // { force: true } -import { navigateToPage } from '../../support/e2e' +import { navigateToUrl } from '../../support/e2e' context('The Labware Creator Landing Page', () => { beforeEach(() => { - navigateToPage('create') + navigateToUrl('/#/create') }) describe('The initial text', () => { diff --git a/labware-library/cypress/e2e/labware-creator/customTubeRack.cy.js b/labware-library/cypress/e2e/labware-creator/customTubeRack.cy.js index 70ff1cf2a7b..b7f9cbbcc30 100644 --- a/labware-library/cypress/e2e/labware-creator/customTubeRack.cy.js +++ b/labware-library/cypress/e2e/labware-creator/customTubeRack.cy.js @@ -1,5 +1,5 @@ import { - navigateToPage, + navigateToUrl, fileHelper, wellBottomImageLocator, } from '../../support/e2e' @@ -7,7 +7,7 @@ const fileHolder = fileHelper('somerackbrand_24_tuberack_1500ul') context('Tubes and Rack', () => { before(() => { - navigateToPage('create') + navigateToUrl('/#/create') }) describe('Custom 6 x 4 tube rack', () => { diff --git a/labware-library/cypress/e2e/labware-creator/fileImport.cy.js b/labware-library/cypress/e2e/labware-creator/fileImport.cy.js index 3b919d21e40..616edca7d5b 100644 --- a/labware-library/cypress/e2e/labware-creator/fileImport.cy.js +++ b/labware-library/cypress/e2e/labware-creator/fileImport.cy.js @@ -1,5 +1,5 @@ import { - navigateToPage, + navigateToUrl, fileHelper, wellBottomImageLocator, } from '../../support/e2e' @@ -9,7 +9,7 @@ const importedLabwareFile = 'TestLabwareDefinition.json' describe('File Import', () => { before(() => { - navigateToPage('create') + navigateToUrl('/#/create') }) it('tests the file import flow', () => { diff --git a/labware-library/cypress/e2e/labware-creator/reservoir.cy.js b/labware-library/cypress/e2e/labware-creator/reservoir.cy.js index 6c019073fba..32b18c88a40 100644 --- a/labware-library/cypress/e2e/labware-creator/reservoir.cy.js +++ b/labware-library/cypress/e2e/labware-creator/reservoir.cy.js @@ -1,5 +1,5 @@ import { - navigateToPage, + navigateToUrl, fileHelper, wellBottomImageLocator, } from '../../support/e2e' @@ -7,7 +7,7 @@ const fileHolder = fileHelper('testpro_10_reservoir_250ul') context('Reservoirs', () => { before(() => { - navigateToPage('create') + navigateToUrl('/#/create') }) describe('Reservoir', () => { diff --git a/labware-library/cypress/e2e/labware-creator/tipRack.cy.js b/labware-library/cypress/e2e/labware-creator/tipRack.cy.js index 6bc7f16059d..4d27a47effc 100644 --- a/labware-library/cypress/e2e/labware-creator/tipRack.cy.js +++ b/labware-library/cypress/e2e/labware-creator/tipRack.cy.js @@ -1,9 +1,9 @@ -import { navigateToPage, fileHelper } from '../../support/e2e' +import { navigateToUrl, fileHelper } from '../../support/e2e' const fileHolder = fileHelper('generic_1_tiprack_20ul') describe('Create a Tip Rack', () => { before(() => { - navigateToPage('create') + navigateToUrl('/#/create') }) it('Should create a tip rack', () => { // Tip Rack Selection from drop down diff --git a/labware-library/cypress/e2e/labware-creator/tubesBlock.cy.js b/labware-library/cypress/e2e/labware-creator/tubesBlock.cy.js index 45735d55ae6..4240342390a 100644 --- a/labware-library/cypress/e2e/labware-creator/tubesBlock.cy.js +++ b/labware-library/cypress/e2e/labware-creator/tubesBlock.cy.js @@ -1,5 +1,5 @@ import { - navigateToPage, + navigateToUrl, fileHelper, wellBottomImageLocator, } from '../../support/e2e' @@ -7,8 +7,7 @@ const fileHolder = fileHelper('testpro_24_aluminumblock_10ul') context('Tubes and Block', () => { beforeEach(() => { - navigateToPage('create') - + navigateToUrl('/#/create') cy.get('label') .contains('What type of labware are you creating?') .children() @@ -447,9 +446,7 @@ context('Tubes and Block', () => { }) it('tests the whole form and file export', () => { - cy.visit('/') - cy.get('a[href="/create"]').first().click() - cy.viewport('macbook-15') + navigateToUrl('/#/create') cy.get('label') .contains('What type of labware are you creating?') .children() diff --git a/labware-library/cypress/e2e/labware-creator/tubesRack.cy.js b/labware-library/cypress/e2e/labware-creator/tubesRack.cy.js index ca1dd1bf25e..0409221b6a4 100644 --- a/labware-library/cypress/e2e/labware-creator/tubesRack.cy.js +++ b/labware-library/cypress/e2e/labware-creator/tubesRack.cy.js @@ -1,9 +1,9 @@ -import { navigateToPage, wellBottomImageLocator } from '../../support/e2e' +import { navigateToUrl, wellBottomImageLocator } from '../../support/e2e' context('Tubes and Rack', () => { describe('Six tubes', () => { before(() => { - navigateToPage('create') + navigateToUrl('/#/create') cy.get('label') .contains('What type of labware are you creating?') .children() @@ -134,10 +134,7 @@ context('Tubes and Rack', () => { describe('Fifteen tubes', () => { before(() => { - cy.visit('/') - cy.get('a[href="/create"]').first().click() - cy.viewport('macbook-15') - + navigateToUrl('#/create') cy.get('label') .contains('What type of labware are you creating?') .children() @@ -266,10 +263,7 @@ context('Tubes and Rack', () => { describe('Twentyfour tubes', () => { before(() => { - cy.visit('/') - cy.get('a[href="/create"]').first().click() - cy.viewport('macbook-15') - + navigateToUrl('/#/create') cy.get('label') .contains('What type of labware are you creating?') .children() diff --git a/labware-library/cypress/e2e/labware-creator/wellPlate.cy.js b/labware-library/cypress/e2e/labware-creator/wellPlate.cy.js index dbab042f5aa..df12cf153a5 100644 --- a/labware-library/cypress/e2e/labware-creator/wellPlate.cy.js +++ b/labware-library/cypress/e2e/labware-creator/wellPlate.cy.js @@ -3,7 +3,7 @@ // a user to do this. import { - navigateToPage, + navigateToUrl, fileHelper, wellBottomImageLocator, } from '../../support/e2e' @@ -11,7 +11,7 @@ const fileHolder = fileHelper('testpro_80_wellplate_100ul') context('Well Plates', () => { before(() => { - navigateToPage('create') + navigateToUrl('/#/create') }) describe('Create a well plate', () => { diff --git a/labware-library/cypress/e2e/navigation.cy.js b/labware-library/cypress/e2e/navigation.cy.js index 83ce2dd7369..0b4c3c14a40 100644 --- a/labware-library/cypress/e2e/navigation.cy.js +++ b/labware-library/cypress/e2e/navigation.cy.js @@ -1,7 +1,8 @@ +import { navigateToUrl } from '../support/e2e' + describe('Desktop Navigation', () => { beforeEach(() => { - cy.visit('/') - cy.viewport('macbook-15') + navigateToUrl('/') }) it('contains the subdomain nav bar', () => { diff --git a/labware-library/cypress/support/e2e.ts b/labware-library/cypress/support/e2e.ts index 4aec3d123d0..85dcff19ba8 100644 --- a/labware-library/cypress/support/e2e.ts +++ b/labware-library/cypress/support/e2e.ts @@ -6,9 +6,8 @@ import { join } from 'path' import './commands' -export const navigateToPage = (page: string): void => { - cy.visit('/') - cy.get(`a[href="/${page}"]`).first().click() +export const navigateToUrl = (url: string): void => { + cy.visit(url) cy.viewport('macbook-15') }