Offerings: layout (card|banner) op aanbod, max 1 banner, admin-keuze, additief in GET /api/v1/offerings
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
import { screen } from '@testing-library/react';
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { renderApp, mockAuthenticated } from '@/test/utils';
|
||||
import { resetMockOfferings } from '@/features/offerings/mocks/handlers';
|
||||
import { getMockOfferings, resetMockOfferings } from '@/features/offerings/mocks/handlers';
|
||||
import { _resetSetupStatusCache } from '@/router';
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -119,4 +119,34 @@ describe('OfferingFormPage', () => {
|
||||
|
||||
expect(await screen.findByText(/pro.*al in gebruik|already.*taken/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('defaults the layout to card and shows a hint only when banner is chosen', async () => {
|
||||
mockAuthenticated();
|
||||
renderApp('/offerings/new');
|
||||
|
||||
const select = await screen.findByTestId('offering-layout', {}, { timeout: 10000 });
|
||||
expect(select).toHaveValue('card');
|
||||
expect(screen.queryByTestId('offering-layout-banner-hint')).not.toBeInTheDocument();
|
||||
|
||||
await userEvent.selectOptions(select, 'banner');
|
||||
expect(await screen.findByTestId('offering-layout-banner-hint')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('saves a banner and turns the previous banner back into a card', async () => {
|
||||
mockAuthenticated();
|
||||
const first = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa';
|
||||
const second = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb';
|
||||
|
||||
renderApp(`/offerings/${first}/edit`);
|
||||
await userEvent.selectOptions(await screen.findByTestId('offering-layout', {}, { timeout: 10000 }), 'banner');
|
||||
await userEvent.click(screen.getByTestId('offering-form-submit'));
|
||||
await waitFor(() => expect(getMockOfferings().find((o) => o.id === first)?.layout).toBe('banner'));
|
||||
await screen.findByTestId('offerings-title', {}, { timeout: 10000 });
|
||||
|
||||
renderApp(`/offerings/${second}/edit`);
|
||||
await userEvent.selectOptions(await screen.findByTestId('offering-layout', {}, { timeout: 10000 }), 'banner');
|
||||
await userEvent.click(screen.getByTestId('offering-form-submit'));
|
||||
await waitFor(() => expect(getMockOfferings().find((o) => o.id === second)?.layout).toBe('banner'));
|
||||
expect(getMockOfferings().find((o) => o.id === first)?.layout).toBe('card');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user