Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(protocol-designer): start of cypress happy path test for mix settings #17320

Draft
wants to merge 17 commits into
base: edge
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from "cypress";

export default defineConfig({

Check failure on line 3 in cypress.config.ts

View workflow job for this annotation

GitHub Actions / js checks

Prefer named exports

Check failure on line 3 in cypress.config.ts

View workflow job for this annotation

GitHub Actions / js checks

Prefer named exports
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, /opentrons/protocol-designer/cypress.config.js I think is where we defined this. There are two places to go from here:

  1. Update cypress.config.js --> cypress.config.ts
  2. Leave it as is for now and delete cypress.config.ts

e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know why this file was added? I fully agree with having fixtures, but this one feels like it was automatically generated by Cypress

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skowalski08 , this is actually a smidge more severe, my apologies. It appears that you have created a cypress, fixtures, and support file within the Opentrons Directory independent of Protocol-Designer

See here https://github.com/Opentrons/opentrons/tree/a42308ca809c4a7389dbc423fd7bd20bbf5dacc9/cypress

Screenshot 2025-01-22 at 5 33 20 PM

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />

Check failure on line 1 in cypress/support/commands.ts

View workflow job for this annotation

GitHub Actions / js checks

Do not use a triple slash reference for cypress, use `import` style instead

Check failure on line 1 in cypress/support/commands.ts

View workflow job for this annotation

GitHub Actions / js checks

Do not use a triple slash reference for cypress, use `import` style instead
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go away from the triple slash, which is causing a linting error, but also might delete the rest of the commented out space

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
20 changes: 20 additions & 0 deletions cypress/support/e2e.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
61 changes: 61 additions & 0 deletions protocol-designer/cypress/e2e/mixSettings.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import '../support/commands.ts'; // Importing the custom commands file

Check failure on line 1 in protocol-designer/cypress/e2e/mixSettings.cy.ts

View workflow job for this annotation

GitHub Actions / js checks

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.

Check failure on line 1 in protocol-designer/cypress/e2e/mixSettings.cy.ts

View workflow job for this annotation

GitHub Actions / js checks

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See example here without using the .ts extension

import '../support/commands'

import {
Actions,
Verifications,
runMixSetup,
} from '../support/mixSetting'
import { UniversalActions } from '../support/universalActions'
import { TestFilePath, getTestFile } from '../support/testFiles'
import {
// verifyOldProtocolModal,
verifyImportProtocolPage,
} from '../support/import'

describe('Redesigned Mixing Steps - Happy Path', () => {
beforeEach(() => {
cy.visit('/')
cy.closeAnalyticsModal()
const protocol = getTestFile(TestFilePath.DoItAllV8)
cy.importProtocol(protocol.path)
verifyImportProtocolPage(protocol)

// NOTE: vv make this chunk better//
cy.contains("Edit protocol").click()
cy.contains("Protocol steps").click()
cy.get('[id="AddStepButton"]').contains("Add Step").click()
cy.verifyOverflowBtn()
});


it('It should verify the working function of every permutation of mix checkboxes', () => {
const steps: Array<Actions | Verifications | UniversalActions> = [
Actions.SelectMix,
UniversalActions.Snapshot,
Verifications.PartOne,
Actions.SelectLabware,
Actions.SelectWellInputField,
Verifications.WellSelectPopout,
UniversalActions.Snapshot,
Actions.Save,
Actions.EnterVolume,
Actions.EnterMixReps,
Actions.SelectTipHandling,
UniversalActions.Snapshot,
Actions.Continue,
Verifications.PartTwoAsp,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was really impressed by how thorough your verifications were!

Actions.AspirateFlowRate,
Actions.AspWellOrder,
Verifications.AspWellOrder,
// Actions.Dispense,
// Verifications.PartTwoDisp,

]

runMixSetup(steps)
// cy.contains('Primary order').closest('div')
});
});

/*
NEED TO ADD RENAME
*/
30 changes: 25 additions & 5 deletions protocol-designer/cypress/support/commands.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cy.contains(locators.confirm).click()

Looks like it's causing trouble with your home.cy.ts file. The cypress test likely will fail until this happens

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ declare global {
verifyCreateNewPage: () => Cypress.Chainable<void>
togglePreWetTip: () => Cypress.Chainable<void>
mixaspirate: () => Cypress.Chainable<void>
clickConfirm: () => Cypress.Chainable<void>
verifyOverflowBtn: () => Cypress.Chainable<void>
}
}
}
Expand All @@ -49,6 +51,12 @@ export const content = {
appSettings: 'App Info',
privacy: 'Privacy',
shareSessions: 'Share analytics with Opentrons',
move: "Move",
transfer: "Transfer",
mix: "Mix",
pause: "Pause",
heaterShaker: "Heater-shaker",
thermocyler: "Thermocycler",
}

export const locators = {
Expand Down Expand Up @@ -104,11 +112,12 @@ Cypress.Commands.add('verifyCreateNewHeader', () => {
// Home Page
Cypress.Commands.add('verifyHomePage', () => {
cy.contains(content.welcome)
cy.get(locators.privacyPolicy).should('exist').and('be.visible')
cy.get(locators.eula).should('exist').and('be.visible')
cy.contains(locators.confirm).click()
cy.contains('button', locators.createProtocol).should('be.visible')
cy.contains('label', locators.importProtocol).should('be.visible')
cy.getByTestId(locators.settingsDataTestid).should('be.visible')
cy.get(locators.privacyPolicy).should('exist').and('be.visible')
cy.get(locators.eula).should('exist').and('be.visible')
})

Cypress.Commands.add('clickCreateNew', () => {
Expand All @@ -122,6 +131,10 @@ Cypress.Commands.add('closeAnalyticsModal', () => {
.click({ force: true })
})

Cypress.Commands.add('clickConfirm', () => {
cy.contains(locators.confirm).click()
})

// Header Import
Cypress.Commands.add('importProtocol', (protocolFilePath: string) => {
cy.contains(locators.import).click()
Expand Down Expand Up @@ -158,6 +171,15 @@ Cypress.Commands.add('verifySettingsPage', () => {
.should('be.visible')
})

Cypress.Commands.add('verifyOverflowBtn', () => {
cy.contains(content.move).should('exist').should('be.visible')
cy.contains(content.transfer).should('exist').should('be.visible')
cy.contains(content.mix).should('exist').should('be.visible')
cy.contains(content.pause).should('exist').should('be.visible')
cy.contains(content.heaterShaker).should('exist').should('be.visible')
cy.contains(content.thermocyler).should('exist').should('be.visible')
})

/// /////////////////////////////////////////////////////////////////
// Legacy Code Section
// This code is deprecated and should be removed
Expand All @@ -183,9 +205,7 @@ Cypress.Commands.add('openFilePage', () => {
// Pipette Page Actions
//

Cypress.Commands.add(
'choosePipettes',
(leftPipetteSelector, rightPipetteSelector) => {
Cypress.Commands.add('choosePipettes', (leftPipetteSelector, rightPipetteSelector) => {
cy.get('[id="PipetteSelect_left"]').click()
cy.get(leftPipetteSelector).click()
cy.get('[id="PipetteSelect_right"]').click()
Expand Down
Loading
Loading