Add account console group test

Fixes: #21250

Signed-off-by: Hynek Mlnarik <hmlnarik@redhat.com>
This commit is contained in:
Hynek Mlnarik 2024-02-09 12:26:31 +01:00 committed by Hynek Mlnařík
parent 83f3e91e4f
commit 18ad2c8b30
3 changed files with 35 additions and 2 deletions

View file

@ -24,7 +24,7 @@ export const Groups = () => {
usePromise(
(signal) => getGroups({ signal, context }),
(groups) => {
if (directMembership) {
if (!directMembership) {
groups.forEach((el) =>
getParents(
el,
@ -66,6 +66,7 @@ export const Groups = () => {
<Checkbox
label={t("directMembership")}
id="directMembership-checkbox"
data-testid="directMembership-checkbox"
isChecked={directMembership}
onChange={(checked) => setDirectMembership(checked)}
/>

View file

@ -5,6 +5,35 @@ test.describe("Groups page", () => {
test("List my groups", async ({ page }) => {
await login(page, "jdoe", "jdoe", "groups");
await page.getByTestId("groups").click();
await expect(page.getByTestId("group[0].name")).toHaveText("one");
await expect(page.getByTestId("group[1].name")).toHaveText("three");
});
test("List my direct and indirect groups", async ({ page }) => {
await login(page, "alice", "alice", "groups");
await page.getByTestId("groups").click();
await expect(
page.getByTestId("directMembership-checkbox"),
).not.toBeChecked();
await expect(page.getByTestId("group[3].name")).toHaveText("one");
await expect(
page.locator("#groups-list li").filter({ hasText: /\/\S+$/ }),
).toHaveCount(4);
await page.getByTestId("directMembership-checkbox").click();
await expect(page.getByTestId("directMembership-checkbox")).toBeChecked();
await expect(
page.locator("#groups-list li").filter({ hasText: /\/\S+$/ }),
).toHaveCount(3);
await expect(page.getByTestId("group[2].name")).toHaveText("subgroup");
await page.getByTestId("directMembership-checkbox").click();
await expect(
page.getByTestId("directMembership-checkbox"),
).not.toBeChecked();
await expect(page.getByTestId("group[3].name")).toHaveText("one");
await expect(
page.locator("#groups-list li").filter({ hasText: /\/\S+$/ }),
).toHaveCount(4);
});
});

View file

@ -30,6 +30,9 @@
},
{
"username": "alice",
"firstName": "Alice",
"lastName": "Alison",
"email": "alice@keycloak.org",
"enabled": true,
"realmRoles": [],
"clientRoles": {