Skip to content

Commit

Permalink
ui-tests issue #2213
Browse files Browse the repository at this point in the history
  • Loading branch information
sgauruseu committed Jan 17, 2025
1 parent 4a19be5 commit beb2ea4
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 7 deletions.
8 changes: 4 additions & 4 deletions testing/libs/app_const.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = Object.freeze({
return part + Math.round(Math.random() * 1000000);
},
//waitForTimeout
mediumTimeout: 3500,
mediumTimeout: 4000,
TIMEOUT_4: 4000,
TIMEOUT_7: 7000,
shortTimeout: 2000,
Expand Down Expand Up @@ -42,10 +42,10 @@ module.exports = Object.freeze({
},

PASSWORD: {
MEDIUM: "password123",
STRONG: "password123=",
MEDIUM: "userA567$",
STRONG: "userA567$=",
WEAK: "1q2w3e",
WITH_SPACES: " password123 "
WITH_SPACES: " userA567$ "
},
PASSWORD_STATE: {
MEDIUM: "Medium",
Expand Down
5 changes: 3 additions & 2 deletions testing/page_objects/confirmation.dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ class ConfirmationDialog extends Page {
async clickOnYesButton() {
try {
await this.clickOnElement(this.yesButton);
return await this.waitForElementNotDisplayed(XPATH.container, appConst.mediumTimeout);
await this.waitForElementNotDisplayed(XPATH.container, appConst.mediumTimeout);
await this.pause(500);
} catch (err) {
let screenshot = await this.saveScreenshotUniqueName('err_close_confirmation_dialog');
throw new Error('Confirmation dialog must be closed! screenshot: ' + screenshot + ' ' + err);
throw new Error(`Confirmation dialog must be closed! screenshot: ${screenshot} ` + err);
}
}

Expand Down
85 changes: 85 additions & 0 deletions testing/tests/clear.password.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Created on 17.01.2025
*/
const assert = require('node:assert');
const webDriverHelper = require('../libs/WebDriverHelper');
const UserWizard = require('../page_objects/wizardpanel/user.wizard');
const testUtils = require('../libs/test.utils');
const userItemsBuilder = require('../libs/userItems.builder.js');
const appConst = require('../libs/app_const');
const ConfirmationDialog = require('../page_objects/confirmation.dialog');

describe('edit.user.spec: Edit an user - change e-mail, name and roles', function () {
this.timeout(appConst.TIMEOUT_SUITE);

if (typeof browser === 'undefined') {
webDriverHelper.setupBrowser();
}

let TEST_USER;
const PASSWORD = appConst.PASSWORD.MEDIUM;

it("GIVEN new user with a password(medium) has been saved WHEN 'Clear' password button has been clicked THEN confirmation dialog should appear",
async () => {
let userWizard = new UserWizard();
let confirmationDialog = new ConfirmationDialog();
let userName = userItemsBuilder.generateRandomName('user');
TEST_USER = userItemsBuilder.buildUser(userName, PASSWORD, userItemsBuilder.generateEmail(userName), null);
// 1. Select 'System' folder and open User Wizard:
await testUtils.clickOnSystemOpenUserWizard();
// 2. Insert the required data:
await userWizard.typeData(TEST_USER);
// 3. Save the user:
await userWizard.waitAndClickOnSave();
// 4. Verify that 'Change password' button is displayed:
await userWizard.waitForChangePasswordButtonDisplayed();
// 5. Verify that 'Clear password' button is displayed:
await userWizard.waitForClearPasswordButtonDisplayed();
// 6. Verify that 'Add public key' button is displayed:
await userWizard.waitForAddPublicKeyButtonDisplayed();
// 7. Click on 'Clear password' button:
await userWizard.clickOnClearPasswordButton();
// 8. Verify that confirmation dialog is displayed:
await confirmationDialog.waitForDialogLoaded();
let question = await confirmationDialog.getQuestionText();
assert.ok(question.includes('Are you sure you want to clear the password?'), 'Expected question should be displayed');
// 9. Click on button 'No':
await confirmationDialog.clickOnNoButton();
// 10. Verify that confirmation dialog is closed:
await confirmationDialog.waitForDialogClosed();
// 11. Verify that 'Change password' button remains displayed:
await userWizard.waitForChangePasswordButtonDisplayed();
await userWizard.waitForClearPasswordButtonDisplayed();
await userWizard.waitForAddPublicKeyButtonDisplayed();
});

it("WHEN 'Clear password' button has been clicked THEN 'Set password' button gets visible AND Save button remains enabled",
async () => {
let userWizard = new UserWizard();
let confirmationDialog = new ConfirmationDialog();
// 1. Open the existing user:
await testUtils.selectUserAndOpenWizard(TEST_USER.displayName);
// 2. Click on 'Clear Password' button:
await userWizard.clickOnClearPasswordButton();
await confirmationDialog.waitForDialogLoaded();
// 3. Click on button 'Yes':
await confirmationDialog.clickOnYesButton();
await confirmationDialog.waitForDialogClosed();
await testUtils.saveScreenshot('password_cleared');
// 4. Verify that 'Change password' button is not displayed now and 'Clear password' button is not displayed:
await userWizard.waitForChangePasswordButtonNotDisplayed();
await userWizard.waitForClearPasswordButtonNotDisplayed();
await userWizard.waitForAddPublicKeyButtonDisplayed();

// 5. Verify that 'Set password' button is displayed
await userWizard.waitForSetPasswordButtonDisplayed();
await userWizard.waitForSaveButtonEnabled();
});

beforeEach(() => testUtils.navigateToUsersApp());
afterEach(() => testUtils.doCloseUsersApp());
before(async () => {
await testUtils.getBrowser().maximizeWindow();
return console.log('specification starting: ' + this.title);
});
});
2 changes: 1 addition & 1 deletion testing/tests/user.save.negative.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Negative ui-tests for user wizard ', function () {
let actualStatus = await userWizard.getPasswordStatus();
assert.equal(actualStatus, appConst.PASSWORD_STATE.WEAK, "'Weak' state of the password should be displayed");
// 4. Verify that user is invalid:
await userWizard.waitUntilInvalidIconAppears(TEST_USER.displayName);
await userWizard.waitUntilInvalidIconDisplayed(userName);
await userWizard.waitForSaveButtonDisabled();
});

Expand Down

0 comments on commit beb2ea4

Please sign in to comment.