Adds the Offerings module and retargets the CI/CD pipeline to Api.SlpSoftware
Continuous Integration / config (pull_request) Successful in 12s
Continuous Integration / changes (pull_request) Successful in 22s
Continuous Integration / backend-build (pull_request) Successful in 5m53s
Continuous Integration / vulnerability-scan (pull_request) Successful in 5m46s
Continuous Integration / frontend-prepare (pull_request) Successful in 1m54s
Continuous Integration / backend-test (pull_request) Successful in 7m37s
Continuous Integration / frontend-build (pull_request) Successful in 2m14s
Continuous Integration / frontend-test (pull_request) Successful in 4m59s
Continuous Integration / frontend-lint (pull_request) Successful in 2m2s
Continuous Integration / publish-production (pull_request) Skipped
Continuous Integration / deploy-production (pull_request) Skipped
Continuous Integration / publish-test (pull_request) Successful in 7m34s
Continuous Integration / deploy-test (pull_request) Skipped

Implements Unit 2 "Offerings" (backend module, admin CRUD UI with
drag-and-drop reordering, public GET /api/v1/offerings endpoint) and
executes the feature's D-15 CI/CD cutover, switching the deploy
pipeline's build/publish target from SlpModularCms.Api to
SlpModularCms.Api.SlpSoftware.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FWyStNL2ZsjrS7FLd7xvvN
This commit is contained in:
2026-08-02 16:23:09 +02:00
co-authored by Claude Sonnet 5
parent b6e9c07c06
commit cfb06b28b6
79 changed files with 4069 additions and 94 deletions
@@ -0,0 +1,50 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { screen } 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 { _resetSetupStatusCache } from '@/router';
beforeEach(() => {
_resetSetupStatusCache();
resetMockOfferings();
});
describe('OfferingFormPage', () => {
it('creates a new offering and returns to the list', async () => {
mockAuthenticated();
renderApp('/offerings/new');
await screen.findByTestId('offering-form-submit', {}, { timeout: 10000 });
await userEvent.type(screen.getByTestId('offering-title'), 'Enterprise');
await userEvent.type(screen.getByTestId('offering-description'), 'A large website');
await userEvent.type(screen.getByTestId('offering-price'), '€ 2000');
await userEvent.type(screen.getByTestId('offering-price-note'), 'one-time');
await userEvent.type(screen.getByTestId('offering-feature-0'), 'Unlimited pages');
await userEvent.type(screen.getByTestId('offering-cta-label'), 'Contact us');
await userEvent.click(screen.getByTestId('offering-form-submit'));
expect(await screen.findByTestId('offerings-title', {}, { timeout: 10000 })).toBeInTheDocument();
expect(screen.getByText('Enterprise')).toBeInTheDocument();
});
it('shows a validation error when required fields are missing', async () => {
mockAuthenticated();
renderApp('/offerings/new');
await screen.findByTestId('offering-form-submit', {}, { timeout: 10000 });
await userEvent.click(screen.getByTestId('offering-form-submit'));
expect(await screen.findByTestId('offering-title-error')).toBeInTheDocument();
});
it('pre-fills the form when editing an existing offering', async () => {
mockAuthenticated();
renderApp('/offerings/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/edit');
const titleInput = await screen.findByTestId('offering-title', {}, { timeout: 10000 });
expect(titleInput).toHaveValue('Starter');
});
});
@@ -0,0 +1,59 @@
import { useState } from 'react';
import { useNavigate, useParams } from '@tanstack/react-router';
import { useTranslation } from 'react-i18next';
import { toast } from 'sonner';
import { FormErrorBanner } from '@/components/ui/FormErrorBanner';
import { OfferingForm } from '../components/OfferingForm';
import { useOffering } from '../services/useOffering';
import { useCreateOffering } from '../services/useCreateOffering';
import { useUpdateOffering } from '../services/useUpdateOffering';
import { NetworkError } from '@/lib/api-client';
import type { OfferingFormData } from '../schemas/offering';
export function OfferingFormPage() {
const { t } = useTranslation();
const navigate = useNavigate();
const { id } = useParams({ strict: false }) as { id?: string };
const isEdit = id !== undefined;
const [serverError, setServerError] = useState<string | null>(null);
const { data: existingOffering, isPending: isLoadingExisting } = useOffering(id);
const createOffering = useCreateOffering();
const updateOffering = useUpdateOffering();
const isSubmitting = createOffering.isPending || updateOffering.isPending;
const onSubmit = async (values: OfferingFormData) => {
setServerError(null);
try {
if (isEdit && id !== undefined) {
await updateOffering.mutateAsync({ id, ...values });
} else {
await createOffering.mutateAsync(values);
}
toast.success(t('offerings.form.successToast'));
navigate({ to: '/offerings' });
} catch (err) {
setServerError(err instanceof NetworkError ? t('errors.network') : t('errors.generic'));
}
};
if (isEdit && isLoadingExisting) {
return <p className="p-4 text-sm text-muted-foreground">{t('common.loading')}</p>;
}
return (
<div className="max-w-2xl space-y-4 p-4">
<h1 className="text-2xl font-semibold" data-testid="offering-form-title">
{isEdit ? t('offerings.form.editTitle') : t('offerings.form.createTitle')}
</h1>
<FormErrorBanner
error={serverError !== null ? { message: serverError } : null}
onDismiss={() => setServerError(null)}
/>
<OfferingForm initialValues={existingOffering} onSubmit={onSubmit} isSubmitting={isSubmitting} />
</div>
);
}
@@ -0,0 +1,94 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { http, HttpResponse } from 'msw';
import { renderApp, mockAuthenticated, mockGuest } from '@/test/utils';
import { server } from '@/mocks/server';
import { API_BASE } from '@/features/auth/mocks/fixtures';
import { resetMockOfferings } from '@/features/offerings/mocks/handlers';
import { _resetSetupStatusCache } from '@/router';
beforeEach(() => {
_resetSetupStatusCache();
resetMockOfferings();
});
const OFFERINGS_URL = `${API_BASE}/api/v1/offerings/admin`;
describe('OfferingsListPage', () => {
it('renders the page title and Add button', async () => {
mockAuthenticated();
renderApp('/offerings');
expect(await screen.findByTestId('offerings-title', {}, { timeout: 10000 })).toBeInTheDocument();
expect(screen.getByTestId('offerings-add-button')).toBeInTheDocument();
});
it('renders the seeded offerings', async () => {
mockAuthenticated();
renderApp('/offerings');
expect(await screen.findByText('Starter', {}, { timeout: 10000 })).toBeInTheDocument();
expect(screen.getByText('Pro')).toBeInTheDocument();
});
it('renders empty state when no offerings exist', async () => {
mockAuthenticated();
server.use(http.get(OFFERINGS_URL, () => HttpResponse.json([])));
renderApp('/offerings');
expect(await screen.findByTestId('offerings-empty-state', {}, { timeout: 10000 })).toBeInTheDocument();
});
it('deletes an offering after confirmation', async () => {
mockAuthenticated();
renderApp('/offerings');
const deleteButton = await screen.findByTestId(
'offering-row-aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa-delete-button',
{},
{ timeout: 10000 },
);
await userEvent.click(deleteButton);
await userEvent.click(await screen.findByTestId('delete-offering-confirm'));
expect(screen.queryByText('Starter')).not.toBeInTheDocument();
expect(screen.getByText('Pro')).toBeInTheDocument();
});
it('cancels delete without removing the offering', async () => {
mockAuthenticated();
renderApp('/offerings');
const deleteButton = await screen.findByTestId(
'offering-row-aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa-delete-button',
{},
{ timeout: 10000 },
);
await userEvent.click(deleteButton);
await userEvent.click(await screen.findByTestId('delete-offering-cancel'));
expect(screen.getByText('Starter')).toBeInTheDocument();
});
it('disables the move-up button on the first row and move-down on the last', async () => {
mockAuthenticated();
renderApp('/offerings');
await screen.findByText('Starter', {}, { timeout: 10000 });
expect(
screen.getByTestId('offering-row-aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa-move-up-button'),
).toBeDisabled();
expect(
screen.getByTestId('offering-row-bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb-move-down-button'),
).toBeDisabled();
});
it('redirects unauthenticated users to login', async () => {
mockGuest();
renderApp('/offerings');
expect(await screen.findByTestId('login-form-submit-button')).toBeInTheDocument();
});
});
@@ -0,0 +1,63 @@
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from '@tanstack/react-router';
import { Package } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { OfferingsList } from '../components/OfferingsList';
import { DeleteOfferingDialog } from '../components/DeleteOfferingDialog';
import { useOfferings } from '../services/useOfferings';
import { useDeleteOffering } from '../services/useDeleteOffering';
import type { OfferingAdminDto } from '../services/types';
export function OfferingsListPage() {
const { t } = useTranslation();
const [offeringPendingDelete, setOfferingPendingDelete] = useState<OfferingAdminDto | null>(null);
const { data: offerings, isPending, isError } = useOfferings();
const deleteOffering = useDeleteOffering({
onSuccess: () => setOfferingPendingDelete(null),
});
return (
<div className="space-y-4 p-4">
<div className="flex items-center justify-between">
<h1 className="text-2xl font-semibold" data-testid="offerings-title">
{t('offerings.title')}
</h1>
<Button asChild data-testid="offerings-add-button">
<Link to="/offerings/new">{t('offerings.addButton')}</Link>
</Button>
</div>
{isPending && <p className="text-sm text-muted-foreground">{t('common.loading')}</p>}
{isError && <p className="text-sm text-destructive">{t('errors.generic')}</p>}
{!isPending && !isError && offerings?.length === 0 && (
<div
className="flex flex-col items-center justify-center py-16 text-center space-y-4"
data-testid="offerings-empty-state"
>
<Package className="size-12 text-muted-foreground" />
<h2 className="text-xl font-semibold">{t('offerings.emptyState.heading')}</h2>
<p className="text-muted-foreground max-w-sm">{t('offerings.emptyState.description')}</p>
<Button asChild data-testid="offerings-empty-add-button">
<Link to="/offerings/new">{t('offerings.addButton')}</Link>
</Button>
</div>
)}
{!isPending && !isError && offerings && offerings.length > 0 && (
<OfferingsList offerings={offerings} onDeleteRequested={setOfferingPendingDelete} />
)}
<DeleteOfferingDialog
offering={offeringPendingDelete}
isDeleting={deleteOffering.isPending}
onConfirm={() => {
if (offeringPendingDelete) deleteOffering.mutate(offeringPendingDelete.id);
}}
onCancel={() => setOfferingPendingDelete(null)}
/>
</div>
);
}