Skip to content

Commit

Permalink
feat(protocol-designer): Make createNew.ts more robust and use it to …
Browse files Browse the repository at this point in the history
…start testing protocol actions in PD (#17156)

<!--
Thanks for taking the time to open a Pull Request (PR)! Please make sure
you've read the "Opening Pull Requests" section of our Contributing
Guide:


https://github.com/Opentrons/opentrons/blob/edge/CONTRIBUTING.md#opening-pull-requests

GitHub provides robust markdown to format your PR. Links, diagrams,
pictures, and videos along with text formatting make it possible to
create a rich and informative PR. For more information on GitHub
markdown, see:


https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax

To ensure your code is reviewed quickly and thoroughly, please fill out
the sections below to the best of your ability!
-->

# Overview
These additions to the test case of transferSetting.js.cy are the start
of providing greater test coverage to our transfer form.

At this moment, it only goes up to saving a liquid and then opening the
transfer form.

<!--
Describe your PR at a high level. State acceptance criteria and how this
PR fits into other work. Link issues, PRs, and other relevant resources.
-->

## Test Plan and Hands on Testing
These are changes exclusively to cypress. So it will be tested when
folks run their code.
<!--
Describe your testing of the PR. Emphasize testing not reflected in the
code. Attach protocols, logs, screenshots and any other assets that
support your testing.
-->

## Changelog

1. opentrons/protocol-designer/cypress/e2e/transferSettings.cy.js . 
2. opentrons/protocol-designer/cypress/support/commands.ts added some
additional helper functions

Please add special attention to checking if this was the correct way to
add liquid. Saving it took a bit of extra effort. AFAIK

> When you submit a form, the browser sends a POST or GET request to the
action URL specified in the <form> tag or the current page URL if no
action is defined.
Cypress executes the test and observes the page reload, which can
interfere with your test flow if you're not handling it properly.

So I tried to do the following

```Javascript
cy.contains('button', 'Add liquid').click()
                        cy.contains('button', 'Liquid').click()
                        cy.contains('button', 'Define a liquid').click()
                        cy.get('input[name="name"]') // Select the input with name="name"
                            .type('My liquid!')

                        cy.get('div[aria-label="ModalShell_ModalArea"]')
                            .find('form') // Target the form that wraps the button
                            .invoke('submit', (e) => {
                                e.preventDefault(); // Prevent default behavior
                            });
```
<!--
List changes introduced by this PR considering future developers and the
end user. Give careful thought and clear documentation to breaking
changes.
-->

## Review requests

@y3rsh @jerader 

<!--
- What do you need from reviewers to feel confident this PR is ready to
merge?
- Ask questions.
-->

## Risk assessment
Medium. This might take some extra time with developers to ensure that
I'm not breaking existing testing behavior.
<!--
- Indicate the level of attention this PR needs.
- Provide context to guide reviewers.
- Discuss trade-offs, coupling, and side effects.
- Look for the possibility, even if you think it's small, that your
change may affect some other part of the system.
- For instance, changing return tip behavior may also change the
behavior of labware calibration.
- How do your unit tests and on hands on testing mitigate this PR's
risks and the risk of future regressions?
- Especially in high risk PRs, explain how you know your testing is
enough.
-->
  • Loading branch information
alexjoel42 authored Jan 9, 2025
1 parent 61ef9eb commit 6db70ab
Show file tree
Hide file tree
Showing 8 changed files with 551 additions and 665 deletions.
13 changes: 4 additions & 9 deletions protocol-designer/cypress/e2e/createNew.cy.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import {
Actions,
Verifications,
runCreateTest,
verifyCreateProtocolPage,
} from '../support/createNew'
import { Actions, Verifications, runCreateTest } from '../support/createNew'
import { UniversalActions } from '../support/universalActions'
import '../support/commands'

describe('The Redesigned Create Protocol Landing Page', () => {
beforeEach(() => {
cy.visit('/')
cy.closeAnalyticsModal()
})

it('content and step 1 flow works', () => {
cy.closeAnalyticsModal()
cy.clickCreateNew()
cy.verifyCreateNewHeader()
verifyCreateProtocolPage()
cy.clickCreateNew()
const steps: Array<Actions | Verifications | UniversalActions> = [
Verifications.OnStep1,
Verifications.FlexSelected,
Expand Down
72 changes: 72 additions & 0 deletions protocol-designer/cypress/e2e/createNewFlex.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Actions, Verifications, runCreateTest } from '../support/createNew'
import { UniversalActions } from '../support/universalActions'

describe('The Redesigned Create Protocol Landing Page', () => {
beforeEach(() => {
cy.visit('/')
cy.closeAnalyticsModal()
})

it('content and step 1 flow works', () => {
cy.clickCreateNew()
cy.verifyCreateNewHeader()
const steps: Array<Actions | Verifications | UniversalActions> = [
Verifications.OnStep1,
Verifications.FlexSelected,
UniversalActions.Snapshot,
Actions.SelectOT2,
Verifications.OT2Selected,
UniversalActions.Snapshot,
Actions.SelectFlex,
Verifications.FlexSelected,
UniversalActions.Snapshot,
Actions.Confirm,
Verifications.OnStep2,
Actions.SingleChannelPipette50,
Verifications.StepTwo50uL,
UniversalActions.Snapshot,
Actions.Confirm,
Verifications.StepTwoPart3,
UniversalActions.Snapshot,
Actions.Confirm,
Verifications.OnStep3,
Actions.YesGripper,
Actions.Confirm,
Verifications.Step4Verification,
Actions.AddThermocycler,
Verifications.ThermocyclerImg,
Actions.AddHeaterShaker,
Verifications.HeaterShakerImg,
Actions.AddMagBlock,
Verifications.MagBlockImg,
Actions.AddTempdeck2,
Verifications.Tempdeck2Img,
Actions.Confirm,
Actions.Confirm,
Actions.Confirm,
Actions.EditProtocolA,
Actions.ChoseDeckSlotC2,
Actions.AddHardwareLabware,
Actions.ClickLabwareHeader,
Actions.ClickWellPlatesSection,
Actions.SelectArmadillo96WellPlate,
Actions.ChoseDeckSlotC2Labware,
Actions.AddLiquid,
Actions.ClickLiquidButton,
Actions.DefineLiquid,
Actions.LiquidSaveWIP,
Actions.WellSelector,
Actions.LiquidDropdown,
Verifications.LiquidPage,
UniversalActions.Snapshot,
Actions.SelectLiquidWells,
Actions.SetVolumeAndSaveforWells,
Actions.ChoseDeckSlotC3,
Actions.AddHardwareLabware,
Actions.ClickLabwareHeader,
Actions.ClickWellPlatesSection,
Actions.SelectBioRad96WellPlate,
]
runCreateTest(steps)
})
})
1 change: 1 addition & 0 deletions protocol-designer/cypress/e2e/home.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
describe('The Home Page', () => {
beforeEach(() => {
cy.visit('/')
cy.closeAnalyticsModal()
})

it('successfully loads', () => {
Expand Down
Loading

0 comments on commit 6db70ab

Please sign in to comment.