Split anonymous access e2e tests into separate files

This commit is contained in:
Sebastian Sdorra
2020-08-12 12:13:23 +02:00
parent 6fbb3b9d53
commit 752745868a
9 changed files with 149 additions and 78 deletions

View File

@@ -47,15 +47,23 @@
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
const login = (username, password) => {
cy.visit( "/login");
cy.visit("/login");
cy.byTestId("username-input").type(username);
cy.byTestId("password-input").type(password);
cy.byTestId("login-button").click();
};
Cypress.Commands.add("login", login);
Cypress.Commands.add("byTestId", (testId) => cy.get("[data-testid=" + testId + "]"));
Cypress.Commands.add("containsNotByTestId", (container, testId) => cy.get(container).not("[data-testid=" + testId + "]"));
const setAnonymousMode = anonymousMode => {
cy.byTestId("primary-navigation-admin").click();
cy.byTestId("admin-settings-link").click();
cy.byTestId("anonymous-mode-select")
.select(anonymousMode)
.should("have.value", anonymousMode);
cy.byTestId("submit-button").click();
};
Cypress.Commands.add("login", login);
Cypress.Commands.add("setAnonymousMode", setAnonymousMode);
Cypress.Commands.add("byTestId", testId => cy.get(`[data-testid=${testId}]`));
Cypress.Commands.add("containsNotByTestId", (container, testId) => cy.get(container).not(`[data-testid=${testId}]`));