Add specs when group is deleted (+ add confirmation dialog)
All checks were successful
Check usage of free licenses / build-static-assets (pull_request) Successful in 1m9s
Add copyright notice / copyright_notice (pull_request) Successful in 1m33s
Build Nginx-based docker image / build-static-assets (push) Successful in 3m29s
Playwright Tests / test (pull_request) Successful in 4m40s

This commit is contained in:
Manuel Bustillo 2025-06-17 20:39:40 +02:00
parent 1b957879d4
commit bcc86f2c3b
2 changed files with 14 additions and 1 deletions

View File

@ -21,7 +21,12 @@ export default function GroupsTable({ groups, onUpdate, onEdit, onEditAffinities
const actions = (group: Group) => (
<div className="flex flex-row items-center">
<TrashIcon className='size-6 cursor-pointer' onClick={() => { api.destroy(serializer, group, onUpdate) }} />
<TrashIcon className='size-6 cursor-pointer' onClick={() => {
if (window.confirm(`Are you sure you want to delete guest "${group.name}"?`)) {
api.destroy(serializer, group, onUpdate)
}
}}
/>
<PencilIcon className='size-6 cursor-pointer' onClick={() => onEdit(group)} />
<AdjustmentsHorizontalIcon className='size-6 cursor-pointer' onClick={() => onEditAffinities(group)} />
</div>

View File

@ -52,6 +52,8 @@ test('should allow CRUD on groups', async ({ page }) => {
await dialog.getByLabel('Name').fill("Pam's friends");
await dialog.getByRole('button', { name: 'Create' }).click();
await expect(page.getByRole('row')).toHaveCount(4); // 1 header row + 3 data rows
await expect(dialog).not.toBeVisible();
await expect(page.getByRole('row').nth(1).getByRole('cell').nth(0)).toContainText('Pam\'s friends');
@ -71,4 +73,10 @@ test('should allow CRUD on groups', async ({ page }) => {
await dialog.getByRole('button', { name: 'Update' }).click();
await expect(page.getByRole('row').nth(1).getByRole('cell').nth(0)).toContainText('Pam\'s best friends');
// Delete the newly added group
page.on('dialog', dialog => dialog.accept());
await page.getByRole('row').nth(1).locator('svg').nth(1).click(); // Click delete icon
await expect(page.getByRole('row')).toHaveCount(3); // 1 header row + 2 data rows
});