summaryrefslogtreecommitdiff
path: root/tests/client/App.test.tsx
diff options
context:
space:
mode:
authorPawel Zelawski <pawel@pzelawski.com>2026-10-04 16:51:18 +0200
committerPawel Zelawski <pawel@pzelawski.com>2026-10-04 16:51:18 +0200
commit1ea071717b046584216a8501917eb3720c19ea0b (patch)
tree762208aa2e8f8347edf8be192fd79e6cb7163822 /tests/client/App.test.tsx
parent93287b442971957e56233b5c2e927ae57bd7ba57 (diff)
test: cover uncovered functions to meet coverage thresholdsHEADmain
- Server: root health route and malformed-JSON error middleware - Client: status polling and start error paths where the error body is not JSON Function coverage rises from 68.42% to 89.47%, satisfying the 70% gate.
Diffstat (limited to 'tests/client/App.test.tsx')
-rw-r--r--tests/client/App.test.tsx55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/client/App.test.tsx b/tests/client/App.test.tsx
index 960f383..8586b13 100644
--- a/tests/client/App.test.tsx
+++ b/tests/client/App.test.tsx
@@ -119,4 +119,59 @@ describe('App', () => {
screen.getByRole('button', { name: /sign in with digi-id/i })
).toBeInTheDocument();
});
+
+ it('surfaces a status polling error when the error body is not JSON', async () => {
+ fetchMock
+ .mockResolvedValueOnce({
+ ok: true,
+ json: async () => ({
+ sessionId: 'session-4',
+ qrCodeDataUrl: 'data:image/png;base64,qr',
+ }),
+ })
+ .mockResolvedValueOnce({
+ ok: false,
+ status: 500,
+ json: async () => {
+ throw new Error('not json');
+ },
+ });
+
+ render(<App />);
+ fireEvent.click(
+ screen.getByRole('button', { name: /sign in with digi-id/i })
+ );
+
+ await waitFor(
+ () => {
+ expect(
+ screen.getByText(/status polling failed: error fetching status/i)
+ ).toBeInTheDocument();
+ },
+ { timeout: 4000 }
+ );
+ });
+
+ it('uses a fallback message when the start error body is not JSON', async () => {
+ fetchMock.mockResolvedValueOnce({
+ ok: false,
+ status: 503,
+ json: async () => {
+ throw new Error('not json');
+ },
+ });
+
+ render(<App />);
+ fireEvent.click(
+ screen.getByRole('button', { name: /sign in with digi-id/i })
+ );
+
+ await waitFor(() => {
+ expect(
+ screen.getByText(
+ /failed to initiate digi-id: failed to start session\. server responded with status: 503/i
+ )
+ ).toBeInTheDocument();
+ });
+ });
});