Skip to content

Commit 4b0a384

Browse files
authored
test(protocol-designer): fix e2e tests after vite migration (#14635)
Closes [AUTH-86](https://opentrons.atlassian.net/jira/software/c/projects/AUTH/issues/AUTH-86)
1 parent 5f40d06 commit 4b0a384

21 files changed

+89
-192
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"protocol-designer",
1414
"shared-data",
1515
"step-generation",
16-
"webpack-config",
1716
"api-client",
1817
"react-api-client",
1918
"usb-bridge/node-client"

protocol-designer/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Opentrons Protocol Designer Beta
1+
# Opentrons Protocol Designer
22

33
## Overview
44

55
Protocol Designer is a tool for scientists and technicians to create protocols for their [OT-2 personal pipetting robot][ot-2] without having to write any code. It provides visual feedback including liquid tracking and tip tracking to allow users to see exactly what their protocol will do at each step. The protocols are saved to Opentrons JSON Protocol files, which can be uploaded to the Opentrons Desktop App to run on a robot.
66

7-
Protocol Designer Beta is optimized for [Chrome][chrome] browser. Other browsers are not fully supported.
7+
Protocol Designer is optimized for [Chrome][chrome] browser. Other browsers are not fully supported.
88

99
## Build setup for development
1010

protocol-designer/cypress.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"baseUrl": "http://localhost:5173",
33
"video": false,
44
"viewportWidth": 1440,
5-
"viewportHeight": 900
5+
"viewportHeight": 900,
6+
"pluginsFile": false
67
}

protocol-designer/cypress/integration/batchEdit.spec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { beforeEach, describe, it } from 'vitest'
2-
31
describe('Batch Edit Transform', () => {
42
beforeEach(() => {
53
cy.visit('/')

protocol-designer/cypress/integration/home.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { beforeEach, describe, it } from 'vitest'
2-
31
describe('The Home Page', () => {
42
beforeEach(() => {
53
cy.visit('/')
64
cy.closeAnnouncementModal()
75
})
86

97
it('successfully loads', () => {
10-
cy.title().should('equal', 'Opentrons Protocol Designer BETA')
8+
cy.title().should('equal', 'Opentrons Protocol Designer')
119
})
1210

1311
it('has the right charset', () => {

protocol-designer/cypress/integration/migrations.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { beforeEach, describe, it } from 'vitest'
21
import 'cypress-file-upload'
32
import cloneDeep from 'lodash/cloneDeep'
43
import { expectDeepEqual } from '@opentrons/shared-data/js/cypressUtils'

protocol-designer/cypress/integration/mixSettings.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { describe, it } from 'vitest'
21
const isMacOSX = Cypress.platform === 'darwin'
32
const invalidInput = 'abcdefghijklmnopqrstuvwxyz!@#$%^&*()<>?,-'
43
const batchEditClickOptions = { [isMacOSX ? 'metaKey' : 'ctrlKey']: true }
@@ -125,7 +124,7 @@ describe('Advanced Settings for Mix Form', () => {
125124
cy.get('[data-test="StepItem_2"]').click(batchEditClickOptions)
126125
cy.get('input[name="aspirate_flowRate"]').click({ force: true })
127126

128-
cy.get('div[class*=FlowRateInput__description]').contains(
127+
cy.contains(
129128
'Our default aspirate speed is optimal for a P1000 Single-Channel GEN2 aspirating liquids with a viscosity similar to water'
130129
)
131130
cy.get('input[name="aspirate_flowRate_customFlowRate"]').type('100')
@@ -144,7 +143,7 @@ describe('Advanced Settings for Mix Form', () => {
144143
it('verify functionality of flowrate in batch edit mix form', () => {
145144
// Batch editing the Flowrate value
146145
cy.get('input[name="aspirate_flowRate"]').click({ force: true })
147-
cy.get('div[class*=FlowRateInput__description]').contains(
146+
cy.contains(
148147
'Our default aspirate speed is optimal for a P1000 Single-Channel GEN2 aspirating liquids with a viscosity similar to water'
149148
)
150149
cy.get('input[name="aspirate_flowRate_customFlowRate"]').type('100')

protocol-designer/cypress/integration/settings.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { describe, it, before } from 'vitest'
21
describe('The Settings Page', () => {
32
const exptlSettingText = 'Disable module placement restrictions'
43

@@ -142,7 +141,7 @@ describe('The Settings Page', () => {
142141
cy.contains(exptlSettingText).next().click()
143142
cy.get('button').contains('Continue').click()
144143
// Leave the settings page
145-
cy.get("button[class*='navbar__tab__']").contains('FILE').click()
144+
cy.get("button[id='NavTab_file']").contains('FILE').click()
146145
// Go back to settings
147146
cy.openSettingsPage()
148147
// The toggle is still on
@@ -160,7 +159,7 @@ describe('The Settings Page', () => {
160159
cy.contains(exptlSettingText).next().click()
161160
cy.get('button').contains('Continue').click()
162161
// Leave the settings page
163-
cy.get("button[class*='navbar__tab__']").contains('FILE')
162+
cy.get("button[id='NavTab_file']").contains('FILE')
164163
// Go back to settings
165164
cy.openSettingsPage()
166165
// The toggle is still off
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,45 @@
1-
import { describe, it, beforeEach } from 'vitest'
2-
31
describe('Desktop Navigation', () => {
42
beforeEach(() => {
53
cy.visit('/')
64
cy.closeAnnouncementModal()
75
})
86

97
it('contains a working file button', () => {
10-
cy.get("button[class*='navbar__tab__']")
8+
cy.get("button[id='NavTab_file']")
119
.contains('FILE')
1210
.parent()
1311
.should('have.prop', 'disabled')
1412
.and('equal', false)
1513
})
1614

1715
it('contains a disabled liquids button', () => {
18-
cy.get("button[class*='navbar__tab__']")
16+
cy.get("button[id='NavTab_liquids']")
1917
.contains('LIQUIDS')
2018
.parent()
2119
.should('have.prop', 'disabled')
2220
})
2321

2422
it('contains a disabled design button', () => {
25-
cy.get("button[class*='navbar__tab__']")
23+
cy.get("button[id='NavTab_design']")
2624
.contains('DESIGN')
2725
.parent()
2826
.should('have.prop', 'disabled')
2927
})
3028

3129
it('contains a help button with external link', () => {
32-
cy.get("a[class*='navbar__tab__']")
30+
cy.get('a')
3331
.contains('HELP')
3432
.parent()
3533
.should('have.prop', 'href')
3634
.and('equal', 'https://support.opentrons.com/s/protocol-designer')
3735
})
3836

3937
it('contains a settings button', () => {
40-
cy.get("button[class*='navbar__tab__']")
41-
.contains('Settings')
42-
.should('exist')
38+
cy.get('button').contains('Settings').should('exist')
4339
})
4440

4541
it('returns to the file controls when the file button is clicked', () => {
46-
cy.get("button[class*='navbar__tab__']").contains('FILE').click()
42+
cy.get("button[id='NavTab_file']").contains('FILE').click()
4743
cy.contains('Protocol File')
4844
})
4945
})

protocol-designer/cypress/integration/transferSettings.spec.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { describe, it, before } from 'vitest'
2-
31
const isMacOSX = Cypress.platform === 'darwin'
42
const batchEditClickOptions = { [isMacOSX ? 'metaKey' : 'ctrlKey']: true }
53

@@ -134,7 +132,7 @@ describe('Advanced Settings for Transfer Form', () => {
134132
cy.get('[data-test="StepItem_2"]').click(batchEditClickOptions)
135133
cy.get('input[name="aspirate_flowRate"]').click({ force: true })
136134

137-
cy.get('div[class*=FlowRateInput__description]').contains(
135+
cy.contains(
138136
'Our default aspirate speed is optimal for a P1000 Single-Channel GEN2 aspirating liquids with a viscosity similar to water'
139137
)
140138
cy.get('input[name="aspirate_flowRate_customFlowRate"]').type('100')
@@ -153,7 +151,7 @@ describe('Advanced Settings for Transfer Form', () => {
153151
it('verify functionality of flowrate in batch edit transfer', () => {
154152
// Batch editing the Flowrate value
155153
cy.get('input[name="aspirate_flowRate"]').click({ force: true })
156-
cy.get('div[class*=FlowRateInput__description]').contains(
154+
cy.contains(
157155
'Our default aspirate speed is optimal for a P1000 Single-Channel GEN2 aspirating liquids with a viscosity similar to water'
158156
)
159157
cy.get('input[name="aspirate_flowRate_customFlowRate"]').type('100')

protocol-designer/cypress/support/commands.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ Cypress.Commands.add('closeAnnouncementModal', () => {
3434
cy.get('[data-test="ComputingSpinner"]', { timeout: 30000 }).should(
3535
'not.exist'
3636
)
37-
cy.get('button').contains('Got It!').should('be.visible').click()
37+
cy.get('button')
38+
.contains('Got It!')
39+
.should('be.visible')
40+
.click({ force: true })
3841
})
3942

4043
//
4144
// File Page Actions
4245
//
4346
Cypress.Commands.add('openFilePage', () => {
44-
cy.get('button[class*="navbar__tab__"]').contains('FILE').click()
47+
cy.get('button[id="NavTab_file"]').contains('FILE').click()
4548
})
4649

4750
//
@@ -87,7 +90,7 @@ Cypress.Commands.add(
8790
// Design Page Actions
8891
//
8992
Cypress.Commands.add('openDesignPage', () => {
90-
cy.get('button[class*="navbar__tab__"]').contains('DESIGN').parent().click()
93+
cy.get('button[id="NavTab_design"]').contains('DESIGN').parent().click()
9194
})
9295
Cypress.Commands.add('addStep', stepName => {
9396
cy.get('button').contains('Add Step').click()
@@ -98,7 +101,7 @@ Cypress.Commands.add('addStep', stepName => {
98101
// Settings Page Actions
99102
//
100103
Cypress.Commands.add('openSettingsPage', () => {
101-
cy.get('button[class*="navbar__tab__"]').contains('Settings').click()
104+
cy.get('button').contains('Settings').click()
102105
})
103106

104107
// Advance Settings for Transfer Steps

protocol-designer/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,400i,600,600i,700,700i" rel="stylesheet">
88

99
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
10-
<title>Protocol Designer</title>
10+
<title>Opentrons Protocol Designer</title>
1111
</head>
1212
<body>
1313
<div id="root"></div>

protocol-designer/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"email": "[email protected]"
99
},
1010
"name": "protocol-designer",
11-
"type": "module",
12-
"productName": "Opentrons Protocol Designer BETA",
11+
"productName": "Opentrons Protocol Designer",
1312
"private": true,
1413
"version": "0.0.0-dev",
1514
"description": "Protocol designer app",

protocol-designer/src/components/DeckSetup/LabwareOverlays/SlotControls.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ export const SlotControls = (props: SlotControlsProps): JSX.Element | null => {
7070
accept: DND_TYPES.LABWARE,
7171
canDrop: (item: DroppedItem) => {
7272
const draggedDef = item?.labwareOnDeck?.def
73-
assert(draggedDef, 'no labware def of dragged item, expected it on drop')
73+
console.assert(
74+
draggedDef,
75+
'no labware def of dragged item, expected it on drop'
76+
)
7477

7578
if (moduleType != null && draggedDef != null) {
7679
// this is a module slot, prevent drop if the dragged labware is not compatible

protocol-designer/src/index.hbs

Lines changed: 0 additions & 15 deletions
This file was deleted.

protocol-designer/src/localization/en/modal.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
}
203203
},
204204
"gate": {
205-
"sign_up_below": "Sign Up For Opentrons Protocol Designer Beta",
205+
"sign_up_below": "Sign Up For Opentrons Protocol Designer",
206206
"failed_verification": "Something Went Wrong",
207207
"sign_up_success": "Please confirm your email address to continue",
208208
"check_email": "We've sent a confirmation URL to your email that will take you to the Protocol Designer. Keep an eye out for a follow up email which contains links to resources such as our help documents."

protocol-designer/vite.config.ts

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import path from 'path'
2-
import { defineConfig } from 'vite'
2+
import { UserConfig, defineConfig } from 'vite'
33
import react from '@vitejs/plugin-react'
44
import postCssImport from 'postcss-import'
55
import postCssApply from 'postcss-apply'
66
import postColorModFunction from 'postcss-color-mod-function'
77
import postCssPresetEnv from 'postcss-preset-env'
88
import lostCss from 'lost'
9+
import { versionForProject } from '../scripts/git-version'
910

1011
const testAliases: {} | { 'file-saver': string } =
1112
process.env.CYPRESS === '1'
@@ -15,53 +16,59 @@ const testAliases: {} | { 'file-saver': string } =
1516
}
1617
: {}
1718

18-
export default defineConfig({
19-
// this makes imports relative rather than absolute
20-
base: '',
21-
build: {
22-
// Relative to the root
23-
outDir: 'dist',
24-
},
25-
plugins: [
26-
react({
27-
include: '**/*.tsx',
28-
babel: {
29-
// Use babel.config.js files
30-
configFile: true,
19+
export default defineConfig(
20+
async (): Promise<UserConfig> => {
21+
const OT_PD_VERSION = await versionForProject('protocol-designer')
22+
const OT_PD_BUILD_DATE = new Date().toUTCString()
23+
return {
24+
// this makes imports relative rather than absolute
25+
base: '',
26+
build: {
27+
// Relative to the root
28+
outDir: 'dist',
3129
},
32-
}),
33-
],
34-
optimizeDeps: {
35-
esbuildOptions: {
36-
target: 'es2020',
37-
},
38-
},
39-
css: {
40-
postcss: {
4130
plugins: [
42-
postCssImport({ root: 'src/' }),
43-
postCssApply(),
44-
postColorModFunction(),
45-
postCssPresetEnv({ stage: 0 }),
46-
lostCss(),
31+
react({
32+
include: '**/*.tsx',
33+
babel: {
34+
// Use babel.config.js files
35+
configFile: true,
36+
},
37+
}),
4738
],
48-
},
49-
},
50-
define: {
51-
'process.env': process.env,
52-
global: 'globalThis',
53-
},
54-
resolve: {
55-
alias: {
56-
'@opentrons/components/styles': path.resolve(
57-
'../components/src/index.module.css'
58-
),
59-
'@opentrons/components': path.resolve('../components/src/index.ts'),
60-
'@opentrons/shared-data': path.resolve('../shared-data/js/index.ts'),
61-
'@opentrons/step-generation': path.resolve(
62-
'../step-generation/src/index.ts'
63-
),
64-
...testAliases,
65-
},
66-
},
67-
})
39+
optimizeDeps: {
40+
esbuildOptions: {
41+
target: 'es2020',
42+
},
43+
},
44+
css: {
45+
postcss: {
46+
plugins: [
47+
postCssImport({ root: 'src/' }),
48+
postCssApply(),
49+
postColorModFunction(),
50+
postCssPresetEnv({ stage: 0 }),
51+
lostCss(),
52+
],
53+
},
54+
},
55+
define: {
56+
'process.env': { ...process.env, OT_PD_VERSION, OT_PD_BUILD_DATE },
57+
global: 'globalThis',
58+
},
59+
resolve: {
60+
alias: {
61+
'@opentrons/components/styles': path.resolve(
62+
'../components/src/index.module.css'
63+
),
64+
'@opentrons/components': path.resolve('../components/src/index.ts'),
65+
'@opentrons/shared-data': path.resolve('../shared-data/js/index.ts'),
66+
'@opentrons/step-generation': path.resolve(
67+
'../step-generation/src/index.ts'
68+
),
69+
...testAliases,
70+
},
71+
},
72+
}
73+
}
74+
)

0 commit comments

Comments
 (0)