Skip to content

Commit

Permalink
Allow scanning if continuous export is disabled and there's no USB dr…
Browse files Browse the repository at this point in the history
…ive (#5566)
  • Loading branch information
arsalansufi authored Oct 30, 2024
1 parent a86aa3f commit ddf5db4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
29 changes: 21 additions & 8 deletions apps/scan/backend/src/app_flow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 () => {
Expand Down
7 changes: 5 additions & 2 deletions apps/scan/backend/src/app_flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ddf5db4

Please sign in to comment.