Skip to content

Commit

Permalink
Kevin/polish rear eject (#4049)
Browse files Browse the repository at this point in the history
* polish rear eject flow

* increase frontend polling interval

* increase frontend auth polling interval

* update tests

* update snpashots
  • Loading branch information
kshen0 authored Oct 12, 2023
1 parent 99d51df commit d942a51
Show file tree
Hide file tree
Showing 20 changed files with 76 additions and 101 deletions.
5 changes: 3 additions & 2 deletions apps/mark-scan/backend/src/custom-paper-handler/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ export const AUTH_STATUS_POLLING_TIMEOUT_MS = 30_000;
export const RESET_DELAY_MS = 8_000;
export const RESET_AFTER_JAM_DELAY_MS = 3_000;
// The delay the state machine will wait for paper to eject before
// declaring a jam state during rear ejection
export const DELAY_BEFORE_DECLARING_REAR_JAM_MS = 3_000;
// declaring a jam state during rear ejection. Expected time for a successful
// ballot cast is is about 3.5 seconds.
export const DELAY_BEFORE_DECLARING_REAR_JAM_MS = 7_000;

export const SCAN_DPI = 72;
export const PRINT_DPI = 200;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ exports[`Single Seat Contest 1`] = `
margin: 0;
}
.c9 {
.c23 {
font-size: 1em;
font-weight: 300;
line-height: 1.15;
margin: 0;
font-size: 0.75rem;
}
.c5 {
.c9 {
font-size: 1em;
font-weight: 500;
line-height: 1.15;
margin: 0;
font-size: 0.75rem;
Expand All @@ -31,9 +31,9 @@ exports[`Single Seat Contest 1`] = `
font-size: 0.75rem;
}
.c23 {
.c5 {
font-size: 1em;
font-weight: 300;
font-weight: 500;
line-height: 1.15;
margin: 0;
font-size: 0.75rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ exports[`Single Seat Contest 1`] = `
margin: 0;
}
.c9 {
.c23 {
font-size: 1em;
font-weight: 300;
line-height: 1.15;
margin: 0;
font-size: 0.75rem;
}
.c5 {
.c9 {
font-size: 1em;
font-weight: 500;
line-height: 1.15;
margin: 0;
font-size: 0.75rem;
Expand All @@ -31,9 +31,9 @@ exports[`Single Seat Contest 1`] = `
font-size: 0.75rem;
}
.c23 {
.c5 {
font-size: 1em;
font-weight: 300;
font-weight: 500;
line-height: 1.15;
margin: 0;
font-size: 0.75rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ exports[`Single Seat Contest 1`] = `
margin: 0;
}
.c9 {
.c23 {
font-size: 1em;
font-weight: 300;
line-height: 1.15;
margin: 0;
font-size: 0.75rem;
}
.c5 {
.c9 {
font-size: 1em;
font-weight: 500;
line-height: 1.15;
margin: 0;
font-size: 0.75rem;
Expand All @@ -31,9 +31,9 @@ exports[`Single Seat Contest 1`] = `
font-size: 0.75rem;
}
.c23 {
.c5 {
font-size: 1em;
font-weight: 300;
font-weight: 500;
line-height: 1.15;
margin: 0;
font-size: 0.75rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ exports[`Single Seat Contest with Write In 1`] = `
margin: 0;
}
.c9 {
.c23 {
font-size: 1em;
font-weight: 300;
line-height: 1.15;
margin: 0;
font-size: 0.75rem;
}
.c5 {
.c9 {
font-size: 1em;
font-weight: 500;
line-height: 1.15;
margin: 0;
font-size: 0.75rem;
Expand All @@ -31,9 +31,9 @@ exports[`Single Seat Contest with Write In 1`] = `
font-size: 0.75rem;
}
.c23 {
.c5 {
font-size: 1em;
font-weight: 300;
font-weight: 500;
line-height: 1.15;
margin: 0;
font-size: 0.75rem;
Expand Down
8 changes: 5 additions & 3 deletions apps/mark-scan/frontend/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
useQueryClient,
} from '@tanstack/react-query';
import {
AUTH_STATUS_POLLING_INTERVAL_MS,
QUERY_CLIENT_DEFAULT_OPTIONS,
USB_DRIVE_STATUS_POLLING_INTERVAL_MS,
createUiStringsApi,
Expand All @@ -18,7 +17,10 @@ import {
import type { UsbDriveStatus } from '@votingworks/usb-drive';
import isEqual from 'lodash.isequal';
import { typedAs } from '@votingworks/basics';
import { STATE_MACHINE_POLLING_INTERVAL_MS } from './constants';
import {
AUTH_STATUS_POLLING_INTERVAL_MS_OVERRIDE,
STATE_MACHINE_POLLING_INTERVAL_MS,
} from './constants';

export type ApiClient = grout.Client<Api>;

Expand Down Expand Up @@ -151,7 +153,7 @@ export const getAuthStatus = {
useQuery() {
const apiClient = useApiClient();
return useQuery(this.queryKey(), () => apiClient.getAuthStatus(), {
refetchInterval: AUTH_STATUS_POLLING_INTERVAL_MS,
refetchInterval: AUTH_STATUS_POLLING_INTERVAL_MS_OVERRIDE,
});
},
} as const;
Expand Down
33 changes: 7 additions & 26 deletions apps/mark-scan/frontend/src/app_cardless_voting.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
screen,
within,
} from '../test/react_testing_library';
import * as GLOBALS from './config/globals';

import { App } from './app';

Expand All @@ -37,6 +36,7 @@ beforeEach(() => {
apiMock = createApiMock();
kiosk = fakeKiosk();
window.kiosk = kiosk;
apiMock.setPaperHandlerState('waiting_for_ballot_data');
});

afterEach(() => {
Expand Down Expand Up @@ -257,16 +257,9 @@ test('Cardless Voting Flow', async () => {
apiMock.expectGetInterpretation(mockInterpretation);
userEvent.click(screen.getByText('My Ballot is Correct'));

// Reset Ballot is called
// Show Verify and Scan Instructions
await screen.findByText('You’re Almost Done');
expect(
screen.queryByText('3. Return the card to a poll worker.')
).toBeFalsy();
apiMock.setPaperHandlerState('ejecting_to_rear');
await screen.findByText('Casting Ballot...');

// Wait for timeout to return to Insert Card screen
apiMock.mockApiClient.endCardlessVoterSession.expectCallWith().resolves();
await advanceTimersAndPromises(GLOBALS.BALLOT_INSTRUCTIONS_TIMEOUT_SECONDS);
apiMock.setAuthStatusLoggedOut();
await screen.findByText('Insert Card');
});
Expand Down Expand Up @@ -411,14 +404,9 @@ test('Voter can submit a blank ballot', async () => {
apiMock.expectGetInterpretation(mockInterpretation);
userEvent.click(screen.getByText('My Ballot is Correct'));

// Reset Ballot is called
// Show Verify and Scan Instructions
await screen.findByText('You’re Almost Done');
expect(screen.queryByText('3. Return the card.')).toBeFalsy();
apiMock.setPaperHandlerState('ejecting_to_rear');
await screen.findByText('Casting Ballot...');

// Click "Done" to get back to Insert Card screen
apiMock.mockApiClient.endCardlessVoterSession.expectCallWith().resolves();
fireEvent.click(screen.getByText('Done'));
apiMock.setAuthStatusLoggedOut();
await screen.findByText('Insert Card');
});
Expand Down Expand Up @@ -635,16 +623,9 @@ test('poll worker must select a precinct first', async () => {
apiMock.expectGetInterpretation(mockInterpretation);
userEvent.click(screen.getByText('My Ballot is Correct'));

// Reset Ballot is called
// Show Verify and Scan Instructions
await screen.findByText('You’re Almost Done');
expect(
screen.queryByText('3. Return the card to a poll worker.')
).toBeFalsy();
apiMock.setPaperHandlerState('ejecting_to_rear');
await screen.findByText('Casting Ballot...');

// Wait for timeout to return to Insert Card screen
apiMock.mockApiClient.endCardlessVoterSession.expectCallWith().resolves();
await advanceTimersAndPromises(GLOBALS.BALLOT_INSTRUCTIONS_TIMEOUT_SECONDS);
apiMock.setAuthStatusLoggedOut();
await screen.findByText('Insert Card');
});
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ beforeEach(() => {
apiMock = createApiMock();
apiMock.expectGetSystemSettings();
apiMock.expectGetElectionDefinition(null);
apiMock.setPaperHandlerState('waiting_for_ballot_data');
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ beforeEach(() => {
jest.useFakeTimers();
window.location.href = '/';
apiMock = createApiMock();
apiMock.setPaperHandlerState('waiting_for_ballot_data');
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ beforeEach(() => {
apiMock = createApiMock();
apiMock.expectGetSystemSettings();
apiMock.expectGetElectionDefinition(null);
apiMock.setPaperHandlerState('waiting_for_ballot_data');
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ beforeEach(() => {
apiMock = createApiMock();
apiMock.expectGetSystemSettings();
apiMock.expectGetElectionDefinition(null);
apiMock.setPaperHandlerState('waiting_for_ballot_data');
});

afterEach(() => {
Expand Down
1 change: 1 addition & 0 deletions apps/mark-scan/frontend/src/app_contest_write_in.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ beforeEach(() => {
apiMock = createApiMock();
apiMock.expectGetSystemSettings();
apiMock.expectGetElectionDefinition(null);
apiMock.setPaperHandlerState('waiting_for_ballot_data');
});

afterEach(() => {
Expand Down
1 change: 1 addition & 0 deletions apps/mark-scan/frontend/src/app_contest_yes_no.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ beforeEach(() => {
apiMock = createApiMock();
apiMock.expectGetSystemSettings();
apiMock.expectGetElectionDefinition(null);
apiMock.setPaperHandlerState('waiting_for_ballot_data');
});

afterEach(() => {
Expand Down
3 changes: 1 addition & 2 deletions apps/mark-scan/frontend/src/app_end_to_end.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,9 @@ test('MarkAndPrint end-to-end flow', async () => {
// Validate Ballot page
await screen.findByText('Review Your Votes');
apiMock.expectValidateBallot();
apiMock.mockApiClient.endCardlessVoterSession.expectCallWith().resolves();
apiMock.expectGetInterpretation(mockInterpretation);
userEvent.click(screen.getByText('My Ballot is Correct'));
userEvent.click(await screen.findByText('Done'));

apiMock.setAuthStatusLoggedOut();

// ---------------
Expand Down
1 change: 1 addition & 0 deletions apps/mark-scan/frontend/src/app_quit_on_idle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ beforeEach(() => {
apiMock.expectGetSystemSettings();
apiMock.expectGetElectionDefinition(null);
apiMock.expectGetPrecinctSelectionResolvesDefault(election);
apiMock.setPaperHandlerState('waiting_for_ballot_data');
});

afterEach(() => {
Expand Down
Loading

0 comments on commit d942a51

Please sign in to comment.