`description` is optional in the request schema, but the column is
NOT NULL with no default, so an omitted description reached Prisma as
undefined and the create threw a validation error instead of saving:
Invalid `prisma.board.create()` invocation
Argument `description` is missing.
Default it to an empty string, matching what the UI sends today, and
cover it with an API test.
36 lines
950 B
TypeScript
36 lines
950 B
TypeScript
import { expect, test } from '@playwright/test';
|
|
import { type Auth, authHeaders, loginViaApi } from './helpers';
|
|
|
|
test.describe('Board API tests', () => {
|
|
test.describe.configure({ mode: 'serial' });
|
|
|
|
let auth: Auth;
|
|
let boardId = '';
|
|
|
|
test.beforeAll(async ({ request }) => {
|
|
auth = await loginViaApi(request);
|
|
});
|
|
|
|
test.afterAll(async ({ request }) => {
|
|
if (boardId) {
|
|
await request.delete(`/api/boards/${boardId}`, { headers: authHeaders(auth) });
|
|
}
|
|
});
|
|
|
|
test('creates a board without a description', async ({ request }) => {
|
|
const response = await request.post('/api/boards', {
|
|
headers: authHeaders(auth),
|
|
data: { name: 'Playwright board', type: 'mixed' },
|
|
});
|
|
|
|
expect(response.status()).toBe(200);
|
|
|
|
const body = await response.json();
|
|
|
|
boardId = body.id;
|
|
|
|
expect(body).toHaveProperty('name', 'Playwright board');
|
|
expect(body).toHaveProperty('description', '');
|
|
});
|
|
});
|