feat(KAN-41): edit allowed status transitions
This commit is contained in:
@@ -35,6 +35,7 @@ function initial() {
|
||||
const ready = makeStatus(2, 'Ready', 10);
|
||||
const active = makeStatus(3, 'Building', 20);
|
||||
const review = makeStatus(4, 'Review', 20, 2);
|
||||
backlog.allowed_target_statuses = [ready];
|
||||
const columns = [
|
||||
{ id: 10, name: 'Todo', position: 1, ticket_statuses: [ready] },
|
||||
{
|
||||
@@ -134,13 +135,17 @@ if (serve) {
|
||||
return;
|
||||
}
|
||||
if (result === 'validation') {
|
||||
errors =
|
||||
request.method === 'DELETE'
|
||||
? {
|
||||
ticket_status_id:
|
||||
'This group needs at least one status.',
|
||||
}
|
||||
: { name: 'Choose a different name.' };
|
||||
errors = url.pathname.endsWith('/transitions')
|
||||
? {
|
||||
'allowed_ticket_status_ids.0':
|
||||
'Choose a destination from this project.',
|
||||
}
|
||||
: request.method === 'DELETE'
|
||||
? {
|
||||
ticket_status_id:
|
||||
'This group needs at least one status.',
|
||||
}
|
||||
: { name: 'Choose a different name.' };
|
||||
} else if (result === 'position') {
|
||||
errors = { position: 'The position must be at least 1.' };
|
||||
} else {
|
||||
@@ -188,7 +193,16 @@ if (serve) {
|
||||
column.position = index + 1;
|
||||
});
|
||||
} else if (url.pathname.endsWith('/transitions')) {
|
||||
// The browser assertion checks the preserved transition endpoint and payload.
|
||||
const sourceId = Number(segments.at(-2));
|
||||
const statuses = [
|
||||
...data.backlogTicketStatuses,
|
||||
...columns.flatMap((column) => column.ticket_statuses),
|
||||
];
|
||||
statuses.find(
|
||||
(status) => status.id === sourceId,
|
||||
).allowed_target_statuses = (
|
||||
submitted.allowed_ticket_status_ids ?? []
|
||||
).map((id) => ({ id: Number(id) }));
|
||||
} else if (request.method === 'POST') {
|
||||
const group =
|
||||
submitted.board_column_id === null
|
||||
@@ -294,6 +308,16 @@ if (serve) {
|
||||
html.indexOf('data-column-id="10"') <
|
||||
html.indexOf('data-column-id="20"'),
|
||||
);
|
||||
assert.match(html, /From status/);
|
||||
assert.match(html, /Saved destinations: 1/);
|
||||
assert.match(
|
||||
await render({ ticketStatuses: [] }),
|
||||
/Add a status to configure/,
|
||||
);
|
||||
assert.match(
|
||||
await render({ ticketStatuses: [makeStatus(1, 'Backlog', null)] }),
|
||||
/No other statuses exist yet/,
|
||||
);
|
||||
const buttons = html.match(/<button\b[^>]*>[\s\S]*?<\/button>/g);
|
||||
for (const name of ['Backlog', 'Ready']) {
|
||||
assert.match(
|
||||
|
||||
Reference in New Issue
Block a user