add some tests for crimes ´add´-button, further tests to be defined
This commit is contained in:
@@ -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`);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user