fix(KAN-14): preserve template inheritance and project data
This commit is contained in:
@@ -46,6 +46,7 @@ try {
|
||||
'/project-templates?reset',
|
||||
'/projects/1/templates/create?reset',
|
||||
'/project-templates/2/edit?reset',
|
||||
'/project-templates/create?reset',
|
||||
]) {
|
||||
await visit(path);
|
||||
await noOverflow();
|
||||
@@ -73,6 +74,7 @@ try {
|
||||
});
|
||||
}
|
||||
}
|
||||
await visit('/project-templates/2/edit?reset');
|
||||
assert.equal(await page.locator('#slug').isDisabled(), true);
|
||||
assert.equal(
|
||||
await button('Save template changes').isDisabled(),
|
||||
@@ -193,6 +195,14 @@ try {
|
||||
name: 'Updated foundation',
|
||||
copy_areas: ['project_settings', 'ticket_types'],
|
||||
confirm_linked_projects_update: true,
|
||||
configuration_snapshot: await page.evaluate(
|
||||
() =>
|
||||
JSON.parse(
|
||||
document
|
||||
.querySelector('[data-page]')
|
||||
.getAttribute('data-page'),
|
||||
).props.template.configuration_snapshot,
|
||||
),
|
||||
});
|
||||
await page
|
||||
.getByRole('heading', { name: 'Project templates', exact: true })
|
||||
@@ -207,15 +217,92 @@ try {
|
||||
assert.deepEqual((await unlinked).postDataJSON(), {
|
||||
name: 'Foundation',
|
||||
copy_areas: ['project_settings', 'ticket_types'],
|
||||
configuration_snapshot: await page.evaluate(
|
||||
() =>
|
||||
JSON.parse(
|
||||
document
|
||||
.querySelector('[data-page]')
|
||||
.getAttribute('data-page'),
|
||||
).props.template.configuration_snapshot,
|
||||
),
|
||||
});
|
||||
await page
|
||||
.getByRole('heading', { name: 'Project templates', exact: true })
|
||||
.waitFor();
|
||||
await visit('/project-templates/2/edit?reset&missing');
|
||||
await visit('/project-templates/2/edit?reset&missing&unlinked');
|
||||
assert.equal(
|
||||
await page
|
||||
.getByText('This template cannot be refreshed', { exact: true })
|
||||
.count(),
|
||||
0,
|
||||
);
|
||||
assert.equal(await button('Save template changes').isEnabled(), true);
|
||||
await button('Save template changes').click();
|
||||
await page
|
||||
.getByText('This template cannot be refreshed', { exact: true })
|
||||
.getByRole('heading', { name: 'Project templates', exact: true })
|
||||
.waitFor();
|
||||
|
||||
await visit('/project-templates/create?reset');
|
||||
await page.locator('#name').fill('New independent template');
|
||||
await page.locator('#slug').fill('independent-template');
|
||||
const columns = page
|
||||
.locator('details')
|
||||
.filter({ has: page.locator('summary', { hasText: 'Board columns' }) });
|
||||
await columns
|
||||
.getByRole('button', { name: 'Add entry', exact: true })
|
||||
.click();
|
||||
await columns.getByLabel('Name', { exact: true }).fill('Todo');
|
||||
const statuses = page.locator('details').filter({
|
||||
has: page.locator('summary', { hasText: 'Ticket statuses' }),
|
||||
});
|
||||
await statuses
|
||||
.getByRole('button', { name: 'Add entry', exact: true })
|
||||
.click();
|
||||
await statuses.getByLabel('Name', { exact: true }).last().fill('Review');
|
||||
await statuses
|
||||
.getByLabel('Board column', { exact: true })
|
||||
.last()
|
||||
.selectOption({ label: 'Todo' });
|
||||
const types = page
|
||||
.locator('details')
|
||||
.filter({ has: page.locator('summary', { hasText: 'Ticket types' }) });
|
||||
await types
|
||||
.getByRole('button', { name: 'Move down', exact: true })
|
||||
.first()
|
||||
.click();
|
||||
const standaloneCreated = page.waitForRequest(
|
||||
(request) => request.method() === 'POST',
|
||||
);
|
||||
await button('Save new template').click();
|
||||
const body = (await standaloneCreated).postDataJSON();
|
||||
assert.equal(
|
||||
new URL((await standaloneCreated).url()).pathname,
|
||||
'/project-templates',
|
||||
);
|
||||
assert.equal(body.configuration_snapshot.ticket_statuses[1].name, 'Review');
|
||||
assert.equal(
|
||||
body.configuration_snapshot.ticket_statuses[1].board_column_key,
|
||||
body.configuration_snapshot.board_columns[0].configuration_key,
|
||||
);
|
||||
assert.deepEqual(
|
||||
body.configuration_snapshot.ticket_types.map((item) => item.name),
|
||||
['Release', 'Task'],
|
||||
);
|
||||
assert.deepEqual(
|
||||
body.configuration_snapshot.ticket_types.map((item) => item.position),
|
||||
[1, 2],
|
||||
);
|
||||
assert.equal(
|
||||
new Set(
|
||||
body.configuration_snapshot.ticket_types.map(
|
||||
(item) => item.configuration_key,
|
||||
),
|
||||
).size,
|
||||
2,
|
||||
);
|
||||
await page
|
||||
.getByRole('heading', { name: 'Project templates', exact: true })
|
||||
.waitFor();
|
||||
assert.equal(await button('Save template changes').isDisabled(), true);
|
||||
|
||||
await visit('/projects/1/templates/create?reset');
|
||||
await page.locator('#name').fill('Unsaved work');
|
||||
|
||||
Reference in New Issue
Block a user