f102_test_KeineListeVorhanden #33
@@ -4,6 +4,7 @@ import type { PageServerLoad } from '../../(token-based)/view/$types';
|
|||||||
export const load: PageServerLoad = async () => {
|
export const load: PageServerLoad = async () => {
|
||||||
const vorgangList = getVorgaenge();
|
const vorgangList = getVorgaenge();
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
vorgangList
|
vorgangList
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
import Trash from '$lib/icons/Trash.svelte';
|
import Trash from '$lib/icons/Trash.svelte';
|
||||||
import Folder from '$lib/icons/Folder.svelte';
|
import Folder from '$lib/icons/Folder.svelte';
|
||||||
import EmptyList from '$lib/components/EmptyList.svelte';
|
import EmptyList from '$lib/components/EmptyList.svelte';
|
||||||
import type { PageData } from '../$types';
|
|
||||||
|
|
||||||
// let { data } = $props();
|
let { data } = $props();
|
||||||
export let data: PageData;
|
|
||||||
let vorgangList = data.vorgangList;
|
let vorgangList = data.vorgangList;
|
||||||
|
|
||||||
let isEmptyList = vorgangList.length === 0;
|
let isEmptyList = vorgangList.length === 0;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
import ModalContent from '$lib/components/Modal/ModalContent.svelte';
|
import ModalContent from '$lib/components/Modal/ModalContent.svelte';
|
||||||
import ModalFooter from '$lib/components/Modal/ModalFooter.svelte';
|
import ModalFooter from '$lib/components/Modal/ModalFooter.svelte';
|
||||||
import Cube from '$lib/icons/Cube.svelte';
|
import Cube from '$lib/icons/Cube.svelte';
|
||||||
import { invalidate, invalidateAll } from '$app/navigation';
|
import { invalidateAll } from '$app/navigation';
|
||||||
import NameItemEditor from '$lib/components/NameItemEditor.svelte';
|
import NameItemEditor from '$lib/components/NameItemEditor.svelte';
|
||||||
import EmptyList from '$lib/components/EmptyList.svelte';
|
import EmptyList from '$lib/components/EmptyList.svelte';
|
||||||
|
|
||||||
|
|||||||
69
tests/VorgangsList.view.test.ts
Normal file
69
tests/VorgangsList.view.test.ts
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import { render } from '@testing-library/svelte';
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import VorgangsListPage from '../src/routes/(angemeldet)/list/+page.svelte';
|
||||||
|
const testUser = {
|
||||||
|
admin: true,
|
||||||
|
exp: 1757067123,
|
||||||
|
iat: 1757063523,
|
||||||
|
id: "admin",
|
||||||
|
}
|
||||||
|
const testCrimesList = [
|
||||||
|
{
|
||||||
|
name: 'model-A',
|
||||||
|
lastModified: '2025-08-28T09:44:12.453Z',
|
||||||
|
etag: '558f35716f6af953f9bb5d75f6d77e6a',
|
||||||
|
size: 8947140,
|
||||||
|
prefix: '7596e4d5-c51f-482d-a4aa-ff76434305fc',
|
||||||
|
show_button: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'model-z',
|
||||||
|
lastModified: '2025-08-28T10:37:20.142Z',
|
||||||
|
etag: '43e3989c32c4682bee407baaf83b6fa0',
|
||||||
|
size: 35788560,
|
||||||
|
prefix: '7596e4d5-c51f-482d-a4aa-ff76434305fc',
|
||||||
|
show_button: true
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const testVorgangsList = [
|
||||||
|
{
|
||||||
|
vorgangName: "vorgang-1",
|
||||||
|
vorgangPIN: "pin-123",
|
||||||
|
vorgangToken: "c322f26f-8c5e-4cb9-94b3-b5433bf5109e"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
vorgangName: "vorgang-2",
|
||||||
|
vorgangPIN: "pin-2",
|
||||||
|
vorgangToken: "cb0051bc-5f38-47b8-943c-9352d4d9c984"
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
const baseData = {
|
||||||
|
user: testUser,
|
||||||
|
vorgang: testVorgangsList[0],
|
||||||
|
vorgangList: testVorgangsList,
|
||||||
|
crimesList: testCrimesList,
|
||||||
|
url: URL,
|
||||||
|
crimeNames: [ "modell-A" ],
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Vorgänge Liste Page', ()=>{
|
||||||
|
//Hier steht die funktion die getestet wird
|
||||||
|
it('zeigt EmptyList-Komponente, wenn Liste leer ist', () => {
|
||||||
|
const testData = { ...baseData, vorgangList: [] };
|
||||||
|
const { getByTestId } = render(VorgangsListPage, {props:{data: testData}});
|
||||||
|
|
||||||
|
expect(getByTestId('empty-list')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('zeigt EmptyList-Komponente, wenn Liste vorhanden ist', () => {
|
||||||
|
const testData = { ...baseData };
|
||||||
|
const { getAllByTestId } = render(VorgangsListPage, {props:{data: testData}});
|
||||||
|
const items = getAllByTestId('test-list-item');
|
||||||
|
|
||||||
|
expect(items).toHaveLength(2); // z. B. bei 2 Einträgen, da fake 2 Einträge hat
|
||||||
|
});
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user