Skip to content

Commit

Permalink
fix(app): check firmware update status in instrument cards (#14110)
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 authored Dec 13, 2023
1 parent b1d774d commit 59c1042
Show file tree
Hide file tree
Showing 16 changed files with 256 additions and 103 deletions.
6 changes: 6 additions & 0 deletions app-shell-odd/src/config/__fixtures__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
ConfigV18,
ConfigV19,
ConfigV20,
ConfigV21,
} from '@opentrons/app/src/redux/config/types'

export const MOCK_CONFIG_V12: ConfigV12 = {
Expand Down Expand Up @@ -129,3 +130,8 @@ export const MOCK_CONFIG_V20: ConfigV20 = {
},
},
}

export const MOCK_CONFIG_V21: ConfigV21 = {
...MOCK_CONFIG_V20,
version: 21,
}
30 changes: 19 additions & 11 deletions app-shell-odd/src/config/__tests__/migrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,81 +9,89 @@ import {
MOCK_CONFIG_V18,
MOCK_CONFIG_V19,
MOCK_CONFIG_V20,
MOCK_CONFIG_V21,
} from '../__fixtures__'
import { migrate } from '../migrate'

const NEWEST_VERSION = 20
const NEWEST_VERSION = 21

describe('config migration', () => {
it('should migrate version 12 to latest', () => {
const v12Config = MOCK_CONFIG_V12
const result = migrate(v12Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 13 to latest', () => {
const v13Config = MOCK_CONFIG_V13
const result = migrate(v13Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 14 to latest', () => {
const v14Config = MOCK_CONFIG_V14
const result = migrate(v14Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 15 to latest', () => {
const v15Config = MOCK_CONFIG_V15
const result = migrate(v15Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 16 to latest', () => {
const v16Config = MOCK_CONFIG_V16
const result = migrate(v16Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 17 to latest', () => {
const v17Config = MOCK_CONFIG_V17
const result = migrate(v17Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migration version 18 to latest', () => {
const v18Config = MOCK_CONFIG_V18
const result = migrate(v18Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migration version 19 to latest', () => {
const v19Config = MOCK_CONFIG_V19
const result = migrate(v19Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should keep version 20', () => {
it('should migration version 20 to latest', () => {
const v20Config = MOCK_CONFIG_V20
const result = migrate(v20Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(v20Config)
expect(result).toEqual(MOCK_CONFIG_V21)
})
it('should keep version 21', () => {
const v21Config = MOCK_CONFIG_V21
const result = migrate(v21Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(v21Config)
})
})
21 changes: 20 additions & 1 deletion app-shell-odd/src/config/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
ConfigV18,
ConfigV19,
ConfigV20,
ConfigV21,
} from '@opentrons/app/src/redux/config/types'
// format
// base config v12 defaults
Expand Down Expand Up @@ -169,6 +170,21 @@ const toVersion20 = (prevConfig: ConfigV19): ConfigV20 => {
}
}

const toVersion21 = (prevConfig: ConfigV20): ConfigV21 => {
return {
...prevConfig,
version: 21 as const,
onDeviceDisplaySettings: {
...prevConfig.onDeviceDisplaySettings,
unfinishedUnboxingFlowRoute:
prevConfig.onDeviceDisplaySettings.unfinishedUnboxingFlowRoute ===
'/dashboard'
? null
: prevConfig.onDeviceDisplaySettings.unfinishedUnboxingFlowRoute,
},
}
}

const MIGRATIONS: [
(prevConfig: ConfigV12) => ConfigV13,
(prevConfig: ConfigV13) => ConfigV14,
Expand All @@ -177,7 +193,8 @@ const MIGRATIONS: [
(prevConfig: ConfigV16) => ConfigV17,
(prevConfig: ConfigV17) => ConfigV18,
(prevConfig: ConfigV18) => ConfigV19,
(prevConfig: ConfigV19) => ConfigV20
(prevConfig: ConfigV19) => ConfigV20,
(prevConfig: ConfigV20) => ConfigV21
] = [
toVersion13,
toVersion14,
Expand All @@ -187,6 +204,7 @@ const MIGRATIONS: [
toVersion18,
toVersion19,
toVersion20,
toVersion21,
]

export const DEFAULTS: Config = migrate(DEFAULTS_V12)
Expand All @@ -202,6 +220,7 @@ export function migrate(
| ConfigV18
| ConfigV19
| ConfigV20
| ConfigV21
): Config {
let result = prevConfig
// loop through the migrations, skipping any migrations that are unnecessary
Expand Down
6 changes: 6 additions & 0 deletions app-shell/src/config/__fixtures__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
ConfigV18,
ConfigV19,
ConfigV20,
ConfigV21,
} from '@opentrons/app/src/redux/config/types'

export const MOCK_CONFIG_V0: ConfigV0 = {
Expand Down Expand Up @@ -262,3 +263,8 @@ export const MOCK_CONFIG_V20: ConfigV20 = {
},
},
}

export const MOCK_CONFIG_V21: ConfigV21 = {
...MOCK_CONFIG_V20,
version: 21,
}
55 changes: 32 additions & 23 deletions app-shell/src/config/__tests__/migrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,173 +21,182 @@ import {
MOCK_CONFIG_V18,
MOCK_CONFIG_V19,
MOCK_CONFIG_V20,
MOCK_CONFIG_V21,
} from '../__fixtures__'
import { migrate } from '../migrate'

const NEWEST_VERSION = 20
const NEWEST_VERSION = 21

describe('config migration', () => {
it('should migrate version 0 to latest', () => {
const v0Config = MOCK_CONFIG_V0
const result = migrate(v0Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 1 to latest', () => {
const v1Config = MOCK_CONFIG_V1
const result = migrate(v1Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 2 to latest', () => {
const v2Config = MOCK_CONFIG_V2
const result = migrate(v2Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 3 to latest', () => {
const v3Config = MOCK_CONFIG_V3
const result = migrate(v3Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 4 to latest', () => {
const v4Config = MOCK_CONFIG_V4
const result = migrate(v4Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 5 to latest', () => {
const v5Config = MOCK_CONFIG_V5
const result = migrate(v5Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 6 to latest', () => {
const v6Config = MOCK_CONFIG_V6
const result = migrate(v6Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 7 to latest', () => {
const v7Config = MOCK_CONFIG_V7
const result = migrate(v7Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 8 to latest', () => {
const v8Config = MOCK_CONFIG_V8
const result = migrate(v8Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 9 to latest', () => {
const v9Config = MOCK_CONFIG_V9
const result = migrate(v9Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 10 to latest', () => {
const v10Config = MOCK_CONFIG_V10
const result = migrate(v10Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 11 to latest', () => {
const v11Config = MOCK_CONFIG_V11
const result = migrate(v11Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 12 to latest', () => {
const v12Config = MOCK_CONFIG_V12
const result = migrate(v12Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 13 to latest', () => {
const v13Config = MOCK_CONFIG_V13
const result = migrate(v13Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 14 to latest', () => {
const v14Config = MOCK_CONFIG_V14
const result = migrate(v14Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 15 to latest', () => {
const v15Config = MOCK_CONFIG_V15
const result = migrate(v15Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 16 to latest', () => {
const v16Config = MOCK_CONFIG_V16
const result = migrate(v16Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})

it('should migrate version 17 to latest', () => {
const v17Config = MOCK_CONFIG_V17
const result = migrate(v17Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})
it('should migrate version 18 to latest', () => {
const v18Config = MOCK_CONFIG_V18
const result = migrate(v18Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})
it('should keep migrate version 19 to latest', () => {
const v19Config = MOCK_CONFIG_V19
const result = migrate(v19Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V20)
expect(result).toEqual(MOCK_CONFIG_V21)
})
it('should keep version 20', () => {
it('should migration version 20 to latest', () => {
const v20Config = MOCK_CONFIG_V20
const result = migrate(v20Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V21)
})
it('should keep version 21', () => {
const v21Config = MOCK_CONFIG_V21
const result = migrate(v21Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(v20Config)
expect(result).toEqual(v21Config)
})
})
Loading

0 comments on commit 59c1042

Please sign in to comment.