From 9aa71a7c3f4b90ebc9bd562b51d7933d2cf8b022 Mon Sep 17 00:00:00 2001 From: Chi Cong Tran Date: Thu, 13 Nov 2025 09:23:58 +0100 Subject: [PATCH] =?UTF-8?q?add=20some=20tests=20for=20crimes=20=C2=B4add?= =?UTF-8?q?=C2=B4-button,=20further=20tests=20to=20be=20defined?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/views/TatortList.test.ts | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/views/TatortList.test.ts b/tests/views/TatortList.test.ts index 8e17f7c..8111ae3 100644 --- a/tests/views/TatortList.test.ts +++ b/tests/views/TatortList.test.ts @@ -9,6 +9,21 @@ import { API_ROUTES } from '../../src/routes'; vi.spyOn(nav, 'invalidateAll').mockResolvedValue(); global.fetch = vi.fn().mockResolvedValue({ ok: true }); +async function clickPlusButton() { + // mock animation features of the browser + + window.HTMLElement.prototype.scrollIntoView = vi.fn(); + window.HTMLElement.prototype.animate = vi.fn(() => ({ + finished: Promise.resolve(), + cancel: vi.fn(), + })) + + // button is visible + const button = screen.getByRole('button', { name: /add item/i }) + expect(button).toBeInTheDocument(); + + await fireEvent.click(button) +} describe('Seite: Vorgangsansicht', () => { test.todo('Share Link disabled wenn Liste leer'); @@ -83,3 +98,42 @@ describe('Seite: Vorgangsansicht', () => { }); }); }); + + +describe('Hinzufügen Button', () => { + it('Unexpandierter Button', () => { + const testData = { ...baseData, vorgangList: [] }; + const { getByTestId } = render(TatortListPage, { props: { data: testData } }); + + const container = getByTestId('expand-container') + expect(container).toBeInTheDocument(); + + // button is visible + const button = within(container).getByRole('button') + expect(button).toBeInTheDocument(); + + // input fields are not visible + let label = screen.queryByText('Modellname'); + expect(label).not.toBeInTheDocument(); + }); + + it('Expandierter Button nach Klick', async () => { + + const testData = { ...baseData, vorgangList: [] }; + render(TatortListPage, { props: { data: testData } }); + + await clickPlusButton(); + + // input fields are visible + let label = screen.queryByText('Modellname'); + expect(label).toBeInTheDocument(); + }); + + it.todo('Check Validation: missing name', async () => { + console.log(`test: input field validation`); + }); + + it.skip('Create Tatort successful', async () => { + console.log(`test: tatort upload`); + }); +}); \ No newline at end of file