add cypress login spec

This commit is contained in:
Yisroel Baum 2026-05-06 23:25:01 +03:00
parent 75ada812bc
commit 9db7920f80
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -0,0 +1,41 @@
describe("login page", function () {
beforeEach(function () {
cy.resetDb();
cy.clearMail();
cy.seedConfirmedUser({
email: "alice@example.com",
displayName: "alice",
password: "longenoughpassword",
});
});
it("logs in with valid credentials and shows the user in the header", function () {
cy.visit("/login");
cy.get('input[type="email"]').type("alice@example.com");
cy.get('input[type="password"]').type("longenoughpassword");
cy.contains("button", "Log in").click();
cy.location("pathname").should("eq", "/");
cy.get(".app-header").contains("alice").should("be.visible");
});
it("shows an error on wrong password", function () {
cy.visit("/login");
cy.get('input[type="email"]').type("alice@example.com");
cy.get('input[type="password"]').type("wrongpassword");
cy.contains("button", "Log in").click();
cy.location("pathname").should("eq", "/login");
cy.contains(".error", "invalid credentials").should("be.visible");
});
it("redirects authenticated users away from /login", function () {
cy.loginViaApi({
email: "alice@example.com",
password: "longenoughpassword",
});
cy.visit("/login");
cy.location("pathname").should("eq", "/");
});
});