add cypress confirm-email spec

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

View file

@ -0,0 +1,48 @@
describe("confirm email page", function () {
beforeEach(function () {
cy.resetDb();
cy.clearMail();
});
it("redirects to /login when no token is present", function () {
cy.visit("/confirm-email");
cy.location("pathname").should("eq", "/login");
});
it("sets the password and redirects to /login on success", function () {
cy.signupViaApi({
email: "alice@example.com",
displayName: "alice",
});
cy.fetchLatestConfirmToken("alice@example.com").then(function (token) {
cy.visit(`/confirm-email?token=${token}`);
cy.get('input[type="password"]').type("longenoughpassword");
cy.contains("button", "Confirm").click();
cy.location("pathname").should("eq", "/login");
cy.loginViaApi({
email: "alice@example.com",
password: "longenoughpassword",
});
});
});
it("shows the backend error when password is too short", function () {
cy.signupViaApi({
email: "alice@example.com",
displayName: "alice",
});
cy.fetchLatestConfirmToken("alice@example.com").then(function (token) {
cy.visit(`/confirm-email?token=${token}`);
cy.get('input[type="password"]')
.invoke("removeAttr", "minlength")
.type("short");
cy.contains("button", "Confirm").click();
cy.contains(".error", "password must be at least 8").should(
"be.visible",
);
});
});
});