Skip to content

Commit

Permalink
Test: User addition
Browse files Browse the repository at this point in the history
Test the addition of the user.
This test still depends on login via old_UI and will be changed in the
future.
It also depends on #134

Signed-off-by: Michal Polovka <mpolovka@redhat.com>
  • Loading branch information
miskopo committed Aug 2, 2023
1 parent adbd17c commit 15814cf
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
66 changes: 66 additions & 0 deletions tests/features/steps/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { When, Then, Given } from "@badeball/cypress-cucumber-preprocessor";

Given("I am on login page", () => {
// temporary solution as the new UI doesn't have login page yet
cy.visit("/ipa/ui");
});

Given(
"an administrator account named {word} exists",
(admin_account_exists) => {
console.log("Admin exists, SUCCESS");
// TODO: implement
}
);

When("I log in as {string} with password {string}", (loginName, password) => {
// temporary solution as the new UI doesn't have login page yet
cy.get("[id=username1]").type(loginName);
cy.get("[id=password2").type(password);
cy.get("button[name=login]").click();
cy.wait(1000);
cy.visit("/ipa/modern_ui");
});

When("I logout", () => {});

When("I open the side menu", () => {
cy.get('[id="nav-toggle"]').then(($ele) => {
if ($ele.attr("aria-expanded") === "false") {
$ele.click();
}
});
});

When("I close the side menu", () => {
cy.get('[id="nav-toggle"]').then(($ele) => {
if ($ele.attr("aria-expanded") === "true") {
$ele.click();
}
});
});
When("I click on {string} tab", (tabText) => {
cy.get("nav a").contains(tabText).click();
});

When("I click on {string} button", function (buttonText) {
cy.wait(1000);
cy.get("button").contains(buttonText).click();
});

When("in the modal dialog I click on {string} button", function (buttonText) {
cy.get("[role=dialog] button").contains(buttonText).click();
});

When("I type in the field {string} text {string}", (fieldName, content) => {
cy.get("[role=dialog] label")
.contains(fieldName)
.parent()
.then(($label) => {
cy.get("[name=modal-form-" + $label.attr("for") + "]").type(content);
});
});

Then("I should see {string} entry in the data table", (name) => {
cy.get("tr[id=" + name + "]").should("be.visible");
});
16 changes: 16 additions & 0 deletions tests/features/steps/test_user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { When, Then, Given } from "@badeball/cypress-cucumber-preprocessor";

Given("there is only admin user active", () => {
cy.get("tr[id=admin]", { timeout: 10000 }).should("be.visible");
cy.get('input[aria-label="Select all"]').check();
cy.get("tr[id=admin] input[type=checkbox]").uncheck();

cy.get("button")
.contains("Delete")
.then(($deleteButton) => {
if ($deleteButton.prop("disabled")) return;

$deleteButton.click();
cy.get("[role=dialog] button").contains("Delete").click();
});
});
20 changes: 20 additions & 0 deletions tests/features/test_active_user.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Feature: User manipulation
Create, edit, delete, preserve and activate users

Background:
Given I am on login page
When I log in as "admin" with password "Secret123"

Scenario: Add a new user
Given I open the side menu
* I click on "Active users" tab
* I close the side menu
* there is only admin user active
When I click on "Add" button
* I type in the field "User login" text "testuser1"
* I type in the field "First name" text "Arthur"
* I type in the field "Last name" text "Dent"
* I type in the field "New Password" text "ILoveKlingonPoetry42"
* I type in the field "Verify password" text "ILoveKlingonPoetry42"
* in the modal dialog I click on "Add" button
Then I should see "testuser1" entry in the data table

0 comments on commit 15814cf

Please sign in to comment.