Skip to content

Commit

Permalink
delete-user uc
Browse files Browse the repository at this point in the history
  • Loading branch information
clauyan committed Nov 1, 2024
1 parent 7a4b32c commit 15cf95c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
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,
postPersonenkontextWorkflow,
} 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";
Expand All @@ -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) => {
Expand Down Expand Up @@ -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);
});
}

Expand Down
9 changes: 6 additions & 3 deletions loadtest/util/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { check, fail } from "k6";

import {
get,
patch,
Expand All @@ -21,7 +22,6 @@ import {
PersonendatensatzResponse,
PersonenkontextWorkflowResponse,
PersonFrontendControllerFindPersons200Response,
PersonLockResponse,
ServiceProviderResponse,
TokenRequiredResponse,
TokenStateResponse,
Expand All @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion loadtest/util/resource-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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-"]);
Expand Down

0 comments on commit 15cf95c

Please sign in to comment.