feat: KAN-30
This commit is contained in:
@@ -123,10 +123,13 @@ const fieldDefinitions = [
|
||||
{ id: 1, label: 'Impact score', field_type: 'number' },
|
||||
{ id: 2, label: 'Reviewer', field_type: 'user' },
|
||||
];
|
||||
let savedForm = {};
|
||||
function makePage(url) {
|
||||
const parsed = new URL(url, 'http://localhost');
|
||||
const params = parsed.searchParams;
|
||||
const detail = parsed.pathname.startsWith('/projects/7/tickets/');
|
||||
const creating = parsed.pathname.endsWith('/create');
|
||||
const detail =
|
||||
!creating && parsed.pathname.startsWith('/projects/7/tickets/');
|
||||
const data = structuredClone(ticket);
|
||||
if (parsed.pathname.endsWith('/41')) {
|
||||
Object.assign(data, linked, {
|
||||
@@ -136,7 +139,7 @@ function makePage(url) {
|
||||
});
|
||||
}
|
||||
if (params.has('saved')) {
|
||||
data.title = params.get('saved');
|
||||
Object.assign(data, savedForm, { title: params.get('saved') });
|
||||
}
|
||||
if (params.has('long')) {
|
||||
data.title = 'LongUnbrokenTicketTitle'.repeat(10);
|
||||
@@ -168,7 +171,11 @@ function makePage(url) {
|
||||
? 'Repository temporarily unavailable.'
|
||||
: null;
|
||||
return {
|
||||
component: detail ? 'Ticket' : 'Destination',
|
||||
component: creating
|
||||
? 'TicketCreate'
|
||||
: detail
|
||||
? 'Ticket'
|
||||
: 'Destination',
|
||||
url,
|
||||
version: null,
|
||||
clearHistory: false,
|
||||
@@ -176,7 +183,28 @@ function makePage(url) {
|
||||
props: {
|
||||
name: 'KanbanGit',
|
||||
errors: params.has('rejected')
|
||||
? { title: 'This title is not allowed.' }
|
||||
? {
|
||||
title: 'This title is not allowed.',
|
||||
...(params.has('allErrors')
|
||||
? {
|
||||
description: 'Invalid description.',
|
||||
ticket_type_id: 'Invalid type.',
|
||||
ticket_priority_id: 'Invalid priority.',
|
||||
ticket_status_id: 'Invalid status.',
|
||||
assignee_user_id: 'Invalid assignee.',
|
||||
author_user_id: 'Invalid author.',
|
||||
parent_ticket_id: 'Invalid parent.',
|
||||
story_points: 'Invalid points.',
|
||||
'acceptance_criteria.0.text':
|
||||
'Invalid checklist.',
|
||||
blocked_comment: 'Invalid blocker.',
|
||||
'field_values.0.value_number':
|
||||
'Invalid number.',
|
||||
'field_values.1.value_user_id':
|
||||
'Invalid reviewer.',
|
||||
}
|
||||
: {}),
|
||||
}
|
||||
: {},
|
||||
sidebarOpen: true,
|
||||
auth: {
|
||||
@@ -204,7 +232,17 @@ function makePage(url) {
|
||||
canManageProject: params.has('admin'),
|
||||
status: params.has('saved') ? 'Ticket updated.' : null,
|
||||
users: [user, ticket.author],
|
||||
ticketTypes: [data.ticket_type],
|
||||
ticketTypes: params.has('noMetadata') ? [] : [data.ticket_type],
|
||||
source: params.get('source') === 'board' ? 'board' : 'backlog',
|
||||
defaultTicketStatusId: 3,
|
||||
ticketStatusOptions: [
|
||||
{
|
||||
id: 3,
|
||||
name: 'In progress',
|
||||
board_column: { name: 'Delivery' },
|
||||
},
|
||||
{ id: 4, name: 'Backlog', board_column: null },
|
||||
],
|
||||
ticketPriorities: [data.ticket_priority],
|
||||
ticketFieldDefinitions: params.has('empty') ? [] : fieldDefinitions,
|
||||
parentTicketOptions: [parent],
|
||||
@@ -282,6 +320,11 @@ if (serve) {
|
||||
const data = JSON.parse(body);
|
||||
const previous = new URL(request.headers.referer);
|
||||
const params = previous.searchParams;
|
||||
if (params.has('serverError')) {
|
||||
response.writeHead(503);
|
||||
response.end('Simulated failure');
|
||||
return;
|
||||
}
|
||||
if (!request.headers['x-inertia']) {
|
||||
assert.equal(request.method, 'PATCH');
|
||||
assert.equal(request.url, '/projects/7/tickets/42');
|
||||
@@ -311,18 +354,19 @@ if (serve) {
|
||||
);
|
||||
} else {
|
||||
assert.ok(
|
||||
'field_values' in data &&
|
||||
(request.method === 'POST' || 'field_values' in data) &&
|
||||
'acceptance_criteria' in data &&
|
||||
'parent_ticket_id' in data,
|
||||
);
|
||||
if (params.has('reject')) {
|
||||
params.set('rejected', '1');
|
||||
} else {
|
||||
savedForm = data;
|
||||
params.set('saved', data.title);
|
||||
}
|
||||
}
|
||||
response.writeHead(303, {
|
||||
Location: `/projects/7/tickets/42?${params}`,
|
||||
Location: `${params.has('rejected') && previous.pathname.endsWith('/create') ? previous.pathname : '/projects/7/tickets/42'}?${params}`,
|
||||
});
|
||||
response.end();
|
||||
return;
|
||||
@@ -364,10 +408,15 @@ if (serve) {
|
||||
const { default: Ticket } = await server.ssrLoadModule(
|
||||
'/resources/js/pages/projects/Ticket.vue',
|
||||
);
|
||||
const render = async (query = '') => {
|
||||
const { default: TicketCreate } = await server.ssrLoadModule(
|
||||
'/resources/js/pages/projects/TicketCreate.vue',
|
||||
);
|
||||
const render = async (query = '', creating = false) => {
|
||||
const result = await createInertiaApp({
|
||||
page: makePage(`/projects/7/tickets/42${query}`),
|
||||
resolve: () => Ticket,
|
||||
page: makePage(
|
||||
`/projects/7/tickets/${creating ? 'create' : '42'}${query}`,
|
||||
),
|
||||
resolve: () => (creating ? TicketCreate : Ticket),
|
||||
render: renderToString,
|
||||
setup: ({ App, props, plugin }) =>
|
||||
createSSRApp({ render: () => h(App, props) })
|
||||
@@ -473,6 +522,37 @@ if (serve) {
|
||||
await render('?gitError'),
|
||||
/Repository temporarily unavailable/,
|
||||
);
|
||||
const create = await render('?source=board', true);
|
||||
assert.match(create, /Create ticket/);
|
||||
assert.match(create, /Delivery \/ In progress/);
|
||||
assert.match(create, /Back to board/);
|
||||
assert.match(create, /id="ticket_status_id"/);
|
||||
assert.doesNotMatch(
|
||||
create,
|
||||
/id="author_user_id"|id="blocked_comment"|id="field-1"/,
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
await render('?hidePoints', true),
|
||||
/id="story_points"/,
|
||||
);
|
||||
const unavailable = await render('?noMetadata', true);
|
||||
assert.doesNotMatch(unavailable, /<form/);
|
||||
assert.match(unavailable, /Ticket creation needs at least one type/);
|
||||
for (const creating of [false, true]) {
|
||||
const invalid = await render('?rejected&allErrors', creating);
|
||||
for (const id of [
|
||||
'title',
|
||||
'description',
|
||||
'ticket_type_id',
|
||||
'ticket_priority_id',
|
||||
'assignee_user_id',
|
||||
'parent_ticket_id',
|
||||
'story_points',
|
||||
'acceptance_criteria_checklist',
|
||||
]) {
|
||||
assert.ok(invalid.includes(`id="${id}-error"`));
|
||||
}
|
||||
}
|
||||
console.log('Ticket detail behavior checks passed.');
|
||||
} finally {
|
||||
await server.close();
|
||||
|
||||
Reference in New Issue
Block a user