1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-14 14:42:26 +00:00

feat: display groups on the account page (#296)

Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
Kyle Mendell
2025-03-06 15:25:03 -06:00
committed by GitHub
parent 37b24bed91
commit 0f14a93e1d
14 changed files with 223 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
import test, { expect } from '@playwright/test';
import { users } from './data';
import { users, userGroups } from './data';
import { cleanupBackend } from './utils/cleanup.util';
test.beforeEach(cleanupBackend);
@@ -142,7 +142,7 @@ test('Update user fails with already taken username', async ({ page }) => {
test('Update user custom claims', async ({ page }) => {
await page.goto(`/settings/admin/users/${users.craig.id}`);
await page.getByRole('button', { name: 'Expand card' }).click();
await page.getByRole('button', { name: 'Expand card' }).nth(1).click();
// Add two custom claims
await page.getByRole('button', { name: 'Add custom claim' }).click();
@@ -178,3 +178,63 @@ test('Update user custom claims', async ({ page }) => {
await expect(page.getByPlaceholder('Key').first()).toHaveValue('customClaim2');
await expect(page.getByPlaceholder('Value').first()).toHaveValue('customClaim2_value');
});
test('Update user group assignments', async ({ page }) => {
const user = users.craig;
await page.goto(`/settings/admin/users/${user.id}`);
// Increase the test timeout since this test is complex
test.setTimeout(30000);
// Expand the user groups section if it's collapsed
const expandButton = page.getByRole('button', { name: 'Expand card' }).first();
if (await expandButton.isVisible()) {
await expandButton.click();
}
// Wait for the user groups table to load
await page.waitForSelector('table');
// First, ensure we start with a clean state - uncheck any checked boxes
const developersCheckbox = page
.getByRole('row', { name: userGroups.developers.name })
.getByRole('checkbox');
const designersCheckbox = page
.getByRole('row', { name: userGroups.designers.name })
.getByRole('checkbox');
// Force click if needed to overcome element interception issues
if ((await developersCheckbox.getAttribute('data-state')) === 'checked') {
await developersCheckbox.click({ force: true });
}
if ((await designersCheckbox.getAttribute('data-state')) === 'checked') {
await designersCheckbox.click({ force: true });
}
// Save the changes to reset state if needed
await page.getByRole('button', { name: 'Save' }).nth(1).click();
// Wait for toast message to appear and disappear
await expect(page.getByRole('status')).toHaveText('User groups updated successfully');
await page.waitForTimeout(1000); // Wait for any animations or state changes
// Now add both groups (using force: true to avoid interception problems)
await developersCheckbox.click({ force: true });
await designersCheckbox.click({ force: true });
// Save the changes
await page.getByRole('button', { name: 'Save' }).nth(1).click();
// Verify success message
await expect(page.getByRole('status')).toHaveText('User groups updated successfully');
await page.reload();
await expect(
page.getByRole('row', { name: userGroups.developers.name }).getByRole('checkbox')
).toHaveAttribute('data-state', 'checked', { timeout: 10000 });
await expect(
page.getByRole('row', { name: userGroups.designers.name }).getByRole('checkbox')
).toHaveAttribute('data-state', 'checked', { timeout: 10000 });
});