forked from louislam/uptime-kuma
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Rovel/add-new-admins-cy-tests
add cy login and create admin tests for louislam#3571
- Loading branch information
Showing
10 changed files
with
104 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const actor = require("../support/actors/actor"); | ||
const userData = require("../support/const/user-data"); | ||
const settingsUsersAddPage = require("../support/pages/settings-users-add-page"); | ||
|
||
describe("user can create a new account on settings page", () => { | ||
before(() => { | ||
cy.visit("/settings/users/add"); | ||
actor.actor.loginTask.fillAndSubmitLoginForm(); | ||
}); | ||
it("user cannot create new account with same", () => { | ||
cy.url().should("be.equal", settingsUsersAddPage.SettingsUsersAddPage.url); | ||
actor.actor.createUserTask.fillAndSubmitNewUserForm(userData.ADMIN_USER_DATA.username, userData.ADMIN_USER_DATA.password, userData.DEFAULT_USER_DATA.password); | ||
cy.get('[role="alert"]') | ||
.should("be.visible") | ||
.and("contain.text", "Added Successfully."); | ||
}); | ||
}); | ||
|
||
describe("logout and login with new user", () => { | ||
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}`); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
exports.LoginCompónent = { | ||
userNameInput: '[data-cy="login-username-input"]', | ||
passWordInput: '[data-cy="login-password-input"]', | ||
submitLoginForm: '[data-cy="submit-login-form"]', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
exports.DEFAULT_USER_DATA = { | ||
id: "1", | ||
username: "testuser", | ||
password: "testuser123", | ||
}; | ||
exports.ADMIN_USER_DATA = { | ||
id: "2", | ||
username: "admin_user", | ||
password: "testuser123", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
exports.SettingsUsersAddPage = { | ||
url: Cypress.env("baseUrl") + "/settings/users/add", | ||
usernameInput: '[data-cy="username-input"]', | ||
passWordInput: '[data-cy="password-input"]', | ||
passwordRepeatInput: '[data-cy="password-repeat-input"]', | ||
submitNewUserForm: '[data-cy="submit-create-admin-form"]', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const 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"]', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const settingsUsersAddPage = require('../pages/settings-users-add-page'); | ||
|
||
class CreateUserTask{ | ||
fillAndSubmitNewUserForm(username, password, passwordRepeat){ | ||
cy.get(settingsUsersAddPage.SettingsUsersAddPage.usernameInput).type(username); | ||
cy.get(settingsUsersAddPage.SettingsUsersAddPage.passWordInput).type(password); | ||
cy.get(settingsUsersAddPage.SettingsUsersAddPage.passwordRepeatInput).type(passwordRepeat); | ||
cy.get(settingsUsersAddPage.SettingsUsersAddPage.submitNewUserForm).click(); | ||
} | ||
} | ||
exports.CreateUserTask = CreateUserTask; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const user_data = require('../const/user-data'); | ||
const login_component = require('../components/login-component'); | ||
|
||
class LoginTask { | ||
fillAndSubmitLoginForm(username, password) { | ||
// check if username and password are provided else use default user | ||
if (username && password) { | ||
cy.get(login_component.LoginCompónent.userNameInput).type(username); | ||
cy.get(login_component.LoginCompónent.passWordInput).type(password); | ||
} else { | ||
cy.get(login_component.LoginCompónent.userNameInput).type(user_data.DEFAULT_USER_DATA.username); | ||
cy.get(login_component.LoginCompónent.passWordInput).type(user_data.DEFAULT_USER_DATA.password); | ||
} | ||
|
||
cy.get(login_component.LoginCompónent.submitLoginForm).click(); | ||
} | ||
} | ||
exports.LoginTask = LoginTask; |