added more test coverage for client v2#50557
Conversation
There was a problem hiding this comment.
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
minimumReleaseAgeExcludeentry to unblock a specific@types/nodeversion.
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. |
| const clientId1 = faker.internet.username(); | ||
| const clientId2 = faker.internet.username(); | ||
|
|
||
| // Create two clients using v2 API |
There was a problem hiding this comment.
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:
currentClientIdbefore/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.
| 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); |
There was a problem hiding this comment.
@edewit seems valid that the test should be broadened to a non-default sort.
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>
There was a problem hiding this comment.
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
afterEachhook or afinallyblock.
await kcAdminClient.clients.v2().byId(clientId1).delete();
await kcAdminClient.clients.v2().byId(clientId2).delete();
relates: #50113
fixes: #50876
Signed-off-by: Erik Jan de Wit erikjan.dewit@gmail.com