Skip to content

Commit

Permalink
Remove old CVR code from VxAdmin (#3999)
Browse files Browse the repository at this point in the history
* Remove old-format CVR fixture data

* Indicate which files in libs/fixtures are generated

So that the GitHub UI collapses them by default

* Generate new-format CVR fixture data using libs/cvr-fixture-generator

From libs/cvr-fixture-generator:
$ ./bin/generate \
  -p ../fixtures/data/electionGridLayoutNewHampshireAmherst/election.json \
  -o ../fixtures/data/electionGridLayoutNewHampshireAmherst/castVoteRecords/generated
$ ./bin/generate \
  -p ../fixtures/data/electionTwoPartyPrimary/election.json \
  -o ../fixtures/data/electionTwoPartyPrimary/castVoteRecords/generated

* Add manually prepared new-format CVR fixture data

* Update build_resources.sh in libs/fixtures

* Run `pnpm build:resources` in libs/fixtures

* Update relevant fixtures' index.ts files

* Delete legacy_import.test.ts

Since it relies on old CVR fixtures and legacy_import.ts will
itself soon be deleted

* Update libs/utils tests

* Add a modifyCastVoteRecordExport fxn for modifying fixtures for tests

Also use more consistent variable names for raw file contents vs.
parsed contents

* Move helper for listing CVR exports out of legacy_cast_vote_records.ts

And then delete legacy_cast_vote_records.ts

* Remove old code paths from VxAdmin backend app.ts

* Update VxAdmin frontend to account for backend updates

* Update VxAdmin backend tests

* Set up getExportedCastVoteRecordIds helper

* Use constants for file names

* Use alternative import syntax to fix frontend builds

* Use build-stubs script to build fs stub in frontends missing that stub

* Distinguish no-entity from not-directory
  • Loading branch information
arsalansufi authored Sep 26, 2023
1 parent 3ba81d4 commit 1483679
Show file tree
Hide file tree
Showing 719 changed files with 286,470 additions and 161,372 deletions.
292 changes: 109 additions & 183 deletions apps/admin/backend/src/app.cvr_files.test.ts

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions apps/admin/backend/src/app.exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ afterEach(() => {
});

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

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

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

Expand Down Expand Up @@ -86,15 +86,15 @@ test('batch export', async () => {
});

test('sems export', async () => {
const { electionDefinition, castVoteRecordReport } =
const { electionDefinition, castVoteRecordExport } =
electionTwoPartyPrimaryFixtures;

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

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

Expand Down
8 changes: 4 additions & 4 deletions apps/admin/backend/src/app.results.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ afterEach(() => {
});

test('card counts', async () => {
const { electionDefinition, castVoteRecordReport } =
const { electionDefinition, castVoteRecordExport } =
electionTwoPartyPrimaryFixtures;
const { election } = electionDefinition;

Expand All @@ -49,7 +49,7 @@ test('card counts', async () => {
mockElectionManagerAuth(auth, electionDefinition.electionHash);

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

Expand Down Expand Up @@ -86,7 +86,7 @@ test('card counts', async () => {
});

test('election write-in adjudication summary', async () => {
const { electionDefinition, castVoteRecordReport } =
const { electionDefinition, castVoteRecordExport } =
electionGridLayoutNewHampshireAmherstFixtures;
const { election } = electionDefinition;

Expand All @@ -95,7 +95,7 @@ test('election write-in adjudication summary', async () => {
mockElectionManagerAuth(auth, electionDefinition.electionHash);

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

Expand Down
12 changes: 6 additions & 6 deletions apps/admin/backend/src/app.results_csv_export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ async function getParsedExport({
}

it('exports expected results for full election', async () => {
const { electionDefinition, castVoteRecordReport } =
const { electionDefinition, castVoteRecordExport } =
electionTwoPartyPrimaryFixtures;

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

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

Expand Down Expand Up @@ -132,15 +132,15 @@ it('exports expected results for full election', async () => {
});

it('logs failure if export fails for some reason', async () => {
const { electionDefinition, castVoteRecordReport } =
const { electionDefinition, castVoteRecordExport } =
electionTwoPartyPrimaryFixtures;

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

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

Expand All @@ -161,7 +161,7 @@ it('logs failure if export fails for some reason', async () => {
});

it('incorporates wia and manual data', async () => {
const { electionDefinition, castVoteRecordReport } =
const { electionDefinition, castVoteRecordExport } =
electionGridLayoutNewHampshireAmherstFixtures;
const { election } = electionDefinition;

Expand All @@ -170,7 +170,7 @@ it('incorporates wia and manual data', async () => {
mockElectionManagerAuth(auth, electionDefinition.electionHash);

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

Expand Down
24 changes: 12 additions & 12 deletions apps/admin/backend/src/app.tally_reports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ afterEach(() => {
});

test('general, full election, write in adjudication', async () => {
const { electionDefinition, castVoteRecordReport } =
const { electionDefinition, castVoteRecordExport } =
electionGridLayoutNewHampshireAmherstFixtures;

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

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

Expand Down Expand Up @@ -161,7 +161,7 @@ test('general, full election, write in adjudication', async () => {
});

test('general, reports by voting method, manual data', async () => {
const { electionDefinition, castVoteRecordReport } =
const { electionDefinition, castVoteRecordExport } =
electionGridLayoutNewHampshireAmherstFixtures;
const { election } = electionDefinition;

Expand All @@ -170,7 +170,7 @@ test('general, reports by voting method, manual data', async () => {
mockElectionManagerAuth(auth, electionDefinition.electionHash);

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

Expand Down Expand Up @@ -292,7 +292,7 @@ test('general, reports by voting method, manual data', async () => {
});

test('primary, full election', async () => {
const { electionDefinition, castVoteRecordReport } =
const { electionDefinition, castVoteRecordExport } =
electionTwoPartyPrimaryFixtures;
const { election } = electionDefinition;

Expand All @@ -301,7 +301,7 @@ test('primary, full election', async () => {
mockElectionManagerAuth(auth, electionDefinition.electionHash);

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

Expand Down Expand Up @@ -355,7 +355,7 @@ test('primary, full election', async () => {
});

test('primary, full election, with manual results', async () => {
const { electionDefinition, castVoteRecordReport } =
const { electionDefinition, castVoteRecordExport } =
electionTwoPartyPrimaryFixtures;
const { election } = electionDefinition;

Expand All @@ -364,7 +364,7 @@ test('primary, full election, with manual results', async () => {
mockElectionManagerAuth(auth, electionDefinition.electionHash);

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

Expand Down Expand Up @@ -410,15 +410,15 @@ test('primary, full election, with manual results', async () => {
});

test('primary, reports by ballot style', async () => {
const { electionDefinition, castVoteRecordReport } =
const { electionDefinition, castVoteRecordExport } =
electionTwoPartyPrimaryFixtures;

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

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

Expand Down Expand Up @@ -469,15 +469,15 @@ test('primary, reports by ballot style', async () => {
});

test('primary, reports grouped by voting method, filtered by precinct', async () => {
const { electionDefinition, castVoteRecordReport } =
const { electionDefinition, castVoteRecordExport } =
electionTwoPartyPrimaryFixtures;

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

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

Expand Down
Loading

0 comments on commit 1483679

Please sign in to comment.