diff --git a/apps/scan/backend/src/app_flow.test.ts b/apps/scan/backend/src/app_flow.test.ts index 423796da9c..f64d4a0409 100644 --- a/apps/scan/backend/src/app_flow.test.ts +++ b/apps/scan/backend/src/app_flow.test.ts @@ -270,25 +270,28 @@ test('unconfigured:precinct', async () => { ).toEqual(false); }); -test('insert_usb_drive', async () => { +test('USB drive removed', async () => { const auth = buildMockInsertedSmartCardAuth(); const store = Store.memoryStore(); const mockUsbDrive = createMockUsbDrive(); - const pollWorkerUser = mockPollWorkerUser({ electionKey }); + mockUsbDrive.insertUsbDrive({}); store.setElectionAndJurisdiction({ electionData: electionDefinition.electionData, jurisdiction: TEST_JURISDICTION, electionPackageHash, }); + store.setPrecinctSelection(ALL_PRECINCTS_SELECTION); + store.transitionPolls({ type: 'open_polls', time: Date.now() }); - auth.getAuthStatus.mockResolvedValue({ - status: 'logged_in', - user: pollWorkerUser, - sessionExpiresAt: mockSessionExpiresAt(), - }); + expect( + await isReadyToScan({ + auth, + store, + usbDrive: mockUsbDrive.usbDrive, + }) + ).toEqual(true); - store.setPrecinctSelection(ALL_PRECINCTS_SELECTION); mockUsbDrive.removeUsbDrive(); expect( @@ -298,6 +301,16 @@ test('insert_usb_drive', async () => { usbDrive: mockUsbDrive.usbDrive, }) ).toEqual(false); + + store.setIsContinuousExportEnabled(false); + + expect( + await isReadyToScan({ + auth, + store, + usbDrive: mockUsbDrive.usbDrive, + }) + ).toEqual(true); }); test('logged_in:poll_worker', async () => { diff --git a/apps/scan/backend/src/app_flow.ts b/apps/scan/backend/src/app_flow.ts index f5627a8fc5..523f27c082 100644 --- a/apps/scan/backend/src/app_flow.ts +++ b/apps/scan/backend/src/app_flow.ts @@ -48,8 +48,11 @@ export async function isReadyToScan({ const usbDriveStatus = await usbDrive.status(); - // If there is no USB drive, we can't scan. - if (usbDriveStatus.status !== 'mounted') { + // If continuous CVR export to USB drive is enabled but there's no USB drive, we can't scan. + if ( + store.getIsContinuousExportEnabled() && + usbDriveStatus.status !== 'mounted' + ) { return false; }