Fix TypeScript typecheck errors
This commit is contained in:
@@ -2,6 +2,7 @@ import React from 'react';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { render, screen, waitFor, within } from '@testing-library/react';
|
||||
import { ADMIN_EVENTS_PATH } from '../../constants';
|
||||
import type { TenantEvent } from '../../api';
|
||||
|
||||
const fixtures = vi.hoisted(() => ({
|
||||
event: {
|
||||
@@ -9,14 +10,17 @@ const fixtures = vi.hoisted(() => ({
|
||||
name: 'Demo Wedding',
|
||||
slug: 'demo-event',
|
||||
event_date: '2026-02-19',
|
||||
status: 'published' as const,
|
||||
settings: { location: 'Berlin' },
|
||||
event_type_id: null,
|
||||
event_type: null,
|
||||
status: 'published',
|
||||
engagement_mode: undefined,
|
||||
settings: { location: 'Berlin', guest_upload_visibility: 'immediate' },
|
||||
tasks_count: 4,
|
||||
photo_count: 12,
|
||||
active_invites_count: 3,
|
||||
total_invites_count: 5,
|
||||
member_permissions: ['photos:moderate', 'tasks:manage', 'join-tokens:manage'],
|
||||
},
|
||||
} as TenantEvent,
|
||||
activePackage: {
|
||||
id: 1,
|
||||
package_id: 1,
|
||||
|
||||
@@ -138,7 +138,9 @@ vi.mock('../components/Primitives', () => ({
|
||||
}));
|
||||
|
||||
vi.mock('../components/FormControls', () => ({
|
||||
MobileInput: ({ compact: _compact, ...props }: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
|
||||
MobileInput: ({ compact: _compact, ...props }: { compact?: boolean } & React.InputHTMLAttributes<HTMLInputElement>) => (
|
||||
<input {...props} />
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock('@tamagui/card', () => ({
|
||||
|
||||
@@ -13,18 +13,36 @@ const fixtures = vi.hoisted(() => ({
|
||||
invites: [
|
||||
{
|
||||
id: 1,
|
||||
token: 'invite-token',
|
||||
url: 'https://example.test/guest/demo-event',
|
||||
qr_code_data_url: '',
|
||||
label: null,
|
||||
qr_code_data_url: null,
|
||||
usage_limit: null,
|
||||
usage_count: 0,
|
||||
expires_at: null,
|
||||
revoked_at: null,
|
||||
is_active: true,
|
||||
created_at: '2026-01-15T12:00:00Z',
|
||||
metadata: {},
|
||||
layouts: [
|
||||
{
|
||||
id: 'layout-1',
|
||||
name: 'Poster Layout',
|
||||
description: 'Layout description',
|
||||
subtitle: 'Layout subtitle',
|
||||
paper: 'a4',
|
||||
orientation: 'portrait',
|
||||
panel_mode: 'single',
|
||||
preview: {
|
||||
background: null,
|
||||
background_gradient: null,
|
||||
accent: null,
|
||||
text: null,
|
||||
},
|
||||
formats: [],
|
||||
},
|
||||
],
|
||||
layouts_url: null,
|
||||
},
|
||||
],
|
||||
}));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
const fixtures = vi.hoisted(() => ({
|
||||
event: {
|
||||
@@ -74,7 +75,11 @@ vi.mock('../components/MobileShell', () => ({
|
||||
|
||||
vi.mock('../components/Primitives', () => ({
|
||||
MobileCard: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||
CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
|
||||
CTAButton: ({ label, onPress, disabled }: { label: string; onPress?: () => void; disabled?: boolean }) => (
|
||||
<button type="button" onClick={onPress} disabled={disabled}>
|
||||
{label}
|
||||
</button>
|
||||
),
|
||||
PillBadge: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||
}));
|
||||
|
||||
@@ -116,6 +121,7 @@ vi.mock('../theme', () => ({
|
||||
}));
|
||||
|
||||
import MobileQrPrintPage from '../QrPrintPage';
|
||||
import { createQrInvite } from '../../api';
|
||||
|
||||
describe('MobileQrPrintPage', () => {
|
||||
it('renders QR overview content', async () => {
|
||||
@@ -125,4 +131,19 @@ describe('MobileQrPrintPage', () => {
|
||||
expect(screen.getByText('Schritt 1: Format wählen')).toBeInTheDocument();
|
||||
expect(screen.getAllByText('Neuen QR-Link erstellen').length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('requires confirmation before creating a new QR link', async () => {
|
||||
const user = userEvent.setup();
|
||||
const confirmSpy = vi.fn().mockReturnValue(false);
|
||||
window.confirm = confirmSpy;
|
||||
|
||||
render(<MobileQrPrintPage />);
|
||||
|
||||
const createButton = await screen.findByRole('button', { name: 'Neuen QR-Link erstellen' });
|
||||
await user.click(createButton);
|
||||
|
||||
expect(confirmSpy).toHaveBeenCalled();
|
||||
expect(confirmSpy).toHaveBeenCalledWith(expect.stringContaining('Ausdrucke'));
|
||||
expect(createQrInvite).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -62,7 +62,7 @@ describe('selectRecommendedPackageId', () => {
|
||||
] as any;
|
||||
|
||||
it('returns null when no feature is requested', () => {
|
||||
expect(selectRecommendedPackageId(packages, null, 100)).toBeNull();
|
||||
expect(selectRecommendedPackageId(packages, null, null)).toBeNull();
|
||||
});
|
||||
|
||||
it('selects the cheapest upgrade with the feature', () => {
|
||||
|
||||
Reference in New Issue
Block a user