Skip to content

Commit

Permalink
feat(scan): remove smartcard reports (#3748)
Browse files Browse the repository at this point in the history
* remove endpoint from scan-backend

* always use printer, never smartcard, in frontend

* change env variable options & default
  • Loading branch information
adghayes authored Jul 20, 2023
1 parent 65fa2bc commit d12b479
Show file tree
Hide file tree
Showing 14 changed files with 168 additions and 995 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ REACT_APP_VX_SKIP_CAST_VOTE_RECORDS_AUTHENTICATION=FALSE
REACT_APP_VX_DISABLE_CVR_ORIGINAL_SNAPSHOTS=FALSE
REACT_APP_VX_CONVERTER=ms-sems
REACT_APP_VX_SCREEN_ORIENTATION=portrait
REACT_APP_VX_PRECINCT_REPORT_DESTINATION=smartcard
REACT_APP_VX_PRECINCT_REPORT_DESTINATION=thermal-sheet-printer
22 changes: 1 addition & 21 deletions apps/scan/backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {
} from '@votingworks/types';
import {
BooleanEnvironmentVariableName,
ScannerReportData,
ScannerReportDataSchema,
isElectionManagerAuth,
isFeatureFlagEnabled,
singlePrecinctSelectionFor,
Expand All @@ -25,7 +23,7 @@ import {
ExportCastVoteRecordReportToUsbDriveError,
readBallotPackageFromUsb,
} from '@votingworks/backend';
import { assert, err, iter, ok, Result } from '@votingworks/basics';
import { assert, iter, ok, Result } from '@votingworks/basics';
import {
ArtifactAuthenticatorApi,
InsertedSmartCardAuthApi,
Expand Down Expand Up @@ -355,24 +353,6 @@ function buildApi(
supportsUltrasonic(): boolean {
return machine.supportsUltrasonic();
},

async saveScannerReportDataToCard(input: {
scannerReportData: ScannerReportData;
}): Promise<Result<void, Error>> {
const machineState = constructAuthMachineState(workspace);
const authStatus = await auth.getAuthStatus(machineState);
if (authStatus.status !== 'logged_in') {
return err(new Error('User is not logged in'));
}
if (authStatus.user.role !== 'poll_worker') {
return err(new Error('User is not a poll worker'));
}

return await auth.writeCardData(machineState, {
data: input.scannerReportData,
schema: ScannerReportDataSchema,
});
},
});
}

Expand Down
81 changes: 3 additions & 78 deletions apps/scan/backend/src/scanners/custom/app_scan.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
import {
AdjudicationReason,
AdjudicationReasonInfo,
DEFAULT_SYSTEM_SETTINGS,
TEST_JURISDICTION,
} from '@votingworks/types';
import { AdjudicationReason, AdjudicationReasonInfo } from '@votingworks/types';
import waitForExpect from 'wait-for-expect';
import { err, ok, Result, sleep, typedAs } from '@votingworks/basics';
import {
fakeElectionManagerUser,
fakePollWorkerUser,
fakeSessionExpiresAt,
mockOf,
} from '@votingworks/test-utils';
import {
electionFamousNames2021Fixtures,
electionGridLayoutNewHampshireAmherstFixtures,
} from '@votingworks/fixtures';
import {
ALL_PRECINCTS_SELECTION,
ReportSourceMachineType,
ScannerReportData,
ScannerReportDataSchema,
} from '@votingworks/utils';
import { err, ok, sleep, typedAs } from '@votingworks/basics';
import { electionGridLayoutNewHampshireAmherstFixtures } from '@votingworks/fixtures';
import { Logger } from '@votingworks/logging';
import { ErrorCode, mocks } from '@votingworks/custom-scanner';
import { MAX_FAILED_SCAN_ATTEMPTS } from './state_machine';
Expand Down Expand Up @@ -72,8 +52,6 @@ function checkLogs(logger: Logger): void {
);
}

const jurisdiction = TEST_JURISDICTION;

test('configure and scan hmpb', async () => {
await withApp(
{},
Expand Down Expand Up @@ -433,56 +411,3 @@ test('scanning time out', async () => {
}
);
});

test('write scanner report data to card', async () => {
await withApp({}, async ({ apiClient, mockAuth, mockUsbDrive }) => {
await configureApp(apiClient, mockAuth, mockUsbDrive);

mockOf(mockAuth.writeCardData).mockResolvedValue(ok());

const { electionDefinition } = electionFamousNames2021Fixtures;
const { electionHash } = electionDefinition;
const scannerReportData: ScannerReportData = {
ballotCounts: {},
isLiveMode: false,
machineId: '0000',
pollsTransition: 'close_polls',
precinctSelection: ALL_PRECINCTS_SELECTION,
tally: [],
tallyMachineType: ReportSourceMachineType.PRECINCT_SCANNER,
timePollsTransitioned: 0,
timeSaved: 0,
totalBallotsScanned: 0,
};
let result: Result<void, Error>;

mockOf(mockAuth.getAuthStatus).mockResolvedValue({
status: 'logged_out',
reason: 'no_card',
});
result = await apiClient.saveScannerReportDataToCard({ scannerReportData });
expect(result).toEqual(err(new Error('User is not logged in')));

mockOf(mockAuth.getAuthStatus).mockResolvedValue({
status: 'logged_in',
user: fakeElectionManagerUser(electionDefinition),
sessionExpiresAt: fakeSessionExpiresAt(),
});
result = await apiClient.saveScannerReportDataToCard({ scannerReportData });
expect(result).toEqual(err(new Error('User is not a poll worker')));

mockOf(mockAuth.getAuthStatus).mockResolvedValue({
status: 'logged_in',
user: fakePollWorkerUser(electionDefinition),
sessionExpiresAt: fakeSessionExpiresAt(),
});
result = await apiClient.saveScannerReportDataToCard({ scannerReportData });
expect(result).toEqual(ok());
expect(mockAuth.writeCardData).toHaveBeenCalledTimes(1);
expect(mockAuth.writeCardData).toHaveBeenNthCalledWith(
1,
{ ...DEFAULT_SYSTEM_SETTINGS, electionHash, jurisdiction },
{ data: scannerReportData, schema: ScannerReportDataSchema }
);
});
});
7 changes: 0 additions & 7 deletions apps/scan/frontend/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,3 @@ export const supportsUltrasonic = {
return useQuery(this.queryKey(), () => apiClient.supportsUltrasonic());
},
} as const;

export const saveScannerReportDataToCard = {
useMutation() {
const apiClient = useApiClient();
return useMutation(apiClient.saveScannerReportDataToCard);
},
} as const;
Loading

0 comments on commit d12b479

Please sign in to comment.