From dae5f2c9a10379ba05684451e9e388d1afbb8fd2 Mon Sep 17 00:00:00 2001 From: ajianaz Date: Tue, 30 Jun 2026 17:54:43 +0700 Subject: [PATCH] fix(web): ApiClientError undefined crash + type errors + frontend CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - P1: Add missing ApiClientError class definition (was accidentally deleted during v0.2.0 merge — caused login crash with 'ApiClientError is not defined' runtime error) - P1: Remove dead [id] issue route (superseded by [issueId]/events/[eventId] which correctly accesses event data via data.message) - P2: Fix debounceTimer null check — use undefined instead of null to match clearTimeout signature - P2: Extract vitest config from vite.config.ts to vitest.config.ts with proper SvelteKit alias resolution - P3: Add svelte-check and vitest to web-build CI pipeline --- .github/workflows/ci.yml | 2 + web/src/lib/api.ts | 9 + .../routes/(dashboard)/issues/+page.svelte | 6 +- .../(dashboard)/issues/[id]/+page.svelte | 160 ------------------ web/vite.config.ts | 8 +- web/vitest.config.ts | 18 ++ 6 files changed, 33 insertions(+), 170 deletions(-) delete mode 100644 web/src/routes/(dashboard)/issues/[id]/+page.svelte create mode 100644 web/vitest.config.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3d4c50..a566d19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,7 +93,9 @@ jobs: cache: 'npm' cache-dependency-path: web/package-lock.json - run: npm ci + - run: npm run check - run: npm run build + - run: npm test cora-review: name: Cora Review diff --git a/web/src/lib/api.ts b/web/src/lib/api.ts index 3c467ca..985400e 100644 --- a/web/src/lib/api.ts +++ b/web/src/lib/api.ts @@ -70,6 +70,15 @@ export interface ListResponse { per_page: number; } +export class ApiClientError extends Error { + constructor( + public status: number, + message: string + ) { + super(message); + this.name = 'ApiClientError'; + } +} // ── Transactions ────────────────────────────────────────────────────── diff --git a/web/src/routes/(dashboard)/issues/+page.svelte b/web/src/routes/(dashboard)/issues/+page.svelte index f894029..f46f69c 100644 --- a/web/src/routes/(dashboard)/issues/+page.svelte +++ b/web/src/routes/(dashboard)/issues/+page.svelte @@ -34,7 +34,7 @@ let wsUnsub: (() => void) | null = $state(null); let searchQuery: string = $state(''); - let debounceTimer: ReturnType | null = null; + let debounceTimer: ReturnType | undefined; const statuses = ['unresolved', 'resolved', 'ignored']; const levels = ['fatal', 'error', 'warning', 'info', 'debug']; @@ -197,7 +197,7 @@ value={searchQuery} oninput={(e) => { searchQuery = (e.target as HTMLInputElement).value; - clearTimeout(debounceTimer); + if (debounceTimer !== undefined) clearTimeout(debounceTimer); debounceTimer = setTimeout(() => { currentPage = 1; navigate(); @@ -206,7 +206,7 @@ } onkeydown={(e) => { if (e.key === 'Enter') { - clearTimeout(debounceTimer); + if (debounceTimer !== undefined) clearTimeout(debounceTimer); currentPage = 1; navigate(); } diff --git a/web/src/routes/(dashboard)/issues/[id]/+page.svelte b/web/src/routes/(dashboard)/issues/[id]/+page.svelte deleted file mode 100644 index 42496c8..0000000 --- a/web/src/routes/(dashboard)/issues/[id]/+page.svelte +++ /dev/null @@ -1,160 +0,0 @@ - - - - {issue ? issue.title : 'Issue'} · TrapFall - - - - -
- {#if loading} -
- - -
- {:else if error} -
-

{error}

-
- {:else if issue} - -
- - {#if project} - · - {project.name} - {/if} - · - Press ESC to go back -
- - -
-
-
- - {issue.level} - - - {issue.status} - -

{issue.title}

-
-

- {issue.culprit || 'No culprit'} · {issue.count} events · {issue.user_count} users · Last seen {timeAgo(issue.last_seen)} -

-
- -
- - -
-

Events

- {#if events.length === 0} -

No event data available.

- {:else} - {#each events as event} - - - - {timeAgo(event.received_at)} · {event.platform || 'unknown'} - - - - {#if event.message} -

{event.message}

- {/if} -
-{JSON.stringify(event.data, null, 2)}
-
-
- {/each} - {/if} -
- {/if} -
diff --git a/web/vite.config.ts b/web/vite.config.ts index 0414132..bf699a8 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -3,11 +3,5 @@ import tailwindcss from '@tailwindcss/vite'; import { defineConfig } from 'vite'; export default defineConfig({ - plugins: [tailwindcss(), sveltekit()], - test: { - include: ['src/**/*.{test,spec}.{js,ts}'], - environment: 'jsdom', - globals: true, - setupFiles: ['src/test-setup.ts'] - } + plugins: [tailwindcss(), sveltekit()] }); diff --git a/web/vitest.config.ts b/web/vitest.config.ts new file mode 100644 index 0000000..476a202 --- /dev/null +++ b/web/vitest.config.ts @@ -0,0 +1,18 @@ +import { resolve } from 'node:path'; +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + resolve: { + alias: { + $lib: resolve('./src/lib'), + $components: resolve('./src/lib/components'), + $ui: resolve('./src/lib/components/ui') + } + }, + test: { + include: ['src/**/*.{test,spec}.{js,ts}'], + environment: 'jsdom', + globals: true, + setupFiles: ['src/test-setup.ts'] + } +});