test(UI): use non-admin user for tests
This commit is contained in:
parent
d19790e03d
commit
f07bc3b369
5 changed files with 32 additions and 4 deletions
5
.github/workflows/ui-tests.yml
vendored
5
.github/workflows/ui-tests.yml
vendored
|
|
@ -127,7 +127,10 @@ jobs:
|
|||
run: cd ~/frappe-bench/ && bench build --apps frappe
|
||||
|
||||
- name: Site Setup
|
||||
run: cd ~/frappe-bench/ && bench --site test_site execute frappe.utils.install.complete_setup_wizard
|
||||
run: |
|
||||
cd ~/frappe-bench/
|
||||
bench --site test_site execute frappe.utils.install.complete_setup_wizard
|
||||
bench --site test_site execute frappe.tests.ui_test_helpers.create_test_user
|
||||
|
||||
- name: UI Tests
|
||||
run: cd ~/frappe-bench/ && bench --site test_site run-ui-tests frappe --with-coverage --headless --parallel --ci-build-id $GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ const { defineConfig } = require("cypress");
|
|||
module.exports = defineConfig({
|
||||
projectId: "92odwv",
|
||||
adminPassword: "admin",
|
||||
testUser: "frappe@example.com",
|
||||
defaultCommandTimeout: 20000,
|
||||
pageLoadTimeout: 15000,
|
||||
video: true,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ context("Login", () => {
|
|||
|
||||
it("logs in using correct credentials", () => {
|
||||
cy.get("#login_email").type("Administrator");
|
||||
cy.get("#login_password").type(Cypress.config("adminPassword"));
|
||||
cy.get("#login_password").type(Cypress.env("adminPassword"));
|
||||
|
||||
cy.findByRole("button", { name: "Login" }).click();
|
||||
cy.location("pathname").should("eq", "/app");
|
||||
|
|
@ -56,7 +56,7 @@ context("Login", () => {
|
|||
);
|
||||
|
||||
cy.get("#login_email").type("Administrator");
|
||||
cy.get("#login_password").type(Cypress.config("adminPassword"));
|
||||
cy.get("#login_password").type(Cypress.env("adminPassword"));
|
||||
|
||||
cy.findByRole("button", { name: "Login" }).click();
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import "cypress-real-events/support";
|
|||
|
||||
Cypress.Commands.add("login", (email, password) => {
|
||||
if (!email) {
|
||||
email = "Administrator";
|
||||
email = Cypress.config("testUser") || "Administrator";
|
||||
}
|
||||
if (!password) {
|
||||
password = Cypress.env("adminPassword");
|
||||
|
|
|
|||
|
|
@ -396,3 +396,27 @@ def create_blog_post():
|
|||
).insert(ignore_if_duplicate=True)
|
||||
|
||||
return doc
|
||||
|
||||
|
||||
def create_test_user():
|
||||
username = "frappe@example.com"
|
||||
if frappe.db.exists("User", username):
|
||||
return
|
||||
|
||||
user = frappe.new_doc("User")
|
||||
user.email = username
|
||||
user.first_name = "Frappe"
|
||||
user.new_password = frappe.local.conf.admin_password
|
||||
user.send_welcome_email = 0
|
||||
user.flags.ignore_password_policy = True
|
||||
user.insert(ignore_if_duplicate=True)
|
||||
|
||||
user.reload()
|
||||
|
||||
blocked_roles = {"Administrator", "Guest", "All"}
|
||||
all_roles = set(frappe.get_all("Role", pluck="name"))
|
||||
|
||||
for role in all_roles - blocked_roles:
|
||||
user.append("roles", {"role": role})
|
||||
|
||||
user.save()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue