Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
clauyan committed Nov 13, 2024
1 parent 863ded5 commit b3c4ea3
Show file tree
Hide file tree
Showing 15 changed files with 458 additions and 6 deletions.
34 changes: 34 additions & 0 deletions loadtest/pages/create-rolle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {
getAllProviders,
getLoginInfo,
getOrganisationen,
} from "../util/api.ts";
import { getFrontendUrl } from "../util/config.ts";
import { loadPage } from "../util/page.ts";
import { PageObject } from "./index.ts";

class CreateRollePage implements PageObject {
name = "UserList";
url = `${getFrontendUrl()}admin/rollen/new`;

navigate(): void {
loadPage(this.url, this.name);
this.fetchData();
}

// fetch on initial load
fetchData() {
getLoginInfo();
const organisationen = getOrganisationen([
"systemrechte=ROLLEN_VERWALTEN",
"excludeTyp=KLASSE",
]);
const providers = getAllProviders();
return {
organisationen,
providers,
};
}
}

export const createRollePage = new CreateRollePage();
43 changes: 43 additions & 0 deletions loadtest/pages/edit-rolle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {
deleteRolleById,
getAllProviders,
getLoginInfo,
getOrganisationById,
getRolleById,
} from "../util/api.ts";
import { getFrontendUrl } from "../util/config.ts";
import { loadPage } from "../util/page.ts";
import { PageObject } from "./index.ts";

export class EditRollePage implements PageObject {
name = "UserList";
url = `${getFrontendUrl()}admin/rollen/new`;

constructor(public rolleId: string) {}

navigate(): void {
loadPage(this.url, this.name);
this.fetchData();
}

// fetch on initial load
fetchData() {
getLoginInfo();
const rolle = getRolleById(this.rolleId);
const organisation = getOrganisationById(
rolle.administeredBySchulstrukturknoten,
);

const providers = getAllProviders();
return {
rolle,
organisation,
providers,
};
}

deleteRolle() {
deleteRolleById(this.rolleId);
// TODO: go to rolle list
}
}
5 changes: 5 additions & 0 deletions loadtest/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ export interface PageObject {
url: string;
navigate: () => void;
}

export function logout() {
// TODO: implement
//stub
}
7 changes: 6 additions & 1 deletion loadtest/pages/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class LoginPage implements PageObject {
response = this.submitForm(response, user);
response = this.complete(response);
if (response.status !== 200 && response.status !== 302) {
console.log("login failed");
fail("login failed");
}
});
Expand All @@ -49,8 +50,11 @@ class LoginPage implements PageObject {
!check(actionUrl, {
"action url found": (url) => url != undefined,
})
)
) {
console.log("action for #kc-form-login was not found");
console.log(response);
fail("action for #kc-form-login was not found");
}

const loginData = {
...user,
Expand All @@ -71,6 +75,7 @@ class LoginPage implements PageObject {
"login url found": (url) => url != undefined,
})
) {
console.log("did not find Location in kc response");
fail("did not find Location in kc response");
}
// this redirects to the start page
Expand Down
20 changes: 20 additions & 0 deletions loadtest/pages/profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { getFrontendUrl } from "../util/config.ts";
import { loadPage } from "../util/page.ts";
import { PageObject } from "./index.ts";

export class ProfilePage implements PageObject {
name = "UserList";
url = `${getFrontendUrl()}admin/personen`;

constructor(public personId: string) {}

navigate(): void {
loadPage(this.url, this.name);
this.fetchData();
}

fetchData() {
// TODO: implement
//stub
}
}
49 changes: 49 additions & 0 deletions loadtest/usecases/4_add-zuordnung.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { group } from "k6";
import { OrganisationResponse } from "../api-client/generated/index.ts";
import { getDefaultOptions } from "../util/config.ts";
import { login } from "../util/page";
import { wrapTestFunction } from "../util/usecase-wrapper.ts";
import { UserMix } from "../util/users.ts";

type TestData = {
testOrg: OrganisationResponse;
};

const loginData = new UserMix({ SYSADMIN: 1 }).getLogin();
export const options = {
...getDefaultOptions(),
};

export function setup() {}

export function teardown(data: TestData) {}

export default wrapTestFunction(main);

function main(data: TestData) {
group("setup", () => {
login(loginData);
// TODO: go to details page
});

group("add zuordnung", () => {
// TODO:
// https://localhost:8099/api/personenkontext-workflow/step?limit=25
// https://localhost:8099/api/personenkontext-workflow/step?limit=25
// https://localhost:8099/api/personenkontext-workflow/step?organisationId=99a2e34e-c0b7-4afe-9120-a7cbc3dac6b9&limit=25
// https://localhost:8099/api/organisationen/99a2e34e-c0b7-4afe-9120-a7cbc3dac6b9/administriert
// https://localhost:8099/api/organisationen?limit=30&typ=SCHULE&systemrechte=SCHULEN_VERWALTEN&organisationIds=99a2e34e-c0b7-4afe-9120-a7cbc3dac6b9
// https://localhost:8099/api/personenkontext-workflow/step?organisationId=99a2e34e-c0b7-4afe-9120-a7cbc3dac6b9&rolleId=c590a195-8416-44ad-9264-f6e6bd9f6744&limit=25
// https://localhost:8099/api/personenkontext-workflow/c4852e54-cd0b-45c2-96cf-2028153db08b
// {"lastModified":"2024-11-07T09:58:41.888Z","count":2,"personenkontexte":[{"personId":"c4852e54-cd0b-45c2-96cf-2028153db08b","organisationId":"d58ec217-42c8-4824-abae-13093eb29f40","rolleId":"c590a195-8416-44ad-9264-f6e6bd9f6744","befristung":null},{"personId":"c4852e54-cd0b-45c2-96cf-2028153db08b","organisationId":"99a2e34e-c0b7-4afe-9120-a7cbc3dac6b9","rolleId":"c590a195-8416-44ad-9264-f6e6bd9f6744"},{"personId":"c4852e54-cd0b-45c2-96cf-2028153db08b","organisationId":"9122528c-f67e-49b7-89e8-2669be7d39f9","rolleId":"c590a195-8416-44ad-9264-f6e6bd9f6744"},{"personId":"c4852e54-cd0b-45c2-96cf-2028153db08b","organisationId":"74567a50-d6d5-4a35-995f-72020b843c61","rolleId":"c590a195-8416-44ad-9264-f6e6bd9f6744","befristung":null}]}
// TODO: reload details page
});

group("delete zuordnung", () => {
// TODO:
// https://localhost:8099/api/personenkontext-workflow/step?limit=25
// https://localhost:8099/api/personenkontext-workflow/step?organisationId=d58ec217-42c8-4824-abae-13093eb29f40&rolleId=c590a195-8416-44ad-9264-f6e6bd9f6744&limit=25
// https://localhost:8099/api/personenkontext-workflow/c4852e54-cd0b-45c2-96cf-2028153db08b
// TODO: reload details page
});
}
58 changes: 58 additions & 0 deletions loadtest/usecases/4_create-delete-2fa-soft.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { check, group } from "k6";
import {
CreateRolleBodyParams,
OrganisationResponse,
RollenArt,
TokenInitBodyParams,
} from "../api-client/generated/index.ts";
import { getDefaultOptions } from "../util/config.ts";
import { goToUserList } from "../util/page.ts";
import { wrapTestFunction } from "../util/usecase-wrapper.ts";
import { getDefaultUserMix, UserMix } from "../util/users.ts";
import { createRollePage } from "../pages/create-rolle.ts";
import { getOrganisationById, getOrganisationen, postRolle } from "../util/api";
import { EditRollePage } from "../pages/edit-rolle";

type TestData = {
testOrg: OrganisationResponse;
};

export const options = {
...getDefaultOptions(),
};
const users = new UserMix({ SYSADMIN: 1000 });

export function setup() {
// TODO: get testOrg
// TODO: create test users
}

export function teardown(data: TestData) {
// TODO: delete test users in testOrg
}

export default wrapTestFunction(main);

function main(data: TestData) {
const personId = group("setup", () => {
goToUserList(users.getLogin());
// TODO: pick user
// TODO: go to details
});
const rolleId = group("create token", () => {
const bodyParams: TokenInitBodyParams = {
personId,
};
const rolleResponse = postRolle(bodyParams);
check(rolleResponse, {
"rolle created": (r) => r.id != undefined,
});
getOrganisationById(bodyParams.administeredBySchulstrukturknoten);
return rolleResponse.id;
});
group("delete rolle", () => {
const po = new EditRollePage(rolleId);
po.fetchData();
po.deleteRolle();
});
}
37 changes: 37 additions & 0 deletions loadtest/usecases/4_create-delete-klasse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { group } from "k6";
import { getDefaultOptions } from "../util/config.ts";
import { goToUserList } from "../util/page.ts";
import { wrapTestFunction } from "../util/usecase-wrapper.ts";
import { getDefaultUserMix } from "../util/users.ts";
import { OrganisationResponse } from "../api-client/generated/index.ts";

type TestData = {
testOrg: OrganisationResponse;
};

export const options = {
...getDefaultOptions(),
};
const users = getDefaultUserMix();

export function setup() {
// TODO: get testOrg
}

export function teardown(data: TestData) {
// TODO: delete klassen in testOrg
}

export default wrapTestFunction(main);

function main(data: TestData) {
group("setup", () => {
goToUserList(users.getLogin());
});
const klasseId = group("create klasse", () => {
// TODO: create klasse in testOrg
});
group("delete klasse", () => {
// TODO: delete klasse in testOrg
});
}
60 changes: 60 additions & 0 deletions loadtest/usecases/4_create-delete-role.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { check, group } from "k6";
import {
CreateRolleBodyParams,
OrganisationResponse,
RollenArt,
} from "../api-client/generated/index.ts";
import { getDefaultOptions } from "../util/config.ts";
import { goToUserList } from "../util/page.ts";
import { wrapTestFunction } from "../util/usecase-wrapper.ts";
import { getDefaultUserMix } from "../util/users.ts";
import { createRollePage } from "../pages/create-rolle.ts";
import { getOrganisationById, getOrganisationen, postRolle } from "../util/api";
import { EditRollePage } from "../pages/edit-rolle";

type TestData = {
testOrg: OrganisationResponse;
};

export const options = {
...getDefaultOptions(),
};
const users = getDefaultUserMix();

export function setup() {
// TODO: get testOrg
}

export function teardown(data: TestData) {
// TODO: delete rollen in testOrg
}

export default wrapTestFunction(main);

function main(data: TestData) {
group("setup", () => {
goToUserList(users.getLogin());
});
const rolleId = group("create rolle", () => {
// TODO: create rolle in testOrg
const data = createRollePage.fetchData();
const bodyParams: CreateRolleBodyParams = {
name: getRandomString(8),
administeredBySchulstrukturknoten: "",
rollenart: RollenArt.Lern,
merkmale: new Set(),
systemrechte: new Set(),
};
const rolleResponse = postRolle(bodyParams);
check(rolleResponse, {
"rolle created": (r) => r.id != undefined,
});
getOrganisationById(bodyParams.administeredBySchulstrukturknoten);
return rolleResponse.id;
});
group("delete rolle", () => {
const po = new EditRollePage(rolleId);
po.fetchData();
po.deleteRolle();
});
}
21 changes: 21 additions & 0 deletions loadtest/usecases/4_logout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { group } from "k6";
import { logout } from "../pages/index";
import { getDefaultOptions } from "../util/config.ts";
import { login } from "../util/page";
import { wrapTestFunction } from "../util/usecase-wrapper.ts";
import { getDefaultUserMix } from "../util/users.ts";

export const options = {
...getDefaultOptions(),
};

export default wrapTestFunction(main);

function main(users = getDefaultUserMix()) {
group("setup", () => {
login(users.getLogin());
});
group("logout", () => {
logout();
});
}
29 changes: 29 additions & 0 deletions loadtest/usecases/4_show-profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { check, fail, group } from "k6";
import { ProfilePage } from "../pages/profile";
import { getDefaultOptions } from "../util/config.ts";
import { login } from "../util/page";
import { wrapTestFunction } from "../util/usecase-wrapper.ts";
import { getDefaultUserMix } from "../util/users.ts";

export const options = {
...getDefaultOptions(),
};

export default wrapTestFunction(main);

function main(users = getDefaultUserMix()) {
const personId = group("setup", () => {
const { loginInfo } = login(users.getLogin());
if (
!check(loginInfo, {
"personId found": (info) => info.personId != undefined,
})
)
fail("no personId found");
return loginInfo.personId!;
});
group("go to profile", () => {
const profilePage = new ProfilePage(personId);
profilePage.navigate();
});
}
Loading

0 comments on commit b3c4ea3

Please sign in to comment.