vbv/cypress/e2e/login.cy.js

47 lines
1.3 KiB
JavaScript

import { login } from "./helpers";
describe("login.cy.js", () => {
Cypress.on("uncaught:exception", (err, runnable) => {
// do not fail on failed requests during tests
return false;
});
beforeEach(() => {
cy.manageCommand("cypress_reset");
});
it("can login to app with username/password", () => {
cy.visit("/login-local");
cy.get("#username").type("test-student1@example.com");
cy.get("#password").type("test");
cy.get("[data-cy=\"login-button\"]").click();
cy.request("/api/core/me").its("status").should("eq", 200);
cy.get("[data-cy=\"dashboard-title\"]").should("contain", "Dashboard");
});
it("can login with helper function", () => {
login("test-student1@example.com", "test");
cy.visit("/");
cy.request("/api/core/me").its("status").should("eq", 200);
cy.get("[data-cy=\"dashboard-title\"]").should("contain", "Dashboard");
});
it("login will redirect to requested page", () => {
cy.visit("/course/test-lehrgang/learn");
cy.get("h1").should("contain", "Login");
cy.get("#username").type("test-student1@example.com");
cy.get("#password").type("test");
cy.get("[data-cy=\"login-button\"]").click();
cy.get("[data-cy=\"learning-path-title\"]").should(
"contain",
"Test Lehrgang"
);
});
});