From 15cf95c00c53b355f3385cdbe69ea1976bb06bd7 Mon Sep 17 00:00:00 2001 From: Yannick Clausen <yannick.clausen@capgemini.com> Date: Fri, 1 Nov 2024 16:27:05 +0100 Subject: [PATCH] delete-user uc --- ...-new-user.ts => 2_create-delete-new-user.ts} | 17 +++++++++++++++-- loadtest/util/api.ts | 9 ++++++--- loadtest/util/resource-helper.ts | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) rename loadtest/usecases/{2_create-new-user.ts => 2_create-delete-new-user.ts} (84%) diff --git a/loadtest/usecases/2_create-new-user.ts b/loadtest/usecases/2_create-delete-new-user.ts similarity index 84% rename from loadtest/usecases/2_create-new-user.ts rename to loadtest/usecases/2_create-delete-new-user.ts index 2eba9b7..bf535f6 100644 --- a/loadtest/usecases/2_create-new-user.ts +++ b/loadtest/usecases/2_create-delete-new-user.ts @@ -1,6 +1,9 @@ import { group, sleep } from "k6"; import { logout } from "../pages/index.ts"; +import { UserDetailsPage } from "../pages/user-details.ts"; +import { userListPage } from "../pages/user-list.ts"; import { + deletePersonById, getAdministeredOrganisationenById, getLoginInfo, getPersonenkontextWorkflowStep, @@ -8,6 +11,7 @@ import { } from "../util/api.ts"; import { getDefaultOptions } from "../util/config.ts"; import { getRandomName, pickRandomItem } from "../util/data.ts"; +import { prettyLog } from "../util/debug.ts"; import { goToUserList, login } from "../util/page.ts"; import { deleteAllTestUsers } from "../util/resource-helper.ts"; import { wrapTestFunction } from "../util/usecase-wrapper.ts"; @@ -33,7 +37,7 @@ function main(users = getDefaultAdminMix()) { getLoginInfo(); }); - group("go through workflow", () => { + const createdPerson = group("go through creation workflow", () => { const { organisations } = getPersonenkontextWorkflowStep(["limit=25"]); const organisation = pickRandomItem(organisations); typeIntoAutocomplete(organisation.name, (name) => { @@ -88,7 +92,16 @@ function main(users = getDefaultAdminMix()) { } else { body.personalnummer = "1237562"; } - postPersonenkontextWorkflow(body); + return postPersonenkontextWorkflow(body); + }); + + group("navigate back", () => { + userListPage.navigate(); + new UserDetailsPage(createdPerson.person.id).navigate(); + }); + + group("go through deletion workflow", () => { + deletePersonById(createdPerson.person.id); }); } diff --git a/loadtest/util/api.ts b/loadtest/util/api.ts index 60a9700..24c9702 100644 --- a/loadtest/util/api.ts +++ b/loadtest/util/api.ts @@ -1,4 +1,5 @@ import { check, fail } from "k6"; + import { get, patch, @@ -21,7 +22,6 @@ import { PersonendatensatzResponse, PersonenkontextWorkflowResponse, PersonFrontendControllerFindPersons200Response, - PersonLockResponse, ServiceProviderResponse, TokenRequiredResponse, TokenStateResponse, @@ -38,7 +38,7 @@ import { prettyLog } from "./debug.ts"; const backendUrl = getBackendUrl(); export function makeQueryString(pairs: Array<string>): string { - return "?".concat(pairs.map((p) => p.replace(" ", "%20")).join("&")); + return "?".concat(pairs.map((p) => p.replaceAll(" ", "%20")).join("&")); } /** * Removes querystring from url. Returns unchanged string, if no query is present @@ -177,7 +177,10 @@ export function getPersonById(id: string, query?: Array<string>) { export function deletePersonById(id: string) { const response = makeHttpRequest("delete", `personen/${id}`); - check(response, defaultHttpCheck); + check(response, { + "got expected status": getStatusChecker(204), + ...defaultTimingCheck, + }); return response; } diff --git a/loadtest/util/resource-helper.ts b/loadtest/util/resource-helper.ts index b559a85..1c30448 100644 --- a/loadtest/util/resource-helper.ts +++ b/loadtest/util/resource-helper.ts @@ -116,7 +116,7 @@ export function deleteTestUsers(ids: Array<string>) { export function deleteAllTestUsers() { let users = getPersonen(["offset=0", "limit=100", "suchFilter=PLT-"]); - console.log("deleting test users"); + console.log(`deleting ${users.total} test users`); while (users.total) { deleteTestUsers(users.items.map((p) => p.person.id)); users = getPersonen(["offset=0", "limit=100", "suchFilter=PLT-"]);