| 1 | import { Given, Then } from "@badeball/cypress-cucumber-preprocessor"; |
| 2 | import { createUser, validateUser } from "../common/user_management"; |
| 3 | import { loginAsAdmin, logout } from "../common/authentication"; |
| 4 | import { |
| 5 | entryExists, |
| 6 | isSelected, |
| 7 | searchForEntry, |
| 8 | selectEntry, |
| 9 | } from "../common/data_tables"; |
| 10 | |
| 11 | const disableUser = (login: string) => { |
| 12 | searchForEntry(login); |
| 13 | entryExists(login); |
| 14 | |
| 15 | selectEntry(login); |
| 16 | isSelected(login); |
| 17 | |
| 18 | cy.dataCy("active-users-button-disable").click(); |
| 19 | cy.dataCy("disable-users-modal").should("exist"); |
| 20 | |
| 21 | cy.dataCy("modal-button-disable").click(); |
| 22 | cy.dataCy("disable-users-modal").should("not.exist"); |
| 23 | |
| 24 | searchForEntry(login); |
| 25 | entryExists(login); |
| 26 | isDisabled(login); |
| 27 | }; |
| 28 | |
| 29 | const isDisabled = (name: string) => { |
| 30 | cy.get("tr[id='" + name + "'] td[data-label=Status]").contains("Disabled"); |
| 31 | }; |
| 32 | |
| 33 | const isEnabled = (name: string) => { |
| 34 | cy.get("tr[id='" + name + "'] td[data-label=Status]").contains("Enabled"); |
| 35 | }; |
| 36 | |
| 37 | Then( |
| 38 | "I should see {string} user in the data table disabled", |
| 39 | (name: string) => { |
| 40 | isDisabled(name); |
| 41 | } |
| 42 | ); |
| 43 | |
| 44 | Then("I should see {string} user in the data table enabled", (name: string) => { |
| 45 | isEnabled(name); |
| 46 | }); |
| 47 | |
| 48 | Given( |
| 49 | "Disabled user {string} {string} {string} exists and is using password {string}", |
| 50 | (login: string, firstName: string, lastName: string, password: string) => { |
| 51 | loginAsAdmin(); |
| 52 | createUser(firstName, lastName, password, login); |
| 53 | validateUser(login); |
| 54 | disableUser(login); |
| 55 | logout(); |
| 56 | } |
| 57 | ); |