Skip to content

Commit

Permalink
Add libs/custom-paper-handler (#3472)
Browse files Browse the repository at this point in the history
* add custom-paper-handler and update flow.test.ts

* remove unused files from libs/custom-paper-handler

* ignore custom-paper-handler from coverage

* set coverage threshold to 0 and remove ignore pattern from root cfg

* remove outdated comment

* Apply suggestions from code review

Clean up package.json

Co-authored-by: Brian Donovan <[email protected]>

* Apply suggestions from code review

Clean up logging

Co-authored-by: Brian Donovan <[email protected]>

* move ballot fixture to test/fixtures

* ignore flow.test.ts and reduce timeout anyway

* update pnpm-lock.yaml

---------

Co-authored-by: Brian Donovan <[email protected]>
  • Loading branch information
kshen0 and eventualbuddha authored May 19, 2023
1 parent f094e51 commit 0bb50ec
Show file tree
Hide file tree
Showing 28 changed files with 3,211 additions and 3 deletions.
23 changes: 23 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,28 @@ jobs:
- store_test_results:
path: libs/custom-scanner/reports/

test-libs-custom-paper-handler:
executor: nodejs
resource_class: xlarge
steps:
- checkout-and-install
- run:
name: Build
command: |
pnpm --dir libs/custom-paper-handler build
- run:
name: Lint
command: |
pnpm --dir libs/custom-paper-handler lint
- run:
name: Test
command: |
pnpm --dir libs/custom-paper-handler test
environment:
JEST_JUNIT_OUTPUT_DIR: ./reports/
- store_test_results:
path: libs/custom-paper-handler/reports/

test-libs-cvr-fixture-generator:
executor: nodejs
resource_class: xlarge
Expand Down Expand Up @@ -1006,6 +1028,7 @@ workflows:
- test-libs-cdf-schema-builder
- test-libs-converter-nh-accuvote
- test-libs-custom-scanner
- test-libs-custom-paper-handler
- test-libs-cvr-fixture-generator
- test-libs-backend
- test-libs-dev-dock-backend
Expand Down
2 changes: 1 addition & 1 deletion jest.config.shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ module.exports = {
'jest-watch-typeahead/testname',
],
cacheDirectory: '.jestcache'
}
}
1 change: 1 addition & 0 deletions libs/api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './base';
export * as Scan from './services/scan';
export * as PrintScan from './services/print-scan';
47 changes: 47 additions & 0 deletions libs/api/src/services/print-scan/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { z } from 'zod';

export type SimpleStatus =
| 'no_paper'
| 'paper_ready_to_load' // Paper is detected in the input area
| 'parking_paper'
| 'paper_parked'
| 'printing_ballot'
| 'ballot_printed'
| 'ejecting';

export const SimpleStatusSchema: z.ZodSchema<SimpleStatus> = z.union([
z.literal('no_paper'),
z.literal('paper_ready_to_load'),
z.literal('parking_paper'),
z.literal('paper_parked'),
z.literal('printing_ballot'),
z.literal('ballot_printed'),
z.literal('ejecting'),
]);

export type SimpleServerStatus = SimpleStatus | 'no_hardware';

export const SimpleServerStatusSchema: z.ZodSchema<SimpleServerStatus> =
z.union([SimpleStatusSchema, z.literal('no_hardware')]);

/**
* @url /print-scan/status
* @method GET
*/
export interface StatusResponse {
status: SimpleServerStatus;
}

/**
* @url /print-scan/status
* @method GET
*/
export const StatusResponseSchema: z.ZodSchema<StatusResponse> = z.object({
status: SimpleServerStatusSchema,
});

/**
* @url /print-scan/print
* @method POST
*/
export type PrintRequest = Uint8Array;
3 changes: 3 additions & 0 deletions libs/custom-paper-handler/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
coverage
jest.config.js
9 changes: 9 additions & 0 deletions libs/custom-paper-handler/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": ["plugin:vx/recommended"],
"rules": {
// Allow for bitwise operations which are necessary for usb protocol communication.
"no-bitwise": "off",
// Disable JSDOC rule: legacy code is not commented with JSDoc comments. Rule status will be reevaluated before production use
"vx/gts-jsdoc": "off"
}
}
Empty file.
Loading

0 comments on commit 0bb50ec

Please sign in to comment.