Skip to content

Commit

Permalink
admin: remove Batch Export feature (#4141)
Browse files Browse the repository at this point in the history
* remove backend

* rename almost empty test file, to be removed when we remove sems

* remove from frontend
  • Loading branch information
adghayes authored Oct 30, 2023
1 parent 7fe78a2 commit 530112f
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 508 deletions.
96 changes: 0 additions & 96 deletions apps/admin/backend/src/__snapshots__/app.exports.test.ts.snap

This file was deleted.

90 changes: 90 additions & 0 deletions apps/admin/backend/src/__snapshots__/app.sems.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`sems export 1`] = `
{
"aquarium-council-fish": {
"metadata": {
"ballots": 28,
"overvotes": 8,
"undervotes": 6,
},
"tallies": {
"manta-ray": 10,
"pufferfish": 8,
"rockfish": 8,
"triggerfish": 8,
"write-in": 8,
},
},
"best-animal-fish": {
"metadata": {
"ballots": 28,
"overvotes": 2,
"undervotes": 2,
},
"tallies": {
"salmon": 22,
"seahorse": 2,
},
},
"best-animal-mammal": {
"metadata": {
"ballots": 28,
"overvotes": 4,
"undervotes": 2,
},
"tallies": {
"fox": 18,
"horse": 2,
"otter": 2,
},
},
"fishing": {
"metadata": {
"ballots": 56,
"overvotes": 4,
"undervotes": 44,
},
"tallies": {
"no": 4,
"yes": 4,
},
},
"new-zoo-either": {
"metadata": {
"ballots": 56,
"overvotes": 4,
"undervotes": 44,
},
"tallies": {
"no": 4,
"yes": 4,
},
},
"new-zoo-pick": {
"metadata": {
"ballots": 56,
"overvotes": 4,
"undervotes": 44,
},
"tallies": {
"no": 4,
"yes": 4,
},
},
"zoo-council-mammal": {
"metadata": {
"ballots": 28,
"overvotes": 6,
"undervotes": 12,
},
"tallies": {
"elephant": 12,
"kangaroo": 12,
"lion": 14,
"write-in": 12,
"zebra": 16,
},
},
}
`;
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import {
electionGridLayoutNewHampshireAmherstFixtures,
electionTwoPartyPrimaryFixtures,
} from '@votingworks/fixtures';
import { electionTwoPartyPrimaryFixtures } from '@votingworks/fixtures';
import {
BooleanEnvironmentVariableName,
getFeatureFlagMock,
} from '@votingworks/utils';
import { tmpNameSync } from 'tmp';
import { readFileSync } from 'fs';
import { LogEventId } from '@votingworks/logging';
import {
buildTestEnvironment,
configureMachine,
Expand Down Expand Up @@ -41,50 +35,6 @@ afterEach(() => {
featureFlagMock.resetFeatureFlags();
});

test('batch export', async () => {
const { electionDefinition, castVoteRecordExport } =
electionGridLayoutNewHampshireAmherstFixtures;

const { apiClient, auth, logger } = buildTestEnvironment();
await configureMachine(apiClient, auth, electionDefinition);
mockElectionManagerAuth(auth, electionDefinition.electionHash);

const loadFileResult = await apiClient.addCastVoteRecordFile({
path: castVoteRecordExport.asDirectoryPath(),
});
loadFileResult.assertOk('load file failed');

const path = tmpNameSync();
const exportResult = await apiClient.exportBatchResults({ path });
expect(exportResult.isOk()).toEqual(true);
expect(readFileSync(path, 'utf-8').toString()).toMatchSnapshot();
expect(logger.log).toHaveBeenLastCalledWith(
LogEventId.FileSaved,
'election_manager',
{
disposition: 'success',
filename: path,
message: `Saved batch results to ${path} on the USB drive.`,
}
);

// mock a failure
const offLimitsPath = '/root/hidden';
const failedExportResult = await apiClient.exportBatchResults({
path: offLimitsPath,
});
expect(failedExportResult.isErr()).toEqual(true);
expect(logger.log).toHaveBeenLastCalledWith(
LogEventId.FileSaved,
'election_manager',
{
disposition: 'failure',
filename: offLimitsPath,
message: `Failed to save batch results to ${offLimitsPath} on the USB drive.`,
}
);
});

test('sems export', async () => {
const { electionDefinition, castVoteRecordExport } =
electionTwoPartyPrimaryFixtures;
Expand Down
38 changes: 0 additions & 38 deletions apps/admin/backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ import {
import { handleEnteredWriteInCandidateData } from './util/manual_results';
import { addFileToZipStream } from './util/zip';
import { exportFile } from './util/export_file';
import { generateBatchResultsFile } from './exports/batch_results';
import { tabulateElectionResults } from './tabulation/full_results';
import { getSemsExportableTallies } from './exports/sems_tallies';
import { generateTallyReportCsv } from './exports/csv_tally_report';
Expand Down Expand Up @@ -691,43 +690,6 @@ function buildApi({
return store.getScannerBatches(loadCurrentElectionIdOrThrow(workspace));
},

async exportBatchResults(input: {
path: string;
}): Promise<ExportDataResult> {
debug('exporting batch results CSV file');
const electionId = loadCurrentElectionIdOrThrow(workspace);
const {
electionDefinition: { election },
} = assertDefined(store.getElection(electionId));

const exportFileResult = await exportFile({
path: input.path,
data: generateBatchResultsFile({
election,
batchGroupedResults: await tabulateElectionResults({
electionId,
store,
groupBy: { groupByBatch: true },
}),
allBatchMetadata: store.getScannerBatches(electionId),
}),
});

await logger.log(
LogEventId.FileSaved,
assertDefined(await getUserRole()),
{
disposition: exportFileResult.isOk() ? 'success' : 'failure',
message: `${
exportFileResult.isOk() ? 'Saved' : 'Failed to save'
} batch results to ${input.path} on the USB drive.`,
filename: input.path,
}
);

return exportFileResult;
},

async getSemsExportableTallies(): Promise<SemsExportableTallies> {
const electionId = loadCurrentElectionIdOrThrow(workspace);

Expand Down
Loading

0 comments on commit 530112f

Please sign in to comment.