-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
Add thorough unit test coverage for frontend/certificate.js to ensure certificate verification flows are resilient, including edge cases, API failures, and invalid data scenarios.
Scope
- Cover success and failure paths for certificate verification logic (including fetch/HTTP error handling, non-200 responses, and malformed JSON).
- Validate behavior when inputs are missing/invalid (empty certificate ID/serial, whitespace-only, excessively long values, special characters).
- Ensure UI state updates are tested (loading indicators, error/success messages, button disabled states, cleared/retained inputs on submit/retry).
- Test handling of timeout/abort scenarios (e.g., fetch aborted or delayed responses) if supported in code.
- Verify rendering of certificate details uses safe defaults when optional fields are absent (expiry date null, missing holder/course fields).
- Add regression tests for QR/verification URL rendering if applicable in
certificate.js.
Approach
- Use a JS test runner suitable for the frontend bundle (e.g., Jest + jsdom, or the project’s preferred runner) and mock
fetchand DOM APIs. - Add fixtures for valid/invalid certificate payloads and error responses.
- Include negative tests: network failure, 500s/404s, invalid JSON, signature mismatch payloads if applicable.
- Ensure tests run via CI (document command in README if new).
Definition of Done
- New tests added under
frontend/(or existing tests folder) with clear arrange/act/assert structure. - Tests deterministic and not relying on live network calls.
- Test command documented if new.
- CI passes with added coverage improvements noted.
Metadata
Metadata
Assignees
Labels
No labels