Offerings: beschrijving en prijsnotitie optioneel (API, admin, index-markers, OpenAPI)
Ontbrekend/null/leeg wordt als lege string opgeslagen en teruggegeven; JSON-LD laat description weg en de HTML-markers renderen geen lege <p>. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,24 @@ describe('OfferingFormPage', () => {
|
||||
expect(screen.getByText('Enterprise')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('saves an offering without description and price note', async () => {
|
||||
mockAuthenticated();
|
||||
renderApp('/offerings/new');
|
||||
|
||||
await screen.findByTestId('offering-form-submit', {}, { timeout: 10000 });
|
||||
expect(screen.getByLabelText(/optioneel|optional/i, { selector: '#offering-description' })).toBeInTheDocument();
|
||||
|
||||
await userEvent.type(screen.getByTestId('offering-title'), 'Gezin');
|
||||
await userEvent.type(screen.getByTestId('offering-price'), '€ 175');
|
||||
await userEvent.type(screen.getByTestId('offering-feature-0'), '1 uur fotografie');
|
||||
await userEvent.type(screen.getByTestId('offering-cta-label'), 'Boek');
|
||||
await userEvent.click(screen.getByTestId('offering-form-submit'));
|
||||
|
||||
expect(await screen.findByTestId('offerings-title', {}, { timeout: 10000 })).toBeInTheDocument();
|
||||
expect(screen.getByText('Gezin')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('offering-description-error')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows a validation error when required fields are missing', async () => {
|
||||
mockAuthenticated();
|
||||
renderApp('/offerings/new');
|
||||
|
||||
@@ -3,15 +3,10 @@ import { z } from 'zod';
|
||||
export const offeringFormSchema = z
|
||||
.object({
|
||||
title: z.string().min(1, 'Title is required').max(100, 'Title must be 100 characters or fewer'),
|
||||
description: z
|
||||
.string()
|
||||
.min(1, 'Description is required')
|
||||
.max(500, 'Description must be 500 characters or fewer'),
|
||||
/** Optional: an empty value is stored as an empty string. */
|
||||
description: z.string().max(500, 'Description must be 500 characters or fewer'),
|
||||
price: z.string().min(1, 'Price is required').max(50, 'Price must be 50 characters or fewer'),
|
||||
priceNote: z
|
||||
.string()
|
||||
.min(1, 'Price note is required')
|
||||
.max(100, 'Price note must be 100 characters or fewer'),
|
||||
priceNote: z.string().max(100, 'Price note must be 100 characters or fewer'),
|
||||
features: z
|
||||
.array(z.string().min(1, 'Feature cannot be empty').max(200, 'Feature must be 200 characters or fewer'))
|
||||
.min(1, 'At least 1 feature is required')
|
||||
|
||||
@@ -431,9 +431,9 @@
|
||||
"editSlugButton": "Edit",
|
||||
"confirmSlugButton": "Confirm slug",
|
||||
"cancelSlugEditButton": "Cancel slug edit",
|
||||
"descriptionLabel": "Description",
|
||||
"descriptionLabel": "Description (optional)",
|
||||
"priceLabel": "Price",
|
||||
"priceNoteLabel": "Price note",
|
||||
"priceNoteLabel": "Price note (optional)",
|
||||
"featuresLabel": "Features",
|
||||
"addFeatureButton": "Add feature",
|
||||
"removeFeatureButton": "Remove",
|
||||
|
||||
@@ -431,9 +431,9 @@
|
||||
"editSlugButton": "Aanpassen",
|
||||
"confirmSlugButton": "Slug bevestigen",
|
||||
"cancelSlugEditButton": "Slug-bewerking annuleren",
|
||||
"descriptionLabel": "Beschrijving",
|
||||
"descriptionLabel": "Beschrijving (optioneel)",
|
||||
"priceLabel": "Prijs",
|
||||
"priceNoteLabel": "Prijsnotitie",
|
||||
"priceNoteLabel": "Prijsnotitie (optioneel)",
|
||||
"featuresLabel": "Kenmerken",
|
||||
"addFeatureButton": "Kenmerk toevoegen",
|
||||
"removeFeatureButton": "Verwijderen",
|
||||
|
||||
Reference in New Issue
Block a user