Skip to content

added more test coverage for client v2#50557

Merged
shawkins merged 7 commits into
keycloak:mainfrom
edewit:expand-tests
Jul 21, 2026
Merged

added more test coverage for client v2#50557
shawkins merged 7 commits into
keycloak:mainfrom
edewit:expand-tests

Conversation

@edewit

@edewit edewit commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

relates: #50113
fixes: #50876

Signed-off-by: Erik Jan de Wit erikjan.dewit@gmail.com

@edewit
edewit requested a review from a team as a code owner July 2, 2026 10:14
Copilot AI review requested due to automatic review settings July 2, 2026 10:14
@edewit
edewit requested a review from a team as a code owner July 2, 2026 10:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends the JS Keycloak Admin Client (v2 endpoints generated from the OpenAPI spec) test suite to validate filtering and sorting behavior, improving confidence that the OpenAPI-driven client and server contract match.

Changes:

  • Adds a new Mocha test covering clients.v2().get() sorting (sort=clientId) and filtering (q=clientId eq ...).
  • Adjusts TypeScript test config to include Mocha/Node ambient types for test compilation/IDE support.
  • Adds a pnpm minimumReleaseAgeExclude entry to unblock a specific @types/node version.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

File Description
js/pnpm-workspace.yaml Adds a pnpm minimum-release-age exclusion for a specific @types/node version.
js/libs/keycloak-admin-client/tsconfig.test.json Adds Mocha/Node typings for the test TS project configuration.
js/libs/keycloak-admin-client/test/tsconfig.json Introduces a test-folder TS config extending the shared test config.
js/libs/keycloak-admin-client/test/clientsV2.spec.ts Adds v2 API coverage for client sorting and filtering.

Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts
Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts Outdated
Copilot AI review requested due to automatic review settings July 7, 2026 10:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • js/pnpm-lock.yaml: Generated file

Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts
Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts Outdated
Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts

@michalvavrik michalvavrik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR

Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts Outdated
Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts
Copilot AI review requested due to automatic review settings July 15, 2026 14:39
@edewit
edewit requested a review from michalvavrik July 15, 2026 14:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • js/pnpm-lock.yaml: Generated file

Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts
Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts

@michalvavrik michalvavrik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two more things (two comments) and LGTM. We could probably expand test coverage with adding a test for descending order, but I am only reviewing what I see and I found it useful and well done. Thanks

Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts
const clientId1 = faker.internet.username();
const clientId2 = faker.internet.username();

// Create two clients using v2 API

@michalvavrik michalvavrik Jul 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will know this better as I do, but AFAICT it is customary in this js/libs/keycloak-admin-client/test/clientsV2.spec.ts to delete clients you create. I am judging based on:

  • currentClientId before/after -> deleted
  • "should create and delete a client" deleted
  • "should create an OIDC client with full configuration" deleted

It is not too important, but maybe you should delete these clients as well? This seems to be only place that doesn't clean up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right

Copilot AI review requested due to automatic review settings July 16, 2026 06:59
@edewit
edewit requested a review from michalvavrik July 16, 2026 06:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • js/pnpm-lock.yaml: Generated file

Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts Outdated

@michalvavrik michalvavrik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

Copilot AI review requested due to automatic review settings July 16, 2026 14:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • js/pnpm-lock.yaml: Generated file

Comment on lines +130 to +139
sort: "clientId",
},
});
expect(sortedClients).to.be.ok;
expect(sortedClients).to.be.an("array");
const clientIds = sortedClients!.map((c) => c.clientId!);
const caseInsensitiveSortedClientIds = [...clientIds].sort((a, b) =>
a.localeCompare(b, undefined, { sensitivity: "base" }),
);
expect(caseInsensitiveSortedClientIds).to.deep.equal(clientIds);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edewit seems valid that the test should be broadened to a non-default sort.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, right... done

Copilot AI review requested due to automatic review settings July 16, 2026 21:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts Outdated
Copilot AI review requested due to automatic review settings July 17, 2026 07:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • js/pnpm-lock.yaml: Generated file

Comment thread js/libs/keycloak-admin-client/test/clientsV2.spec.ts Outdated
Copilot AI review requested due to automatic review settings July 17, 2026 08:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

edewit added 7 commits July 20, 2026 14:03
relates: keycloak#50113
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Copilot AI review requested due to automatic review settings July 20, 2026 12:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

js/libs/keycloak-admin-client/test/clientsV2.spec.ts:160

  • These deletions run only after all assertions pass, so a sort/filter regression—or failure while creating the second client—leaves test clients in the shared realm and can pollute later list results. Track each successful creation and delete it from an afterEach hook or a finally block.
    await kcAdminClient.clients.v2().byId(clientId1).delete();
    await kcAdminClient.clients.v2().byId(clientId2).delete();

@vmuzikar
vmuzikar requested a review from shawkins July 21, 2026 13:17

@shawkins shawkins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @edewit

@shawkins
shawkins merged commit 7a9b036 into keycloak:main Jul 21, 2026
69 checks passed
@edewit
edewit deleted the expand-tests branch July 23, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update admin client tests to use sort and filter

5 participants