Debian Codegraph @

install/freeipa-webui/cypress/e2e/common/user_management.ts

raw symbols SCIP
1 import { When, Then, Given } from "@badeball/cypress-cucumber-preprocessor";
2 import { loginAsAdmin, logout } from "./authentication";
3 import {
4 entryDoesNotExist,
5 entryExists,
6 searchForEntry,
7 selectEntry,
8 } from "./data_tables";
9
10 const fillUser = (
11 firstName: string,
12 lastName: string,
13 password: string,
14 login?: string
15 ) => {
16 if (login) {
17 cy.dataCy("modal-textbox-login").type(login);
18 cy.dataCy("modal-textbox-login").should("have.value", login);
19 }
20
21 cy.dataCy("modal-textbox-first-name").type(firstName);
22 cy.dataCy("modal-textbox-first-name").should("have.value", firstName);
23
24 cy.dataCy("modal-textbox-last-name").type(lastName);
25 cy.dataCy("modal-textbox-last-name").should("have.value", lastName);
26
27 cy.dataCy("modal-textbox-new-password").type(password);
28 cy.dataCy("modal-textbox-new-password").should("have.value", password);
29
30 cy.dataCy("modal-textbox-verify-password").type(password);
31 cy.dataCy("modal-textbox-verify-password").should("have.value", password);
32 };
33
34 export const createUser = (
35 firstName: string,
36 lastName: string,
37 password: string,
38 login?: string
39 ) => {
40 cy.dataCy("active-users-button-add").click();
41 cy.dataCy("add-user-modal").should("exist");
42
43 fillUser(firstName, lastName, password, login);
44
45 cy.dataCy("modal-button-add").click();
46 cy.dataCy("add-user-modal").should("not.exist");
47 };
48
49 export const validateUser = (login: string) => {
50 searchForEntry(login);
51 entryExists(login);
52 };
53
54 When(
55 "I create user {string} {string} {string} with password {string}",
56 (login: string, firstName: string, lastName: string, password: string) => {
57 createUser(firstName, lastName, password, login);
58 }
59 );
60
61 Then("I should see user {string} in the user list", (username: string) => {
62 validateUser(username);
63 });
64
65 Given(
66 "User {string} {string} {string} exists and is using password {string}",
67 (login: string, firstName: string, lastName: string, password: string) => {
68 loginAsAdmin();
69 createUser(firstName, lastName, password, login);
70 validateUser(login);
71 logout();
72 }
73 );
74
75 Given("I delete user {string}", (username: string) => {
76 loginAsAdmin();
77 selectEntry(username);
78
79 cy.dataCy("active-users-button-delete").click();
80 cy.dataCy("delete-users-modal").should("exist");
81
82 cy.dataCy("modal-button-delete").click();
83 cy.dataCy("delete-users-modal").should("not.exist");
84
85 searchForEntry(username);
86 entryDoesNotExist(username);
87 logout();
88 });