Skip to content

Commit

Permalink
Little fixes and typechecks and handling of trash files
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoster1 committed Nov 6, 2023
1 parent 574a1d9 commit 07994f9
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 9 deletions.
9 changes: 6 additions & 3 deletions app-shell-odd/src/system-update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,12 @@ export function getCachedSystemUpdateFiles(

function getInfoFromUpdateSet(
filepaths: ReleaseSetFilepaths
): Promise<{ version: string; releaseNotes: string }> {
): Promise<{ version: string; releaseNotes: string | null }> {
const version = getLatestVersion()

Check warning on line 357 in app-shell-odd/src/system-update/index.ts

View check run for this annotation

Codecov / codecov/patch

app-shell-odd/src/system-update/index.ts#L357

Added line #L357 was not covered by tests
return readFile(filepaths.releaseNotes, 'utf8')
const releaseNotesContentPromise = filepaths.releaseNotes
? readFile(filepaths.releaseNotes, 'utf8')
: new Promise<string | null>(resolve => resolve(null))
return releaseNotesContentPromise
.then(releaseNotes => ({

Check warning on line 362 in app-shell-odd/src/system-update/index.ts

View check run for this annotation

Codecov / codecov/patch

app-shell-odd/src/system-update/index.ts#L360-L362

Added lines #L360 - L362 were not covered by tests
version: version,
releaseNotes,
Expand All @@ -365,7 +368,7 @@ function getInfoFromUpdateSet(

function cacheUpdateSet(
filepaths: ReleaseSetFilepaths
): Promise<{ version: string; releaseNotes: string }> {
): Promise<{ version: string; releaseNotes: string | null }> {
systemUpdateSet = filepaths
return getInfoFromUpdateSet(systemUpdateSet)

Check warning on line 373 in app-shell-odd/src/system-update/index.ts

View check run for this annotation

Codecov / codecov/patch

app-shell-odd/src/system-update/index.ts#L372-L373

Added lines #L372 - L373 were not covered by tests
}
1 change: 0 additions & 1 deletion app-shell-odd/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type {
Action,
Error as PlainError,
} from '@opentrons/app/src/redux/types'

import type { Logger } from '@opentrons/app/src/logger'
export type { Action, PlainError }

Expand Down
10 changes: 9 additions & 1 deletion app-shell-odd/src/usb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ const FLEX_USB_MOUNT_DIR = '/media/'
const FLEX_USB_MOUNT_FILTER = /sd[a-z][0-9]$/
const MOUNT_ENUMERATION_DELAY_MS = 1000

Check warning on line 13 in app-shell-odd/src/usb.ts

View check run for this annotation

Codecov / codecov/patch

app-shell-odd/src/usb.ts#L11-L13

Added lines #L11 - L13 were not covered by tests

// These directories are generated by OSX and contain entries for all
// the files that were deleted from a mass storage device, or search index
// data
const isWeirdDirectoryAndShouldSkip = (dirName: string): boolean =>
['.Trashes', '.Spotlight']
.map(keyword => dirName.includes(keyword))

Check warning on line 20 in app-shell-odd/src/usb.ts

View check run for this annotation

Codecov / codecov/patch

app-shell-odd/src/usb.ts#L18-L20

Added lines #L18 - L20 were not covered by tests
.reduce((prev, current) => prev || current, false)

const enumerateMassStorage = (path: string): Promise<string[]> =>
fsPromises

Check warning on line 24 in app-shell-odd/src/usb.ts

View check run for this annotation

Codecov / codecov/patch

app-shell-odd/src/usb.ts#L23-L24

Added lines #L23 - L24 were not covered by tests
.readdir(path)
Expand All @@ -26,7 +34,7 @@ const enumerateMassStorage = (path: string): Promise<string[]> =>
.then(entries =>
Promise.all(

Check warning on line 35 in app-shell-odd/src/usb.ts

View check run for this annotation

Codecov / codecov/patch

app-shell-odd/src/usb.ts#L35

Added line #L35 was not covered by tests
entries.map(entry =>
entry.isDirectory()
entry.isDirectory() && !isWeirdDirectoryAndShouldSkip(entry.name)
? enumerateMassStorage(join(path, entry.name))
: new Promise<string[]>(resolve =>
resolve([join(path, entry.name)])

Check warning on line 40 in app-shell-odd/src/usb.ts

View check run for this annotation

Codecov / codecov/patch

app-shell-odd/src/usb.ts#L40

Added line #L40 was not covered by tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('RobotSystemVersion', () => {
currentVersion: 'mock7.0.0',
isUpdateAvailable: false,
setCurrentOption: mockBack,
robotUpdateInfo: null,
}
mockRobotSystemVersionModal.mockReturnValue(
<div>mock RobotSystemVersionModal</div>
Expand All @@ -58,6 +59,11 @@ describe('RobotSystemVersion', () => {
props = {
...props,
isUpdateAvailable: true,
robotUpdateInfo: {
target: 'flex',
version: 'mock1.2.3',
releaseNotes: null,
},
}
const [{ getByText }] = render(props)
getByText('Update available')
Expand Down
3 changes: 2 additions & 1 deletion app/src/pages/OnDeviceDisplay/__tests__/UpdateRobot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { renderWithProviders } from '@opentrons/components'
import { i18n } from '../../../i18n'

import * as RobotUpdate from '../../../redux/robot-update'
import type { RobotUpdateSession } from '../../../redux/robot-update/types'
import { getLocalRobot } from '../../../redux/discovery'

import { UpdateRobot } from '../UpdateRobot'
Expand Down Expand Up @@ -60,7 +61,7 @@ const mockRobot = {
serverHealthStatus: null,
} as any

const mockSession = {
const mockSession: RobotUpdateSession = {
robotName: mockRobot.name,
fileInfo: null,
token: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { renderWithProviders } from '@opentrons/components'
import { i18n } from '../../../i18n'

import * as RobotUpdate from '../../../redux/robot-update'
import type { RobotUpdateSession } from '../../../redux/robot-update/types'
import { getLocalRobot } from '../../../redux/discovery'

import { UpdateRobotDuringOnboarding } from '../UpdateRobotDuringOnboarding'
Expand Down Expand Up @@ -59,7 +60,7 @@ const mockRobot = {
serverHealthStatus: null,
} as any

const mockSession = {
const mockSession: RobotUpdateSession = {
robotName: mockRobot.name,
fileInfo: null,
token: null,
Expand Down
5 changes: 3 additions & 2 deletions app/src/redux/robot-update/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ export const INITIAL_STATE: RobotUpdateState = {
releaseNotes: null,
downloadProgress: null,
downloadError: null,
force: false,
},
ot2: {
version: null,
releaseNotes: null,
downloadProgress: null,
downloadError: null,
force: false,
},
session: null,
}
Expand Down Expand Up @@ -46,7 +48,7 @@ export const robotUpdateReducer: Reducer<RobotUpdateState, Action> = (
[action.payload.target]: {
...state[action.payload.target],
version: action.payload.version,
force: action.payload.force ?? false,
force: action.payload?.force ?? false,
},
},
}
Expand All @@ -60,7 +62,6 @@ export const robotUpdateReducer: Reducer<RobotUpdateState, Action> = (
...state[action.payload.target],
version: action.payload.version,
releaseNotes: action.payload.releaseNotes,
force: action.payload.force ?? false,
},
},
}
Expand Down

0 comments on commit 07994f9

Please sign in to comment.