diff --git a/src/components/settings/Users/EditUser.vue b/src/components/settings/Users/EditUser.vue index 59a8a174710..baeec88ed8a 100644 --- a/src/components/settings/Users/EditUser.vue +++ b/src/components/settings/Users/EditUser.vue @@ -14,10 +14,11 @@ class="form-control mt-2" required :disabled="saving" + data-cy="edit-username-input" /> - @@ -35,6 +36,7 @@ class="form-control mt-2" required :disabled="savingPassword" + data-cy="edit-current-password-input" /> @@ -49,6 +51,7 @@ class="form-control mt-2" required :disabled="savingPassword" + data-cy="edit-new-password-input" /> @@ -63,11 +66,12 @@ class="form-control mt-2" required :disabled="savingPassword" + data-cy="edit-new-password-repeat-input" /> - @@ -83,6 +87,7 @@ type="checkbox" :disabled="saving" @click="debounceCheckboxClick(() => { active = !active; save({ active }); })" + data-cy="edit-active-checkbox" >
{{ $t("Active") }}
diff --git a/test/cypress/e2e/settings.cy.js b/test/cypress/e2e/settings.cy.js index 133eb47a92f..442340223b7 100644 --- a/test/cypress/e2e/settings.cy.js +++ b/test/cypress/e2e/settings.cy.js @@ -1,6 +1,7 @@ const actor = require("../support/actors/actor"); const userData = require("../support/const/user-data"); const settingsUsersAddPage = require("../support/pages/settings-users-add-page"); +const settingsUsersEditPage = require("../support/pages/settings-users-edit-page"); describe("user can create a new account on settings page", () => { before(() => { @@ -16,13 +17,34 @@ describe("user can create a new account on settings page", () => { }); }); -describe("logout and login with new user", () => { +describe("login with new user then edit info", () => { before(() => { cy.visit('/'); actor.actor.loginTask.fillAndSubmitLoginForm(userData.ADMIN_USER_DATA.username, userData.ADMIN_USER_DATA.password); }); it("user can edit its data with new created account", () => { cy.visit(`/settings/users/edit/${userData.ADMIN_USER_DATA.id}`); + + actor.actor.editUserTask.fillAndSubmitNewUserNameForm(userData.ADMIN_USER_DATA.username + "new"); + actor.actor.editUserTask.fillAndSubmitNewPasswordForm(userData.ADMIN_USER_DATA.password, userData.ADMIN_USER_DATA.password + "new", userData.ADMIN_USER_DATA.password + "new"); + + cy.wait(1000); + cy.visit('/'); + actor.actor.loginTask.fillAndSubmitLoginForm(userData.ADMIN_USER_DATA.username + "new", userData.ADMIN_USER_DATA.password + "new"); + cy.visit(`/settings/users/edit/${userData.DEFAULT_USER_DATA.id}`); + actor.actor.editUserTask.inactivateUser(); + cy.wait(2000); + + }); + +}); +describe("Inactivated user cannot login", () => { + it("user cannot login with inactivated account", () => { + cy.visit('/'); + actor.actor.loginTask.fillAndSubmitLoginForm(userData.DEFAULT_USER_DATA.username, userData.DEFAULT_USER_DATA.password); + cy.get('.alert') + .should("be.visible") + .and("contain.text", "Incorrect username or password."); }); }); \ No newline at end of file diff --git a/test/cypress/support/actors/actor.js b/test/cypress/support/actors/actor.js index 8a2c71fc436..f503a6a6005 100644 --- a/test/cypress/support/actors/actor.js +++ b/test/cypress/support/actors/actor.js @@ -1,11 +1,13 @@ const setupTask = require("../tasks/setup-task"); const loginTask = require("../tasks/login-task"); const createUserTask = require("../tasks/create-user-task"); +const editUserTask = require("../tasks/edit-user-task"); class Actor { constructor() { this.setupTask = new setupTask.SetupTask(); this.loginTask = new loginTask.LoginTask(); this.createUserTask = new createUserTask.CreateUserTask(); + this.editUserTask = new editUserTask.EditUserTask(); } } const actor = new Actor(); diff --git a/test/cypress/support/pages/settings-users-edit-page.js b/test/cypress/support/pages/settings-users-edit-page.js index 2cd6fe492b6..e9ac10be12f 100644 --- a/test/cypress/support/pages/settings-users-edit-page.js +++ b/test/cypress/support/pages/settings-users-edit-page.js @@ -1,9 +1,10 @@ -const SettingsUsersEditPage = { +exports.SettingsUsersEditPage = { url: Cypress.env("baseUrl") + "/settings/users/edit", - usernameInput: '[data-cy="username-input"]', - newPassWordInput: '[data-cy="password-input"]', - newPasswordRepeatInput: '[data-cy="password-repeat-input"]', - submitEditUserForm: '[data-cy="submit-create-admin-form"]', - submitNewPasswordForm: '[data-cy="submit-new-password-form"]', - activeStatus: '[data-cy="active-status"]', + usernameInput: '[data-cy="edit-username-input"]', + currentPassWordInput: '[data-cy="edit-current-password-input"]', + newPassWordInput: '[data-cy="edit-new-password-input"]', + newPasswordRepeatInput: '[data-cy="edit-new-password-repeat-input"]', + submitEditUserNameForm: '[data-cy="submit-edit-username-form"]', + submitNewPasswordForm: '[data-cy="submit-edit-password-form"]', + activeStatus: '[data-cy="edit-active-checkbox"]', }; \ No newline at end of file diff --git a/test/cypress/support/tasks/edit-user-task.js b/test/cypress/support/tasks/edit-user-task.js new file mode 100644 index 00000000000..fb2c4c06ca2 --- /dev/null +++ b/test/cypress/support/tasks/edit-user-task.js @@ -0,0 +1,19 @@ +const settingsUsersEditPage = require('../pages/settings-users-edit-page'); + +class EditUserTask{ + fillAndSubmitNewUserNameForm(username){ + cy.get(settingsUsersEditPage.SettingsUsersEditPage.usernameInput).clear(); + cy.get(settingsUsersEditPage.SettingsUsersEditPage.usernameInput).type(username); + cy.get(settingsUsersEditPage.SettingsUsersEditPage.submitEditUserNameForm).click(); + } + fillAndSubmitNewPasswordForm(password, newPassword, newPasswordRepeat){ + cy.get(settingsUsersEditPage.SettingsUsersEditPage.currentPassWordInput).type(password); + cy.get(settingsUsersEditPage.SettingsUsersEditPage.newPassWordInput).type(newPassword); + cy.get(settingsUsersEditPage.SettingsUsersEditPage.newPasswordRepeatInput).type(newPasswordRepeat); + cy.get(settingsUsersEditPage.SettingsUsersEditPage.submitNewPasswordForm).click(); + } + inactivateUser(){ + cy.get(settingsUsersEditPage.SettingsUsersEditPage.activeStatus).uncheck(); + } +} +exports.EditUserTask = EditUserTask; \ No newline at end of file