Update admin PWA events, branding, and packages
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-19 11:35:38 +01:00
parent 926bc7d070
commit fbff2afa3e
43 changed files with 6846 additions and 6323 deletions

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { act, fireEvent, render, screen } from '@testing-library/react';
const backMock = vi.fn();
@@ -7,10 +7,11 @@ const navigateMock = vi.fn();
const selectEventMock = vi.fn();
const refetchMock = vi.fn();
const invalidateQueriesMock = vi.fn();
const paramsState: { slug?: string } = {};
vi.mock('react-router-dom', () => ({
useNavigate: () => navigateMock,
useParams: () => ({}),
useParams: () => paramsState,
}));
vi.mock('@tanstack/react-query', () => ({
@@ -50,11 +51,18 @@ vi.mock('../components/Primitives', () => ({
{label}
</button>
),
FloatingActionButton: ({ label, onPress }: { label: string; onPress?: () => void }) => (
<button type="button" onClick={onPress}>
{label}
</button>
),
}));
vi.mock('../components/FormControls', () => ({
MobileField: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
MobileDateTimeInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
MobileDateTimeInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => (
<input type="datetime-local" {...props} />
),
MobileInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
MobileSelect: ({ children, ...props }: { children: React.ReactNode }) => <select {...props}>{children}</select>,
MobileTextArea: (props: React.TextareaHTMLAttributes<HTMLTextAreaElement>) => <textarea {...props} />,
@@ -108,11 +116,16 @@ vi.mock('../../context/EventContext', () => ({
}),
}));
import { getEventTypes } from '../../api';
import { getEvent, getEventTypes } from '../../api';
import MobileEventFormPage from '../EventFormPage';
describe('MobileEventFormPage', () => {
afterEach(() => {
paramsState.slug = undefined;
});
it('renders a save draft button when creating a new event', async () => {
paramsState.slug = undefined;
await act(async () => {
render(<MobileEventFormPage />);
});
@@ -124,6 +137,7 @@ describe('MobileEventFormPage', () => {
});
it('defaults event type to wedding when available', async () => {
paramsState.slug = undefined;
vi.mocked(getEventTypes).mockResolvedValueOnce([
{ id: 11, slug: 'conference', name: 'Conference', name_translations: {}, icon: null, settings: {} },
{ id: 22, slug: 'wedding', name: 'Wedding', name_translations: {}, icon: null, settings: {} },
@@ -136,4 +150,24 @@ describe('MobileEventFormPage', () => {
const select = screen.getByRole('combobox');
expect(select).toHaveValue('22');
});
it('disables the date field when the event is completed', async () => {
paramsState.slug = 'past-event';
vi.mocked(getEvent).mockResolvedValueOnce({
id: 1,
name: 'Past event',
slug: 'past-event',
event_date: '2020-01-01T10:00:00Z',
event_type_id: null,
event_type: null,
status: 'archived',
description: null,
settings: {},
} as any);
render(<MobileEventFormPage />);
const dateInput = await screen.findByDisplayValue('2020-01-01T10:00');
expect(dateInput).toBeDisabled();
});
});