@opentrons/shared-data 0.1.2-alpha.1 → 0.1.2-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/js/__tests__/__snapshots__/pipettes.test.ts.snap +0 -5969
- package/js/__tests__/deckSchemas.test.ts +0 -87
- package/js/__tests__/errors.test.js +0 -21
- package/js/__tests__/getAreSlotsAdjacent.test.ts +0 -128
- package/js/__tests__/getWellNamePerMultiTip.test.ts +0 -162
- package/js/__tests__/labwareDefQuirks.test.ts +0 -38
- package/js/__tests__/labwareDefSchemaV1.test.ts +0 -82
- package/js/__tests__/labwareDefSchemaV2.test.ts +0 -298
- package/js/__tests__/moduleAccessors.test.ts +0 -50
- package/js/__tests__/moduleSpecsSchema.test.ts +0 -77
- package/js/__tests__/pipetteSchemaV2.test.ts +0 -107
- package/js/__tests__/pipetteSpecSchemas.test.ts +0 -48
- package/js/__tests__/pipettes.test.ts +0 -58
- package/js/__tests__/protocolSchemaV4.test.ts +0 -137
- package/js/__tests__/protocolSchemaV5.test.ts +0 -137
- package/js/__tests__/protocolSchemaV6.test.ts +0 -132
- package/js/__tests__/protocolSchemaV7.test.ts +0 -64
- package/js/__tests__/protocolValidation.test.ts +0 -83
- package/js/__tests__/sortWells.test.ts +0 -40
- package/js/__tests__/splitWellsOnColumn.test.ts +0 -21
- package/js/__tests__/validateErrors.test.js +0 -34
- package/js/constants.ts +0 -405
- package/js/cypressUtils.ts +0 -35
- package/js/errors.ts +0 -33
- package/js/fixtures.ts +0 -156
- package/js/getLabware.ts +0 -145
- package/js/gripper.ts +0 -29
- package/js/helpers/__tests__/getAdapterName.test.ts +0 -31
- package/js/helpers/__tests__/getDeckDefFromLoadedLabware.test.ts +0 -12
- package/js/helpers/__tests__/getSimplestFlexDeckConfig.test.ts +0 -176
- package/js/helpers/__tests__/getVectorDifference.test.ts +0 -25
- package/js/helpers/__tests__/getVectorSum.test.ts +0 -21
- package/js/helpers/__tests__/labwareInference.test.ts +0 -84
- package/js/helpers/__tests__/orderWells.test.ts +0 -87
- package/js/helpers/__tests__/parseProtocolData.test.ts +0 -165
- package/js/helpers/__tests__/volume.test.ts +0 -108
- package/js/helpers/__tests__/wellSets.test.ts +0 -352
- package/js/helpers/get96Channel384WellPlateWells.ts +0 -44
- package/js/helpers/getAddressableAreasInProtocol.ts +0 -98
- package/js/helpers/getLoadedLabwareDefinitionsByUri.ts +0 -30
- package/js/helpers/getModuleVizDims.ts +0 -118
- package/js/helpers/getOccludedSlotCountForModule.ts +0 -13
- package/js/helpers/getSimplestFlexDeckConfig.ts +0 -183
- package/js/helpers/getVectorDifference.ts +0 -12
- package/js/helpers/getVectorSum.ts +0 -12
- package/js/helpers/getWellNamePerMultiTip.ts +0 -86
- package/js/helpers/getWellTotalVolume.ts +0 -16
- package/js/helpers/index.ts +0 -348
- package/js/helpers/labwareInference.ts +0 -92
- package/js/helpers/orderWells.ts +0 -69
- package/js/helpers/parseProtocolData.ts +0 -141
- package/js/helpers/volume.ts +0 -35
- package/js/helpers/wellIsRect.ts +0 -6
- package/js/helpers/wellSets.ts +0 -155
- package/js/index.ts +0 -14
- package/js/labwareTools/__tests__/__snapshots__/createIrregularLabware.test.ts.snap +0 -3
- package/js/labwareTools/__tests__/__snapshots__/createLabware.test.ts.snap +0 -3
- package/js/labwareTools/__tests__/createDefaultDisplayName.test.ts +0 -111
- package/js/labwareTools/__tests__/createIrregularLabware.test.ts +0 -226
- package/js/labwareTools/__tests__/createLabware.test.ts +0 -147
- package/js/labwareTools/index.ts +0 -452
- package/js/modules.ts +0 -97
- package/js/pipettes.ts +0 -89
- package/js/protocols.ts +0 -290
- package/js/schema.ts +0 -80
- package/js/scripts/generateDeckLayersFromSVG.js +0 -46
- package/js/titleCase.ts +0 -30
- package/js/types.ts +0 -561
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/** Ensure that protocol schema v4 definition itself functions as intended,
|
|
2
|
-
* and that all v4 protocol fixtures will validate */
|
|
3
|
-
import Ajv from 'ajv'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import glob from 'glob'
|
|
6
|
-
import omit from 'lodash/omit'
|
|
7
|
-
|
|
8
|
-
import protocolSchema from '../../protocol/schemas/4.json'
|
|
9
|
-
import labwareV2Schema from '../../labware/schemas/2.json'
|
|
10
|
-
import simpleV4Fixture from '../../protocol/fixtures/4/simpleV4.json'
|
|
11
|
-
|
|
12
|
-
const fixturesGlobPath = path.join(
|
|
13
|
-
__dirname,
|
|
14
|
-
'../../protocol/fixtures/4/**/*.json'
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
const protocolFixtures = glob.sync(fixturesGlobPath)
|
|
18
|
-
const ajv = new Ajv({ allErrors: true, jsonPointers: true })
|
|
19
|
-
|
|
20
|
-
// v4 protocol schema contains reference to v2 labware schema, so give AJV access to it
|
|
21
|
-
ajv.addSchema(labwareV2Schema)
|
|
22
|
-
|
|
23
|
-
const validateProtocol = ajv.compile(protocolSchema)
|
|
24
|
-
|
|
25
|
-
describe('validate v4 protocol fixtures under JSON schema', () => {
|
|
26
|
-
protocolFixtures.forEach(protocolPath => {
|
|
27
|
-
it(path.basename(protocolPath), () => {
|
|
28
|
-
const protocol = require(protocolPath)
|
|
29
|
-
|
|
30
|
-
const valid = validateProtocol(protocol)
|
|
31
|
-
const validationErrors = validateProtocol.errors
|
|
32
|
-
|
|
33
|
-
if (validationErrors) {
|
|
34
|
-
console.log(JSON.stringify(validationErrors, null, 4))
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
expect(validationErrors).toBe(null)
|
|
38
|
-
expect(valid).toBe(true)
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
describe('ensure bad protocol data fails validation', () => {
|
|
44
|
-
it('$otSharedSchema is required to be "#/protocol/schemas/4"', () => {
|
|
45
|
-
expect(validateProtocol(omit(simpleV4Fixture, '$otSharedSchema'))).toBe(
|
|
46
|
-
false
|
|
47
|
-
)
|
|
48
|
-
expect(
|
|
49
|
-
validateProtocol({
|
|
50
|
-
...simpleV4Fixture,
|
|
51
|
-
$otSharedSchema: '#/protocol/schemas/5',
|
|
52
|
-
})
|
|
53
|
-
).toBe(false)
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('schemaVersion is required to be 4', () => {
|
|
57
|
-
expect(validateProtocol(omit(simpleV4Fixture, 'schemaVersion'))).toBe(false)
|
|
58
|
-
expect(validateProtocol({ ...simpleV4Fixture, schemaVersion: 3 })).toBe(
|
|
59
|
-
false
|
|
60
|
-
)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('reject bad values in "pipettes" objects', () => {
|
|
64
|
-
const badPipettes = {
|
|
65
|
-
missingKeys: {},
|
|
66
|
-
missingName: { mount: 'left' },
|
|
67
|
-
missingMount: { name: 'pipetteName' },
|
|
68
|
-
badMount: { mount: 'blah', name: 'pipetteName' },
|
|
69
|
-
hasAdditionalProperties: {
|
|
70
|
-
mount: 'left',
|
|
71
|
-
name: 'pipetteName',
|
|
72
|
-
blah: 'blah',
|
|
73
|
-
},
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
Object.entries(badPipettes).forEach(([pipetteId, pipette]) => {
|
|
77
|
-
expect(
|
|
78
|
-
validateProtocol({
|
|
79
|
-
...simpleV4Fixture,
|
|
80
|
-
pipettes: {
|
|
81
|
-
...simpleV4Fixture.pipettes,
|
|
82
|
-
[pipetteId]: pipette,
|
|
83
|
-
},
|
|
84
|
-
})
|
|
85
|
-
).toBe(false)
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
it('reject bad values in "labware" objects', () => {
|
|
90
|
-
const badLabware = {
|
|
91
|
-
noSlot: { definitionId: 'defId' },
|
|
92
|
-
noDefId: { slot: '1' },
|
|
93
|
-
hasAdditionalProperties: {
|
|
94
|
-
slot: '1',
|
|
95
|
-
definitionId: 'defId',
|
|
96
|
-
blah: 'blah',
|
|
97
|
-
},
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
Object.entries(badLabware).forEach(([labwareId, labware]) => {
|
|
101
|
-
expect(
|
|
102
|
-
validateProtocol({
|
|
103
|
-
...simpleV4Fixture,
|
|
104
|
-
labware: {
|
|
105
|
-
...simpleV4Fixture.labware,
|
|
106
|
-
[labwareId]: labware,
|
|
107
|
-
},
|
|
108
|
-
})
|
|
109
|
-
).toBe(false)
|
|
110
|
-
})
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
it('reject bad values in "modules" objects', () => {
|
|
114
|
-
const badModules = {
|
|
115
|
-
badModuleType: { slot: '1', moduleType: 'fake' },
|
|
116
|
-
noSlot: { moduleType: 'thermocycler' },
|
|
117
|
-
noModuleType: { slot: '1' },
|
|
118
|
-
hasAdditionalProperties: {
|
|
119
|
-
slot: '1',
|
|
120
|
-
moduleType: 'thermocycler',
|
|
121
|
-
blah: 'blah',
|
|
122
|
-
},
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
Object.entries(badModules).forEach(([moduleId, module]) => {
|
|
126
|
-
expect(
|
|
127
|
-
validateProtocol({
|
|
128
|
-
...simpleV4Fixture,
|
|
129
|
-
modules: {
|
|
130
|
-
...simpleV4Fixture.modules,
|
|
131
|
-
[moduleId]: module,
|
|
132
|
-
},
|
|
133
|
-
})
|
|
134
|
-
).toBe(false)
|
|
135
|
-
})
|
|
136
|
-
})
|
|
137
|
-
})
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/** Ensure that protocol schema v5 definition itself functions as intended,
|
|
2
|
-
* and that all v5 protocol fixtures will validate */
|
|
3
|
-
import Ajv from 'ajv'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import glob from 'glob'
|
|
6
|
-
import omit from 'lodash/omit'
|
|
7
|
-
|
|
8
|
-
import protocolSchema from '../../protocol/schemas/5.json'
|
|
9
|
-
import labwareV2Schema from '../../labware/schemas/2.json'
|
|
10
|
-
import simpleV5Fixture from '../../protocol/fixtures/5/simpleV5.json'
|
|
11
|
-
|
|
12
|
-
const fixturesGlobPath = path.join(
|
|
13
|
-
__dirname,
|
|
14
|
-
'../../protocol/fixtures/5/**/*.json'
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
const protocolFixtures = glob.sync(fixturesGlobPath)
|
|
18
|
-
const ajv = new Ajv({ allErrors: true, jsonPointers: true })
|
|
19
|
-
|
|
20
|
-
// v5 protocol schema contains reference to v2 labware schema, so give AJV access to it
|
|
21
|
-
ajv.addSchema(labwareV2Schema)
|
|
22
|
-
|
|
23
|
-
const validateProtocol = ajv.compile(protocolSchema)
|
|
24
|
-
|
|
25
|
-
describe('validate v5 protocol fixtures under JSON schema', () => {
|
|
26
|
-
protocolFixtures.forEach(protocolPath => {
|
|
27
|
-
it(path.basename(protocolPath), () => {
|
|
28
|
-
const protocol = require(protocolPath)
|
|
29
|
-
|
|
30
|
-
const valid = validateProtocol(protocol)
|
|
31
|
-
const validationErrors = validateProtocol.errors
|
|
32
|
-
|
|
33
|
-
if (validationErrors) {
|
|
34
|
-
console.log(JSON.stringify(validationErrors, null, 4))
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
expect(validationErrors).toBe(null)
|
|
38
|
-
expect(valid).toBe(true)
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
describe('ensure bad protocol data fails validation', () => {
|
|
44
|
-
it('$otSharedSchema is required to be "#/protocol/schemas/5"', () => {
|
|
45
|
-
expect(validateProtocol(omit(simpleV5Fixture, '$otSharedSchema'))).toBe(
|
|
46
|
-
false
|
|
47
|
-
)
|
|
48
|
-
expect(
|
|
49
|
-
validateProtocol({
|
|
50
|
-
...simpleV5Fixture,
|
|
51
|
-
$otSharedSchema: '#/protocol/schemas/6',
|
|
52
|
-
})
|
|
53
|
-
).toBe(false)
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('schemaVersion is required to be 5', () => {
|
|
57
|
-
expect(validateProtocol(omit(simpleV5Fixture, 'schemaVersion'))).toBe(false)
|
|
58
|
-
expect(validateProtocol({ ...simpleV5Fixture, schemaVersion: 3 })).toBe(
|
|
59
|
-
false
|
|
60
|
-
)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('reject bad values in "pipettes" objects', () => {
|
|
64
|
-
const badPipettes = {
|
|
65
|
-
missingKeys: {},
|
|
66
|
-
missingName: { mount: 'left' },
|
|
67
|
-
missingMount: { name: 'pipetteName' },
|
|
68
|
-
badMount: { mount: 'blah', name: 'pipetteName' },
|
|
69
|
-
hasAdditionalProperties: {
|
|
70
|
-
mount: 'left',
|
|
71
|
-
name: 'pipetteName',
|
|
72
|
-
blah: 'blah',
|
|
73
|
-
},
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
Object.entries(badPipettes).forEach(([pipetteId, pipette]) => {
|
|
77
|
-
expect(
|
|
78
|
-
validateProtocol({
|
|
79
|
-
...simpleV5Fixture,
|
|
80
|
-
pipettes: {
|
|
81
|
-
...simpleV5Fixture.pipettes,
|
|
82
|
-
[pipetteId]: pipette,
|
|
83
|
-
},
|
|
84
|
-
})
|
|
85
|
-
).toBe(false)
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
it('reject bad values in "labware" objects', () => {
|
|
90
|
-
const badLabware = {
|
|
91
|
-
noSlot: { definitionId: 'defId' },
|
|
92
|
-
noDefId: { slot: '1' },
|
|
93
|
-
hasAdditionalProperties: {
|
|
94
|
-
slot: '1',
|
|
95
|
-
definitionId: 'defId',
|
|
96
|
-
blah: 'blah',
|
|
97
|
-
},
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
Object.entries(badLabware).forEach(([labwareId, labware]) => {
|
|
101
|
-
expect(
|
|
102
|
-
validateProtocol({
|
|
103
|
-
...simpleV5Fixture,
|
|
104
|
-
labware: {
|
|
105
|
-
...simpleV5Fixture.labware,
|
|
106
|
-
[labwareId]: labware,
|
|
107
|
-
},
|
|
108
|
-
})
|
|
109
|
-
).toBe(false)
|
|
110
|
-
})
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
it('reject bad values in "modules" objects', () => {
|
|
114
|
-
const badModules = {
|
|
115
|
-
badModuleType: { slot: '1', moduleType: 'fake' },
|
|
116
|
-
noSlot: { moduleType: 'thermocycler' },
|
|
117
|
-
noModuleType: { slot: '1' },
|
|
118
|
-
hasAdditionalProperties: {
|
|
119
|
-
slot: '1',
|
|
120
|
-
moduleType: 'thermocycler',
|
|
121
|
-
blah: 'blah',
|
|
122
|
-
},
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
Object.entries(badModules).forEach(([moduleId, module]) => {
|
|
126
|
-
expect(
|
|
127
|
-
validateProtocol({
|
|
128
|
-
...simpleV5Fixture,
|
|
129
|
-
modules: {
|
|
130
|
-
...simpleV5Fixture.modules,
|
|
131
|
-
[moduleId]: module,
|
|
132
|
-
},
|
|
133
|
-
})
|
|
134
|
-
).toBe(false)
|
|
135
|
-
})
|
|
136
|
-
})
|
|
137
|
-
})
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/** Ensure that protocol schema v6 definition itself functions as intended,
|
|
2
|
-
* and that all v6 protocol fixtures will validate */
|
|
3
|
-
import Ajv from 'ajv'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import glob from 'glob'
|
|
6
|
-
import omit from 'lodash/omit'
|
|
7
|
-
|
|
8
|
-
import protocolSchema from '../../protocol/schemas/6.json'
|
|
9
|
-
import labwareV2Schema from '../../labware/schemas/2.json'
|
|
10
|
-
import simpleV6Fixture from '../../protocol/fixtures/6/simpleV6.json'
|
|
11
|
-
|
|
12
|
-
const fixturesGlobPath = path.join(
|
|
13
|
-
__dirname,
|
|
14
|
-
'../../protocol/fixtures/6/**/*.json'
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
const protocolFixtures = glob.sync(fixturesGlobPath)
|
|
18
|
-
const ajv = new Ajv({ allErrors: true, jsonPointers: true })
|
|
19
|
-
|
|
20
|
-
// v6 protocol schema contains reference to v2 labware schema, so give AJV access to it
|
|
21
|
-
ajv.addSchema(labwareV2Schema)
|
|
22
|
-
|
|
23
|
-
const validateProtocol = ajv.compile(protocolSchema)
|
|
24
|
-
|
|
25
|
-
describe('validate v6 protocol fixtures under JSON schema', () => {
|
|
26
|
-
protocolFixtures.forEach(protocolPath => {
|
|
27
|
-
it(path.basename(protocolPath), () => {
|
|
28
|
-
const protocol = require(protocolPath)
|
|
29
|
-
|
|
30
|
-
const valid = validateProtocol(protocol)
|
|
31
|
-
const validationErrors = validateProtocol.errors
|
|
32
|
-
|
|
33
|
-
if (validationErrors) {
|
|
34
|
-
console.log(JSON.stringify(validationErrors, null, 4))
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
expect(validationErrors).toBe(null)
|
|
38
|
-
expect(valid).toBe(true)
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
describe('ensure bad protocol data fails validation', () => {
|
|
44
|
-
it('$otSharedSchema is required to be "#/protocol/schemas/6"', () => {
|
|
45
|
-
expect(validateProtocol(omit(simpleV6Fixture, '$otSharedSchema'))).toBe(
|
|
46
|
-
false
|
|
47
|
-
)
|
|
48
|
-
expect(
|
|
49
|
-
validateProtocol({
|
|
50
|
-
...simpleV6Fixture,
|
|
51
|
-
$otSharedSchema: '#/protocol/schemas/3',
|
|
52
|
-
})
|
|
53
|
-
).toBe(false)
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('schemaVersion is required to be 6', () => {
|
|
57
|
-
expect(validateProtocol(omit(simpleV6Fixture, 'schemaVersion'))).toBe(false)
|
|
58
|
-
expect(validateProtocol({ ...simpleV6Fixture, schemaVersion: 3 })).toBe(
|
|
59
|
-
false
|
|
60
|
-
)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('reject bad values in "pipettes" objects', () => {
|
|
64
|
-
const badPipettes = {
|
|
65
|
-
missingKeys: {},
|
|
66
|
-
missingName: { mount: 'left' },
|
|
67
|
-
hasAdditionalProperties: {
|
|
68
|
-
mount: 'left',
|
|
69
|
-
name: 'pipetteName',
|
|
70
|
-
blah: 'blah',
|
|
71
|
-
},
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
Object.entries(badPipettes).forEach(([pipetteId, pipette]) => {
|
|
75
|
-
expect(
|
|
76
|
-
validateProtocol({
|
|
77
|
-
...simpleV6Fixture,
|
|
78
|
-
pipettes: {
|
|
79
|
-
...simpleV6Fixture.pipettes,
|
|
80
|
-
[pipetteId]: pipette,
|
|
81
|
-
},
|
|
82
|
-
})
|
|
83
|
-
).toBe(false)
|
|
84
|
-
})
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
it('reject bad values in "labware" objects', () => {
|
|
88
|
-
const badLabware = {
|
|
89
|
-
noDefId: { displayName: 'myLabware' },
|
|
90
|
-
hasAdditionalProperties: {
|
|
91
|
-
slot: '1',
|
|
92
|
-
definitionId: 'defId',
|
|
93
|
-
blah: 'blah',
|
|
94
|
-
},
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
Object.entries(badLabware).forEach(([labwareId, labware]) => {
|
|
98
|
-
expect(
|
|
99
|
-
validateProtocol({
|
|
100
|
-
...simpleV6Fixture,
|
|
101
|
-
labware: {
|
|
102
|
-
...simpleV6Fixture.labware,
|
|
103
|
-
[labwareId]: labware,
|
|
104
|
-
},
|
|
105
|
-
})
|
|
106
|
-
).toBe(false)
|
|
107
|
-
})
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
it('reject bad values in "modules" objects', () => {
|
|
111
|
-
const badModules = {
|
|
112
|
-
noModel: { moduleType: 'thermocycler' },
|
|
113
|
-
hasAdditionalProperties: {
|
|
114
|
-
model: 'thermocycler',
|
|
115
|
-
slot: '1',
|
|
116
|
-
blah: 'blah',
|
|
117
|
-
},
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
Object.entries(badModules).forEach(([moduleId, module]) => {
|
|
121
|
-
expect(
|
|
122
|
-
validateProtocol({
|
|
123
|
-
...simpleV6Fixture,
|
|
124
|
-
modules: {
|
|
125
|
-
...simpleV6Fixture.modules,
|
|
126
|
-
[moduleId]: module,
|
|
127
|
-
},
|
|
128
|
-
})
|
|
129
|
-
).toBe(false)
|
|
130
|
-
})
|
|
131
|
-
})
|
|
132
|
-
})
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/** Ensure that protocol schema v7 definition itself functions as intended,
|
|
2
|
-
* and that all v7 protocol fixtures will validate */
|
|
3
|
-
import Ajv from 'ajv'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import glob from 'glob'
|
|
6
|
-
import omit from 'lodash/omit'
|
|
7
|
-
|
|
8
|
-
import protocolSchema from '../../protocol/schemas/7.json'
|
|
9
|
-
import labwareV2Schema from '../../labware/schemas/2.json'
|
|
10
|
-
import commandV7Schema from '../../command/schemas/7.json'
|
|
11
|
-
import simpleV7Fixture from '../../protocol/fixtures/7/simpleV7.json'
|
|
12
|
-
|
|
13
|
-
const fixturesGlobPath = path.join(
|
|
14
|
-
__dirname,
|
|
15
|
-
'../../protocol/fixtures/7/**/*.json'
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
const protocolFixtures = glob.sync(fixturesGlobPath)
|
|
19
|
-
const ajv = new Ajv({ allErrors: true, jsonPointers: true })
|
|
20
|
-
|
|
21
|
-
// v7 protocol schema contains reference to v2 labware schema, and v7 command schema, so give AJV access to it
|
|
22
|
-
ajv.addSchema(labwareV2Schema)
|
|
23
|
-
ajv.addSchema(commandV7Schema)
|
|
24
|
-
|
|
25
|
-
const validateProtocol = ajv.compile(protocolSchema)
|
|
26
|
-
|
|
27
|
-
describe('validate v7 protocol fixtures under JSON schema', () => {
|
|
28
|
-
protocolFixtures.forEach(protocolPath => {
|
|
29
|
-
it(path.basename(protocolPath), () => {
|
|
30
|
-
const protocol = require(protocolPath)
|
|
31
|
-
|
|
32
|
-
const valid = validateProtocol(protocol)
|
|
33
|
-
const validationErrors = validateProtocol.errors
|
|
34
|
-
|
|
35
|
-
if (validationErrors) {
|
|
36
|
-
console.log(JSON.stringify(validationErrors, null, 4))
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
expect(validationErrors).toBe(null)
|
|
40
|
-
expect(valid).toBe(true)
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
describe('ensure bad protocol data fails validation', () => {
|
|
46
|
-
it('$otSharedSchema is required to be "#/protocol/schemas/7"', () => {
|
|
47
|
-
expect(validateProtocol(omit(simpleV7Fixture, '$otSharedSchema'))).toBe(
|
|
48
|
-
false
|
|
49
|
-
)
|
|
50
|
-
expect(
|
|
51
|
-
validateProtocol({
|
|
52
|
-
...simpleV7Fixture,
|
|
53
|
-
$otSharedSchema: '#/protocol/schemas/3',
|
|
54
|
-
})
|
|
55
|
-
).toBe(false)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it('schemaVersion is required to be 7', () => {
|
|
59
|
-
expect(validateProtocol(omit(simpleV7Fixture, 'schemaVersion'))).toBe(false)
|
|
60
|
-
expect(validateProtocol({ ...simpleV7Fixture, schemaVersion: 3 })).toBe(
|
|
61
|
-
false
|
|
62
|
-
)
|
|
63
|
-
})
|
|
64
|
-
})
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/** Ensure that we can parse all our fixture json protocols, which also
|
|
2
|
-
* ensures that our protocol schemas are correct */
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import glob from 'glob'
|
|
5
|
-
import { validate } from '../protocols'
|
|
6
|
-
import { omit } from 'lodash'
|
|
7
|
-
|
|
8
|
-
const relRoot = path.join(__dirname, '../../protocol/fixtures/')
|
|
9
|
-
|
|
10
|
-
const protocolFixtures4 = glob.sync(
|
|
11
|
-
path.join(__dirname, '../../protocol/fixtures/4/*.json')
|
|
12
|
-
)
|
|
13
|
-
const protocolFixtures5 = glob.sync(
|
|
14
|
-
path.join(__dirname, '../../protocol/fixtures/5/*.json')
|
|
15
|
-
)
|
|
16
|
-
const protocolFixtures6 = glob.sync(
|
|
17
|
-
path.join(__dirname, '../../protocol/fixtures/6/*.json')
|
|
18
|
-
)
|
|
19
|
-
const protocolFixtures7 = glob.sync(
|
|
20
|
-
path.join(__dirname, '../../protocol/fixtures/7/*.json')
|
|
21
|
-
)
|
|
22
|
-
const protocolFixtures8 = glob.sync(
|
|
23
|
-
path.join(__dirname, '../../protocol/fixtures/8/*.json')
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
describe('check that all fixtures can validate', () => {
|
|
27
|
-
const protocolPaths = [
|
|
28
|
-
...protocolFixtures4,
|
|
29
|
-
...protocolFixtures5,
|
|
30
|
-
...protocolFixtures6,
|
|
31
|
-
...protocolFixtures7,
|
|
32
|
-
...protocolFixtures8,
|
|
33
|
-
]
|
|
34
|
-
protocolPaths.forEach(protocolPath =>
|
|
35
|
-
it(`${path.relative(relRoot, protocolPath)}`, () => {
|
|
36
|
-
const protocol = require(protocolPath)
|
|
37
|
-
return validate(protocol)
|
|
38
|
-
})
|
|
39
|
-
)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
describe('test that mutating v8 fixtures causes failure', () => {
|
|
43
|
-
const base = require('../../protocol/fixtures/8/simpleV8.json')
|
|
44
|
-
it('should fail validation with no schema spec', () => {
|
|
45
|
-
const mangled = omit(base, '$otSharedSchema')
|
|
46
|
-
expect.assertions(1)
|
|
47
|
-
return expect(validate(mangled)).rejects.toMatchObject([
|
|
48
|
-
{ keyword: 'Invalid protocol schema requested' },
|
|
49
|
-
])
|
|
50
|
-
})
|
|
51
|
-
it('should fail validation with a schema spec from the future', () => {
|
|
52
|
-
const mangled = { ...base, $otSharedSchema: 'opentronsProtocolSchemaV9' }
|
|
53
|
-
expect.assertions(1)
|
|
54
|
-
return expect(validate(mangled)).rejects.toMatchObject([
|
|
55
|
-
{ keyword: 'Invalid protocol schema requested' },
|
|
56
|
-
])
|
|
57
|
-
})
|
|
58
|
-
it('should fail validation with a mangled schema spec', () => {
|
|
59
|
-
const mangled = { ...base, $otSharedSchema: 'asdhasda' }
|
|
60
|
-
expect.assertions(1)
|
|
61
|
-
return expect(validate(mangled)).rejects.toMatchObject([
|
|
62
|
-
{ keyword: 'Invalid protocol schema requested' },
|
|
63
|
-
])
|
|
64
|
-
})
|
|
65
|
-
it('should fail validation with a mangled command schema spec', () => {
|
|
66
|
-
const mangled = { ...base, commandSchemaId: 'asdasd' }
|
|
67
|
-
return expect(validate(mangled)).rejects.toMatchObject([
|
|
68
|
-
{ keyword: 'Invalid command schema requested' },
|
|
69
|
-
])
|
|
70
|
-
})
|
|
71
|
-
it('should fail validation with a mangled liquid schema spec', () => {
|
|
72
|
-
const mangled = { ...base, liquidSchemaId: 'asdhasdas' }
|
|
73
|
-
return expect(validate(mangled)).rejects.toMatchObject([
|
|
74
|
-
{ keyword: 'Invalid liquid schema requested' },
|
|
75
|
-
])
|
|
76
|
-
})
|
|
77
|
-
it('should fail validation with a mangled command annotation schema spec', () => {
|
|
78
|
-
const mangled = { ...base, commandAnnotationSchemaId: 'asdasd' }
|
|
79
|
-
return expect(validate(mangled)).rejects.toMatchObject([
|
|
80
|
-
{ keyword: 'Invalid command annotation schema requested' },
|
|
81
|
-
])
|
|
82
|
-
})
|
|
83
|
-
})
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { sortWells } from '../helpers'
|
|
2
|
-
|
|
3
|
-
describe('sortWells', () => {
|
|
4
|
-
it('single letters', () => {
|
|
5
|
-
const input = ['A12', 'A2', 'B1', 'B12', 'A1']
|
|
6
|
-
const expected = ['A1', 'B1', 'A2', 'A12', 'B12']
|
|
7
|
-
const result = [...input].sort(sortWells)
|
|
8
|
-
expect(result).toEqual(expected)
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
// just in case we get a 1536-well plate
|
|
12
|
-
it('double letters', () => {
|
|
13
|
-
const input = [
|
|
14
|
-
'AB12',
|
|
15
|
-
'A12',
|
|
16
|
-
'B12',
|
|
17
|
-
'Z12',
|
|
18
|
-
'AA12',
|
|
19
|
-
'AB1',
|
|
20
|
-
'Z1',
|
|
21
|
-
'A1',
|
|
22
|
-
'B1',
|
|
23
|
-
'AA1',
|
|
24
|
-
]
|
|
25
|
-
const expected = [
|
|
26
|
-
'A1',
|
|
27
|
-
'B1',
|
|
28
|
-
'Z1',
|
|
29
|
-
'AA1',
|
|
30
|
-
'AB1',
|
|
31
|
-
'A12',
|
|
32
|
-
'B12',
|
|
33
|
-
'Z12',
|
|
34
|
-
'AA12',
|
|
35
|
-
'AB12',
|
|
36
|
-
]
|
|
37
|
-
const result = [...input].sort(sortWells)
|
|
38
|
-
expect(result).toEqual(expected)
|
|
39
|
-
})
|
|
40
|
-
})
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { splitWellsOnColumn } from '../helpers'
|
|
2
|
-
|
|
3
|
-
describe('test splitWellsOnColumn', () => {
|
|
4
|
-
it('empty array', () => {
|
|
5
|
-
expect(splitWellsOnColumn([])).toEqual([])
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
it('one value', () => {
|
|
9
|
-
expect(splitWellsOnColumn(['A1'])).toEqual([['A1']])
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
it('sort multi-digit wels', () => {
|
|
13
|
-
expect(splitWellsOnColumn(['A1', 'B2', 'C2', 'D3', 'X10', 'X11'])).toEqual([
|
|
14
|
-
['A1'],
|
|
15
|
-
['B2', 'C2'],
|
|
16
|
-
['D3'],
|
|
17
|
-
['X10'],
|
|
18
|
-
['X11'],
|
|
19
|
-
])
|
|
20
|
-
})
|
|
21
|
-
})
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Tests for error data validation
|
|
2
|
-
|
|
3
|
-
import Ajv from 'ajv'
|
|
4
|
-
|
|
5
|
-
import errorDefinitions from '@opentrons/shared-data/errors/definitions/1/errors.json'
|
|
6
|
-
import errorSchema from '@opentrons/shared-data/errors/schemas/1.json'
|
|
7
|
-
|
|
8
|
-
describe('error data should match error schema', () => {
|
|
9
|
-
it('error schema should match', () => {
|
|
10
|
-
const ajv = new Ajv({ allErrors: true })
|
|
11
|
-
const validator = ajv.compile(errorSchema)
|
|
12
|
-
const valid = validator(errorDefinitions)
|
|
13
|
-
const validationFailures = validator.errors
|
|
14
|
-
if (validationFailures) {
|
|
15
|
-
console.log(
|
|
16
|
-
'errors.json does not follow its schema',
|
|
17
|
-
JSON.stringify(validationFailures, null, 4)
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
expect(valid).toBe(true)
|
|
21
|
-
expect(validationFailures).toBeNull()
|
|
22
|
-
})
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
describe('error code unschemad requirements should match', () =>
|
|
26
|
-
Object.entries(errorDefinitions.codes).forEach(
|
|
27
|
-
([errorCode, { category: errorCategory }]) => {
|
|
28
|
-
it(`error code ${errorCode} category is correct`, () => {
|
|
29
|
-
const categoryObj = errorDefinitions.categories[errorCategory] ?? null
|
|
30
|
-
expect(categoryObj).not.toBeNull()
|
|
31
|
-
expect(errorCode).toMatch(new RegExp(`^${categoryObj.codePrefix}.*$`))
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
))
|