fix(tests): fix type errors in spec files after adding user to App.PageData
Some checks failed
CI / Unit & Component Tests (push) Has been cancelled
CI / Backend Unit Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Unit & Component Tests (pull_request) Successful in 1m57s
CI / Backend Unit Tests (pull_request) Successful in 1m55s
CI / E2E Tests (pull_request) Failing after 14m6s
Some checks failed
CI / Unit & Component Tests (push) Has been cancelled
CI / Backend Unit Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Unit & Component Tests (pull_request) Successful in 1m57s
CI / Backend Unit Tests (pull_request) Successful in 1m55s
CI / E2E Tests (pull_request) Failing after 14m6s
Add user: undefined to baseData in conversations and documents/new specs. Change null to undefined for filePath/transcription in makeDoc fixture. Add form: null to render calls missing it. Fix birthYear conversion from string to number in persons/[id] server action. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ afterEach(cleanup);
|
|||||||
// ─── Test data ────────────────────────────────────────────────────────────────
|
// ─── Test data ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const baseData = {
|
const baseData = {
|
||||||
|
user: undefined,
|
||||||
canWrite: true,
|
canWrite: true,
|
||||||
documents: [],
|
documents: [],
|
||||||
initialValues: { senderName: '', receiverName: '' },
|
initialValues: { senderName: '', receiverName: '' },
|
||||||
@@ -31,8 +32,8 @@ const makeDoc = (overrides: Record<string, unknown> = {}) => ({
|
|||||||
sender: { id: 'p1', firstName: 'Hans', lastName: 'Müller' },
|
sender: { id: 'p1', firstName: 'Hans', lastName: 'Müller' },
|
||||||
receivers: [{ id: 'p2', firstName: 'Anna', lastName: 'Schmidt' }],
|
receivers: [{ id: 'p2', firstName: 'Anna', lastName: 'Schmidt' }],
|
||||||
tags: [],
|
tags: [],
|
||||||
transcription: null,
|
transcription: undefined,
|
||||||
filePath: null,
|
filePath: undefined,
|
||||||
createdAt: '1923-04-12T00:00:00Z',
|
createdAt: '1923-04-12T00:00:00Z',
|
||||||
updatedAt: '1923-04-12T00:00:00Z',
|
updatedAt: '1923-04-12T00:00:00Z',
|
||||||
...overrides
|
...overrides
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ afterEach(cleanup);
|
|||||||
// ─── Test data ────────────────────────────────────────────────────────────────
|
// ─── Test data ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const baseData = {
|
const baseData = {
|
||||||
|
user: undefined,
|
||||||
|
canWrite: true,
|
||||||
persons: [],
|
persons: [],
|
||||||
initialSenderId: '',
|
initialSenderId: '',
|
||||||
initialSenderName: '',
|
initialSenderName: '',
|
||||||
@@ -18,14 +20,15 @@ const baseData = {
|
|||||||
|
|
||||||
describe('New document page – sender prefill', () => {
|
describe('New document page – sender prefill', () => {
|
||||||
it('shows an empty sender input when no senderId is in the URL', async () => {
|
it('shows an empty sender input when no senderId is in the URL', async () => {
|
||||||
render(Page, { data: baseData });
|
render(Page, { data: baseData, form: null });
|
||||||
const input = document.querySelector<HTMLInputElement>('#senderId-search');
|
const input = document.querySelector<HTMLInputElement>('#senderId-search');
|
||||||
expect(input?.value).toBe('');
|
expect(input?.value).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows the sender name in the typeahead input when initialSenderName is set', async () => {
|
it('shows the sender name in the typeahead input when initialSenderName is set', async () => {
|
||||||
render(Page, {
|
render(Page, {
|
||||||
data: { ...baseData, initialSenderId: 'p1', initialSenderName: 'Hans Müller' }
|
data: { ...baseData, initialSenderId: 'p1', initialSenderName: 'Hans Müller' },
|
||||||
|
form: null
|
||||||
});
|
});
|
||||||
const input = document.querySelector<HTMLInputElement>('#senderId-search');
|
const input = document.querySelector<HTMLInputElement>('#senderId-search');
|
||||||
expect(input?.value).toBe('Hans Müller');
|
expect(input?.value).toBe('Hans Müller');
|
||||||
@@ -33,7 +36,8 @@ describe('New document page – sender prefill', () => {
|
|||||||
|
|
||||||
it('sets the hidden senderId input to the prefilled ID', async () => {
|
it('sets the hidden senderId input to the prefilled ID', async () => {
|
||||||
render(Page, {
|
render(Page, {
|
||||||
data: { ...baseData, initialSenderId: 'p1', initialSenderName: 'Hans Müller' }
|
data: { ...baseData, initialSenderId: 'p1', initialSenderName: 'Hans Müller' },
|
||||||
|
form: null
|
||||||
});
|
});
|
||||||
const hidden = document.querySelector<HTMLInputElement>(
|
const hidden = document.querySelector<HTMLInputElement>(
|
||||||
'input[type="hidden"][name="senderId"]'
|
'input[type="hidden"][name="senderId"]'
|
||||||
@@ -46,7 +50,7 @@ describe('New document page – sender prefill', () => {
|
|||||||
|
|
||||||
describe('New document page – receiver prefill', () => {
|
describe('New document page – receiver prefill', () => {
|
||||||
it('shows no receiver chips when initialReceivers is empty', async () => {
|
it('shows no receiver chips when initialReceivers is empty', async () => {
|
||||||
render(Page, { data: baseData });
|
render(Page, { data: baseData, form: null });
|
||||||
await expect.element(page.getByText('Anna Schmidt')).not.toBeInTheDocument();
|
await expect.element(page.getByText('Anna Schmidt')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -55,7 +59,7 @@ describe('New document page – receiver prefill', () => {
|
|||||||
...baseData,
|
...baseData,
|
||||||
initialReceivers: [{ id: 'p2', firstName: 'Anna', lastName: 'Schmidt' }]
|
initialReceivers: [{ id: 'p2', firstName: 'Anna', lastName: 'Schmidt' }]
|
||||||
};
|
};
|
||||||
render(Page, { data });
|
render(Page, { data, form: null });
|
||||||
await expect.element(page.getByText('Anna Schmidt')).toBeInTheDocument();
|
await expect.element(page.getByText('Anna Schmidt')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -64,7 +68,7 @@ describe('New document page – receiver prefill', () => {
|
|||||||
...baseData,
|
...baseData,
|
||||||
initialReceivers: [{ id: 'p2', firstName: 'Anna', lastName: 'Schmidt' }]
|
initialReceivers: [{ id: 'p2', firstName: 'Anna', lastName: 'Schmidt' }]
|
||||||
};
|
};
|
||||||
render(Page, { data });
|
render(Page, { data, form: null });
|
||||||
const hidden = document.querySelector<HTMLInputElement>('input[name="receiverIds"]');
|
const hidden = document.querySelector<HTMLInputElement>('input[name="receiverIds"]');
|
||||||
expect(hidden?.value).toBe('p2');
|
expect(hidden?.value).toBe('p2');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ export const actions = {
|
|||||||
const lastName = formData.get('lastName')?.toString().trim();
|
const lastName = formData.get('lastName')?.toString().trim();
|
||||||
const alias = formData.get('alias')?.toString().trim() || undefined;
|
const alias = formData.get('alias')?.toString().trim() || undefined;
|
||||||
const notes = formData.get('notes')?.toString().trim() || undefined;
|
const notes = formData.get('notes')?.toString().trim() || undefined;
|
||||||
const birthYear = formData.get('birthYear')?.toString().trim() || undefined;
|
const birthYearStr = formData.get('birthYear')?.toString().trim();
|
||||||
const deathYear = formData.get('deathYear')?.toString().trim() || undefined;
|
const deathYearStr = formData.get('deathYear')?.toString().trim();
|
||||||
|
const birthYear = birthYearStr ? parseInt(birthYearStr, 10) : undefined;
|
||||||
|
const deathYear = deathYearStr ? parseInt(deathYearStr, 10) : undefined;
|
||||||
|
|
||||||
if (!firstName || !lastName) {
|
if (!firstName || !lastName) {
|
||||||
return fail(400, { updateError: 'Vor- und Nachname sind Pflichtfelder.' });
|
return fail(400, { updateError: 'Vor- und Nachname sind Pflichtfelder.' });
|
||||||
|
|||||||
Reference in New Issue
Block a user