fix(invites): resolve svelte-check warnings in UserGroupsSection and page.server.test
All checks were successful
All checks were successful
Use untrack() for intentional one-time prop seed in UserGroupsSection. Add explicit LoadData type alias in page.server.test to avoid void|Record<string,any> union. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit was merged in pull request #582.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { untrack } from 'svelte';
|
||||
import { m } from '$lib/paraglide/messages.js';
|
||||
|
||||
let {
|
||||
@@ -9,7 +10,7 @@ let {
|
||||
selectedGroupIds?: string[];
|
||||
} = $props();
|
||||
|
||||
let selected = $state<string[]>([...selectedGroupIds]);
|
||||
let selected = $state<string[]>(untrack(() => [...selectedGroupIds]));
|
||||
</script>
|
||||
|
||||
<fieldset class="flex flex-wrap gap-3 border-none p-0">
|
||||
|
||||
@@ -5,6 +5,17 @@ vi.mock('$env/dynamic/private', () => ({
|
||||
}));
|
||||
|
||||
import { load, actions } from './+page.server';
|
||||
import type { UserGroup } from './+page.server';
|
||||
|
||||
// PageServerLoad annotates the return as `void | (...)`. This explicit shape avoids
|
||||
// the void and the Record<string, any> from the generic constraint.
|
||||
type LoadData = {
|
||||
invites: unknown[];
|
||||
status: string;
|
||||
loadError: string | null;
|
||||
groups: UserGroup[];
|
||||
groupsLoadError: string | null;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type AnyFetch = (...args: any[]) => any;
|
||||
@@ -40,7 +51,7 @@ describe('admin/invites load()', () => {
|
||||
])
|
||||
);
|
||||
|
||||
const result = await load(event());
|
||||
const result = (await load(event())) as LoadData;
|
||||
|
||||
expect(result.groups).toHaveLength(2);
|
||||
expect(result.groupsLoadError).toBeNull();
|
||||
@@ -55,7 +66,7 @@ describe('admin/invites load()', () => {
|
||||
])
|
||||
);
|
||||
|
||||
const result = await load(event());
|
||||
const result = (await load(event())) as LoadData;
|
||||
|
||||
expect(result.groups.map((g) => g.name)).toEqual(['Alfa', 'Mitte', 'Zebra']);
|
||||
});
|
||||
@@ -65,7 +76,7 @@ describe('admin/invites load()', () => {
|
||||
.mockResolvedValueOnce(mockResponse(true, []))
|
||||
.mockResolvedValueOnce(mockResponse(false, { code: 'FORBIDDEN' }, 403));
|
||||
|
||||
const result = await load(event());
|
||||
const result = (await load(event())) as LoadData;
|
||||
|
||||
expect(result.groups).toEqual([]);
|
||||
expect(result.groupsLoadError).toBe('FORBIDDEN');
|
||||
@@ -76,7 +87,7 @@ describe('admin/invites load()', () => {
|
||||
.mockResolvedValueOnce(mockResponse(true, []))
|
||||
.mockResolvedValueOnce(mockResponse(false, null, 500));
|
||||
|
||||
const result = await load(event());
|
||||
const result = (await load(event())) as LoadData;
|
||||
|
||||
expect(result.groupsLoadError).toBe('INTERNAL_ERROR');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user