Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset session if pollworker card is pulled during paper load prompt/intake #4647

Merged
merged 9 commits into from
Mar 19, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MARK_SCAN_WORKSPACE } from '../../globals';
import {
AUTH_STATUS_POLLING_INTERVAL_MS,
DEV_DEVICE_STATUS_POLLING_INTERVAL_MS,
SUCCESS_NOTIFICATION_DURATION_MS,
NOTIFICATION_DURATION_MS,
} from '../constants';
import {
PaperHandlerStateMachine,
Expand Down Expand Up @@ -95,7 +95,7 @@ export async function main(): Promise<number> {
patConnectionStatusReader,
devicePollingIntervalMs: DEV_DEVICE_STATUS_POLLING_INTERVAL_MS,
authPollingIntervalMs: AUTH_STATUS_POLLING_INTERVAL_MS,
notificationDurationMs: SUCCESS_NOTIFICATION_DURATION_MS,
notificationDurationMs: NOTIFICATION_DURATION_MS,
});
assert(stateMachine !== undefined, 'Unexpected undefined state machine');

Expand Down
6 changes: 4 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 @@ -7,13 +7,15 @@ export const DEV_AUTH_STATUS_POLLING_INTERVAL_MS = 1000;

export const DEVICE_STATUS_POLLING_TIMEOUT_MS = 30_000;
export const AUTH_STATUS_POLLING_TIMEOUT_MS = 30_000;
// The delay the state machine will wait after issuing a reset command.
// The reset command resolves immediately but the hardware takes about 7
// seconds to become available again.
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. 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 SUCCESS_NOTIFICATION_DURATION_MS = 5_000;
export const NOTIFICATION_DURATION_MS = 5_000;

export const MAX_BALLOT_BOX_CAPACITY = 200;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { assert } from 'console';
import {
PaperHandlerStateMachine,
getPaperHandlerStateMachine,
paperHandlerStatusToEvent,
} from './state_machine';
import { Workspace, createWorkspace } from '../util/workspace';
import {
Expand Down Expand Up @@ -443,3 +444,33 @@ describe('PAT device', () => {
);
});
});

test('ending poll worker auth in accepting_paper returns to initial state', async () => {
machine.setAcceptingPaper();
const ballotStyle = electionGeneralDefinition.election.ballotStyles[1];
mockCardlessVoterAuth(auth, {
ballotStyleId: ballotStyle.id,
precinctId,
});
await waitForStatus('not_accepting_paper');
});

test('poll_worker_auth_ended_unexpectedly', async () => {
machine.setAcceptingPaper();
const ballotStyle = electionGeneralDefinition.election.ballotStyles[1];
setMockDeviceStatus(getPaperInFrontStatus());
await waitForStatus('loading_paper');
mockCardlessVoterAuth(auth, {
ballotStyleId: ballotStyle.id,
precinctId,
});
await waitForStatus('poll_worker_auth_ended_unexpectedly');
});

describe('paperHandlerStatusToEvent', () => {
test('paper in output', () => {
expect(paperHandlerStatusToEvent(getPaperInRearStatus())).toEqual({
type: 'PAPER_IN_OUTPUT',
});
});
});
Loading