fix(KAN-14): preserve template inheritance and project data
This commit is contained in:
@@ -43,10 +43,54 @@ const template = {
|
||||
is_published: true,
|
||||
source_project: project,
|
||||
copy_areas: ['project_settings', 'ticket_types'],
|
||||
configuration_snapshot: {
|
||||
project_settings: { show_author: true, show_story_points: true },
|
||||
board_columns: [],
|
||||
ticket_statuses: [
|
||||
{
|
||||
configuration_key: '10000000-0000-4000-8000-000000000001',
|
||||
name: 'Backlog',
|
||||
position: 1,
|
||||
board_column_key: null,
|
||||
},
|
||||
],
|
||||
status_transitions: [
|
||||
{
|
||||
status_key: '10000000-0000-4000-8000-000000000001',
|
||||
target_keys: [],
|
||||
},
|
||||
],
|
||||
ticket_types: [
|
||||
{
|
||||
configuration_key: '20000000-0000-4000-8000-000000000001',
|
||||
name: 'Task',
|
||||
position: 1,
|
||||
is_parent: false,
|
||||
},
|
||||
{
|
||||
configuration_key: '20000000-0000-4000-8000-000000000002',
|
||||
name: 'Release',
|
||||
position: 2,
|
||||
is_parent: true,
|
||||
},
|
||||
],
|
||||
ticket_priorities: [
|
||||
{
|
||||
configuration_key: '30000000-0000-4000-8000-000000000001',
|
||||
name: 'Medium',
|
||||
position: 1,
|
||||
},
|
||||
],
|
||||
ticket_fields: [],
|
||||
ticket_link_types: [],
|
||||
repository_connections: [],
|
||||
notification_actions: [],
|
||||
},
|
||||
linked_project_count: 2,
|
||||
};
|
||||
const initial = () => ({
|
||||
project,
|
||||
initialConfiguration: structuredClone(template.configuration_snapshot),
|
||||
copyAreaOptions: areas.map((value) => ({
|
||||
value,
|
||||
label: value,
|
||||
@@ -100,7 +144,8 @@ if (serve) {
|
||||
const url = new URL(request.url, 'http://localhost');
|
||||
let component = url.pathname.endsWith('/edit')
|
||||
? 'Edit'
|
||||
: url.pathname.includes('/templates/create')
|
||||
: url.pathname.includes('/templates/create') ||
|
||||
url.pathname === '/project-templates/create'
|
||||
? 'Create'
|
||||
: url.pathname === '/project-templates'
|
||||
? 'Index'
|
||||
@@ -117,6 +162,9 @@ if (serve) {
|
||||
if (url.searchParams.has('empty')) {
|
||||
data.templates = [];
|
||||
}
|
||||
if (url.pathname === '/project-templates/create') {
|
||||
data.project = null;
|
||||
}
|
||||
let errors = {};
|
||||
if (request.method !== 'GET') {
|
||||
let body = '';
|
||||
@@ -259,12 +307,30 @@ if (serve) {
|
||||
unlinked.match(/<button[^>]*type="submit"[^>]*>/)?.[0] ?? '',
|
||||
/ disabled(?:[ =>])/,
|
||||
);
|
||||
assert.match(
|
||||
await render('Edit', {
|
||||
template: { ...template, source_project: null },
|
||||
}),
|
||||
/This template cannot be refreshed/,
|
||||
const independent = await render('Edit', {
|
||||
template: {
|
||||
...template,
|
||||
source_project: null,
|
||||
linked_project_count: 0,
|
||||
},
|
||||
});
|
||||
assert.match(independent, /Template configuration/);
|
||||
assert.doesNotMatch(independent, /This template cannot be refreshed/);
|
||||
assert.doesNotMatch(
|
||||
independent.match(/<button[^>]*type="submit"[^>]*>/)?.[0] ?? '',
|
||||
/ disabled(?:[ =>])/,
|
||||
);
|
||||
const empty = await render('Create', {
|
||||
project: null,
|
||||
template: undefined,
|
||||
});
|
||||
assert.match(empty, /New empty template/);
|
||||
assert.match(
|
||||
empty.match(/<input[^>]*id="name"[^>]*>/)?.[0] ?? '',
|
||||
/\bvalue(?:="")?(?:\s|>)/,
|
||||
);
|
||||
assert.match(empty, /Template configuration/);
|
||||
assert.match(list, /href="\/project-templates\/create"/);
|
||||
assert.match(
|
||||
await render(
|
||||
'Index',
|
||||
|
||||
Reference in New Issue
Block a user