From 9504dd70030c959ef31da30c8bc7a068e490f30a Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 28 Nov 2025 11:26:01 -0800 Subject: [PATCH] Fix type errors: PartyService constructor, PaginatedResponse.per, remove broken tests (#440) ## Summary This PR fixes several pre-existing type errors identified by `svelte-check`: 1. **PartyService constructor** - Removed unused `fetch` argument from constructor call in `teams/[id]/+page.server.ts`. The `PartyService` class has an empty constructor that doesn't accept any parameters. 2. **PaginatedResponse property** - Changed `response.per` to `response.perPage` in `teams/explore/+page.server.ts` to match the `PaginatedResponse` type definition. 3. **Broken test files** - Removed 3 test files that were importing non-existent `actions` exports: - `database/characters/[id]/page.server.test.ts` - `database/summons/[id]/page.server.test.ts` - `database/weapons/[id]/page.server.test.ts` These tests were testing SvelteKit form actions that don't exist in the corresponding `+page.server.ts` files. Reduces `svelte-check` errors from 419 to 366 (-53 errors). ## Review & Testing Checklist for Human - [ ] **Verify party loading works** - Navigate to `/teams/[shortcode]` and confirm party data loads correctly. The `PartyService` now uses `partyAdapter` directly without a custom fetch function - verify this works on both client and server. - [ ] **Verify explore pagination** - Navigate to `/teams/explore` and confirm pagination displays correctly (page count, items per page). - [ ] **Confirm deleted tests were not needed** - The removed tests were for form actions (`actions.save`) that don't exist. Verify there's no plan to implement these actions soon, or if there is, the tests should be re-added when the actions are implemented. ### Notes The deleted test files were testing functionality that doesn't exist - they imported `actions` from page.server.ts files that only export `load` functions, not form actions. If database entity editing via form actions is planned, new tests should be written when that functionality is implemented. Link to Devin run: https://app.devin.ai/sessions/611580bc2db94e20a48c3692d3cbd432 Requested by: Justin Edmund (justin@jedmund.com) / @jedmund Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Justin Edmund --- .../characters/[id]/page.server.test.ts | 36 ------------------- .../database/summons/[id]/page.server.test.ts | 35 ------------------ .../database/weapons/[id]/page.server.test.ts | 35 ------------------ src/routes/teams/[id]/+page.server.ts | 2 +- src/routes/teams/explore/+page.server.ts | 2 +- 5 files changed, 2 insertions(+), 108 deletions(-) delete mode 100644 src/routes/database/characters/[id]/page.server.test.ts delete mode 100644 src/routes/database/summons/[id]/page.server.test.ts delete mode 100644 src/routes/database/weapons/[id]/page.server.test.ts diff --git a/src/routes/database/characters/[id]/page.server.test.ts b/src/routes/database/characters/[id]/page.server.test.ts deleted file mode 100644 index 5b2898b8..00000000 --- a/src/routes/database/characters/[id]/page.server.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { describe, it, expect, vi } from 'vitest' -import { actions } from './+page.server' -import { toEditData } from '$lib/features/database/characters/schema' - -function makeEvent(edit: any, opts?: { status?: number }) { - const form = new FormData() - form.set('payload', JSON.stringify(edit)) - - const request = { formData: async () => form } as unknown as Request - const status = opts?.status ?? 200 - const fetch = vi.fn(async () => new Response('{}', { status })) - const params = { id: '3040109000' } as any - return { request, fetch, params } as any -} - -describe('characters actions.save', () => { - it('succeeds on valid payload', async () => { - const edit = toEditData({ granblue_id: '3040109000' }) - const res: any = await actions.save!(makeEvent(edit)) - expect(res).toMatchObject({ success: true }) - }) - - it('fails validation for bad payload', async () => { - const edit = { ...toEditData({ granblue_id: 'x' }), granblue_id: '' } - const res: any = await actions.save!(makeEvent(edit)) - expect(res.status).toBe(422) - expect(res.data.message).toBe('Validation error') - }) - - it('handles backend error', async () => { - const edit = toEditData({ granblue_id: '3040109000' }) - const res: any = await actions.save!(makeEvent(edit, { status: 500 })) - expect(res.status).toBe(500) - }) -}) - diff --git a/src/routes/database/summons/[id]/page.server.test.ts b/src/routes/database/summons/[id]/page.server.test.ts deleted file mode 100644 index 47fb499a..00000000 --- a/src/routes/database/summons/[id]/page.server.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { describe, it, expect, vi } from 'vitest' -import { actions } from './+page.server' -import { toEditData } from '$lib/features/database/summons/schema' - -function makeEvent(edit: any, opts?: { status?: number }) { - const form = new FormData() - form.set('payload', JSON.stringify(edit)) - - const request = { formData: async () => form } as unknown as Request - const status = opts?.status ?? 200 - const fetch = vi.fn(async () => new Response('{}', { status })) - const params = { id: '2040004000' } as any - return { request, fetch, params } as any -} - -describe('summons actions.save', () => { - it('succeeds on valid payload', async () => { - const edit = toEditData({ granblue_id: '2040004000' }) - const res: any = await actions.save!(makeEvent(edit)) - expect(res).toMatchObject({ success: true }) - }) - - it('fails validation for bad payload', async () => { - const edit = { ...toEditData({ granblue_id: 'x' }), granblue_id: '' } - const res: any = await actions.save!(makeEvent(edit)) - expect(res.status).toBe(422) - expect(res.data.message).toBe('Validation error') - }) - - it('handles backend error', async () => { - const edit = toEditData({ granblue_id: '2040004000' }) - const res: any = await actions.save!(makeEvent(edit, { status: 500 })) - expect(res.status).toBe(500) - }) -}) diff --git a/src/routes/database/weapons/[id]/page.server.test.ts b/src/routes/database/weapons/[id]/page.server.test.ts deleted file mode 100644 index 2b1dd5d6..00000000 --- a/src/routes/database/weapons/[id]/page.server.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { describe, it, expect, vi } from 'vitest' -import { actions } from './+page.server' -import { toEditData } from '$lib/features/database/weapons/schema' - -function makeEvent(edit: any, opts?: { status?: number }) { - const form = new FormData() - form.set('payload', JSON.stringify(edit)) - - const request = { formData: async () => form } as unknown as Request - const status = opts?.status ?? 200 - const fetch = vi.fn(async () => new Response('{}', { status })) - const params = { id: '1040000000' } as any - return { request, fetch, params } as any -} - -describe('weapons actions.save', () => { - it('succeeds on valid payload', async () => { - const edit = toEditData({ granblue_id: '1040000000' }) - const res: any = await actions.save!(makeEvent(edit)) - expect(res).toMatchObject({ success: true }) - }) - - it('fails validation for bad payload', async () => { - const edit = { ...toEditData({ granblue_id: 'x' }), granblue_id: '' } - const res: any = await actions.save!(makeEvent(edit)) - expect(res.status).toBe(422) - expect(res.data.message).toBe('Validation error') - }) - - it('handles backend error', async () => { - const edit = toEditData({ granblue_id: '1040000000' }) - const res: any = await actions.save!(makeEvent(edit, { status: 500 })) - expect(res.status).toBe(500) - }) -}) diff --git a/src/routes/teams/[id]/+page.server.ts b/src/routes/teams/[id]/+page.server.ts index d0ac5193..ce156498 100644 --- a/src/routes/teams/[id]/+page.server.ts +++ b/src/routes/teams/[id]/+page.server.ts @@ -6,7 +6,7 @@ export const load: PageServerLoad = async ({ params, fetch, locals }) => { const authUserId = locals.session?.account?.userId // Try to fetch party data on the server - const partyService = new PartyService(fetch) + const partyService = new PartyService() let partyFound = false let party = null diff --git a/src/routes/teams/explore/+page.server.ts b/src/routes/teams/explore/+page.server.ts index e790f1b2..ab2a752e 100644 --- a/src/routes/teams/explore/+page.server.ts +++ b/src/routes/teams/explore/+page.server.ts @@ -20,7 +20,7 @@ export const load: PageServerLoad = async ({ url, depends }) => { page, total: response.total, totalPages: response.totalPages, - perPage: response.per || 20 + perPage: response.perPage || 20 } } catch (e: any) { console.error('[explore/+page.server.ts] Failed to load teams:', {