Add specs for group update operation

This commit is contained in:
Manuel Bustillo 2025-06-17 20:35:50 +02:00
parent 536f74cd7a
commit 1b957879d4
2 changed files with 48 additions and 13 deletions

View File

@ -62,4 +62,13 @@ test('should allow CRUD on groups', async ({ page }) => {
await expect(page.getByRole('row').nth(1).getByRole('cell').nth(6)).toHaveText('0'); await expect(page.getByRole('row').nth(1).getByRole('cell').nth(6)).toHaveText('0');
await expect(page.getByRole('row').nth(1).getByRole('cell').nth(7)).toHaveText('0'); await expect(page.getByRole('row').nth(1).getByRole('cell').nth(7)).toHaveText('0');
await expect(page.getByRole('row').nth(1).locator('svg:visible')).toHaveCount(3); await expect(page.getByRole('row').nth(1).locator('svg:visible')).toHaveCount(3);
// Modify the newly added group
await page.getByRole('row').nth(1).locator('svg').nth(2).click(); // Click edit icon
await expect(dialog).toBeVisible();
await expect(dialog.getByLabel('Name')).toHaveValue("Pam's friends");
await dialog.getByLabel('Name').fill('Pam\'s best friends');
await dialog.getByRole('button', { name: 'Update' }).click();
await expect(page.getByRole('row').nth(1).getByRole('cell').nth(0)).toContainText('Pam\'s best friends');
}); });

View File

@ -39,22 +39,48 @@ export default async function mockGroupsAPI({ page }: { page: Page }): Promise<v
await route.fulfill({ json }) await route.fulfill({ json })
} else if (route.request().method() === 'POST') { } else if (route.request().method() === 'POST') {
const json = { const json = {
"id": "4d55bc34-6f42-4e2e-82a1-71ae32da2466", "id": "4d55bc34-6f42-4e2e-82a1-71ae32da2466",
"name": "Pam's friends", "name": "Pam's friends",
"icon": "pi pi-desktop", "icon": "pi pi-desktop",
"parent_id": null, "parent_id": null,
"color": "#0000ff", "color": "#0000ff",
"attendance": { "attendance": {
"total": 0, "total": 0,
"considered": 0, "considered": 0,
"invited": 0, "invited": 0,
"confirmed": 0, "confirmed": 0,
"declined": 0, "declined": 0,
"tentative": 0 "tentative": 0
}
} }
}
await route.fulfill({ json }) await route.fulfill({ json })
} }
}) })
page.route("*/**/api/default/groups/*", async route => {
if (route.request().method() === 'PUT') {
const json = {
"id": "4d55bc34-6f42-4e2e-82a1-71ae32da2466",
"name": "Pam's best friends",
"icon": "pi pi-desktop",
"parent_id": null,
"color": "#0000ff",
"attendance": {
"total": 0,
"considered": 0,
"invited": 0,
"confirmed": 0,
"declined": 0,
"tentative": 0
}
}
await route.fulfill({ json });
} else if (route.request().method() === 'DELETE') {
const json = {}
await route.fulfill({ json });
}
});
} }