|
1 |
| -import path from 'path' |
2 |
| -import cloneDeep from 'lodash/cloneDeep' |
3 |
| -import semver from 'semver' |
4 |
| - |
5 |
| -import { expectDeepEqual } from '@opentrons/shared-data/js/cypressUtils' |
6 |
| - |
7 | 1 | // eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
8 |
| -import { getTestFile, TestFile, TestFilePath } from './TestFiles' |
9 |
| - |
10 |
| -export interface MigrateTestCase { |
11 |
| - title: string |
12 |
| - importTestFile: TestFilePath |
13 |
| - expectedTestFile: TestFilePath |
14 |
| - showMigrationModal: boolean |
15 |
| -} |
| 2 | +import { TestFile } from './TestFiles' |
16 | 3 |
|
17 | 4 | export const ContentStrings = {
|
18 | 5 | newLabwareDefs: 'Update protocol to use new labware definitions',
|
@@ -69,100 +56,3 @@ export const verifyImportProtocolPage = (protocol: TestFile): void => {
|
69 | 56 | }
|
70 | 57 | })
|
71 | 58 | }
|
72 |
| - |
73 |
| -export const migrateAndMatchSnapshot = ({ |
74 |
| - importTestFile, |
75 |
| - expectedTestFile, |
76 |
| - showMigrationModal, |
77 |
| -}: MigrateTestCase): void => { |
78 |
| - const uploadProtocol: TestFile = getTestFile(importTestFile) |
79 |
| - cy.importProtocol(uploadProtocol.path) |
80 |
| - |
81 |
| - if (showMigrationModal) { |
82 |
| - cy.get('button') |
83 |
| - .contains(ContentStrings.importButton, { matchCase: false }) |
84 |
| - .click({ force: true }) |
85 |
| - } |
86 |
| - |
87 |
| - verifyImportProtocolPage(uploadProtocol) |
88 |
| - // cy.contains('Edit protocol').click() |
89 |
| - |
90 |
| - cy.screenshot('protocol-designer/migration-snapshot', { |
91 |
| - capture: 'viewport', |
92 |
| - overwrite: true, |
93 |
| - }) |
94 |
| - |
95 |
| - cy.get(LocatorStrings.exportProtocol).click({ force: true }) |
96 |
| - |
97 |
| - const expectedProtocol: TestFile = getTestFile(expectedTestFile) |
98 |
| - |
99 |
| - cy.readFile(expectedProtocol.path).then(expectedProtocolRead => { |
100 |
| - const downloadedFilePath = path.join( |
101 |
| - expectedProtocol.downloadsFolder, |
102 |
| - `${expectedProtocolRead.metadata.protocolName}.json` |
103 |
| - ) |
104 |
| - cy.readFile(downloadedFilePath, { timeout: 5000 }).should('exist') |
105 |
| - cy.readFile(downloadedFilePath).then(savedFile => { |
106 |
| - const expectedFile = cloneDeep(expectedProtocolRead) |
107 |
| - const version = semver.parse( |
108 |
| - savedFile.designerApplication.version as string |
109 |
| - ) |
110 |
| - assert(version !== null, 'PD version is not valid semver') |
111 |
| - const isBelowVersion850 = semver.lt(version ?? '', '8.5.0') |
112 |
| - |
113 |
| - const files = [savedFile, expectedFile] |
114 |
| - files.forEach(f => { |
115 |
| - f.metadata.lastModified = 123 |
116 |
| - f.designerApplication.data._internalAppBuildDate = 'Foo Date' |
117 |
| - f.designerApplication.version = 'x.x.x' |
118 |
| - |
119 |
| - const savedStepForms = f.designerApplication.data.savedStepForms |
120 |
| - const initialDeckSetupStep = '__INITIAL_DECK_SETUP_STEP__' |
121 |
| - |
122 |
| - // a uuid is randomly generated each time you upload a protocol that is less than version 8_5_0 |
123 |
| - // which is the migration version that adds these keys. Due to this, we need to ignore |
124 |
| - // the uuids |
125 |
| - if ( |
126 |
| - Boolean(savedStepForms[initialDeckSetupStep]) && |
127 |
| - isBelowVersion850 |
128 |
| - ) { |
129 |
| - savedStepForms[initialDeckSetupStep].trashBinLocationUpdate = { |
130 |
| - trashBin: 'trashLocation', |
131 |
| - } |
132 |
| - savedStepForms[initialDeckSetupStep].gripperLocationUpdate = { |
133 |
| - gripper: 'gripperLocation', |
134 |
| - } |
135 |
| - } |
136 |
| - |
137 |
| - Object.values(savedStepForms as Record<string, unknown>).forEach( |
138 |
| - stepForm => { |
139 |
| - const stepFormTyped = stepForm as { |
140 |
| - stepType: string |
141 |
| - dropTip_location?: string |
142 |
| - blowout_location?: string |
143 |
| - } |
144 |
| - if (stepFormTyped.stepType === 'moveLiquid') { |
145 |
| - stepFormTyped.dropTip_location = 'trash drop tip location' |
146 |
| - if ( |
147 |
| - stepFormTyped.blowout_location?.includes('trashBin') ?? |
148 |
| - false |
149 |
| - ) { |
150 |
| - stepFormTyped.blowout_location = 'trash blowout location' |
151 |
| - } |
152 |
| - } |
153 |
| - if (stepFormTyped.stepType === 'mix') { |
154 |
| - stepFormTyped.dropTip_location = 'trash drop tip location' |
155 |
| - stepFormTyped.blowout_location = 'trash blowout location' |
156 |
| - } |
157 |
| - } |
158 |
| - ) |
159 |
| - |
160 |
| - f.commands.forEach((command: { key: string }) => { |
161 |
| - if ('key' in command) command.key = '123' |
162 |
| - }) |
163 |
| - }) |
164 |
| - |
165 |
| - expectDeepEqual(assert, savedFile, expectedFile) |
166 |
| - }) |
167 |
| - }) |
168 |
| -} |
0 commit comments