8000 Fix duplicated resource on current and next page in Auth Resources by andreqrochaa · Pull Request #47446 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/apps/admin-ui/src/clients/authorization/Resources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export const AuthorizationResources = ({
)}
</Tr>
</Thead>
{resources.map((resource, rowIndex) => (
{resources.slice(0, max).map((resource, rowIndex) => (
<Tbody key={resource._id} isExpanded={resource.isExpanded}>
<Tr>
<Td
Expand Down
49 changes: 48 additions & 1 deletion js/apps/admin-ui/test/clients/authorization.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from "@playwright/test";
import { test, expect } from "@playwright/test";
import adminClient from "../utils/AdminClient.ts";
import { clickSaveButton } from "../utils/form.ts";
import { login } from "../utils/login.ts";
Expand Down Expand Up @@ -260,3 +260,50 @@ test.describe.serial("Accessibility tests for client authorization", () => {
await assertAxeViolations(page);
});
});

test.describe.serial("Client authorization resources pagination", () => {
const clientId = `client-authz-pagination-${crypto.randomUUID()}`;

test.beforeAll(async () => {
await adminClient.createClient({
protocol: "openid-connect",
clientId,
publicClient: false,
authorizationServicesEnabled: true,
serviceAccountsEnabled: true,
standardFlowEnabled: true,
});

for (let i = 1; i <= 11; i++) {
await adminClient.createResource(clientId, {
name: `Resource-${i.toString().padStart(2, "0")}`,
displayName: `Display Resource ${i}`,
type: "urn:pagination:test",
});
}
});

test.afterAll(async () => {
await adminClient.deleteClient(clientId);
});

test.beforeEach(async ({ page }) => {
await login(page);
await goToClients(page);
await searchItem(page, "Search for client", clientId);
await clickTableRowItem(page, clientId);
await goToAuthorizationTab(page);
await goToResourcesSubTab(page);
});

test("Should not duplicate the 10th item on the 2nd page", async ({
page,
}) => {
await page.waitForSelector("table");
await expect(page.getByText("Resource-10", { exact: true })).toBeVisible();
await expect(page.getByText("Resource-11", { exact: true })).toBeHidden();
await page.locator('[aria-label="Go to next page"]').first().click();
await expect(page.getByText("Resource-11", { exact: true })).toBeVisible();
await expect(page.getByText("Resource-10", { exact: true })).toBeHidden();
});
});
Loading
0