add cypress signup spec

This commit is contained in:
Yisroel Baum 2026-05-06 23:24:50 +03:00
parent 178193bfd8
commit 75ada812bc
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -0,0 +1,67 @@
describe("signup page", function () {
beforeEach(function () {
cy.resetDb();
cy.clearMail();
});
it("creates an unconfirmed user and redirects to check-email", function () {
cy.visit("/signup");
cy.get('input[type="email"]').type("alice@example.com");
cy.get('input[autocomplete="username"]').type("alice");
cy.contains("button", "Continue").click();
cy.location("pathname").should("eq", "/check-email");
cy.contains("h1", "Check your email").should("be.visible");
cy.getMail().then(function (inbox) {
expect(inbox.messages).to.have.length(1);
expect(inbox.messages[0].To[0].Address).to.equal(
"alice@example.com",
);
});
});
it("surfaces a 409 when the email is already registered", function () {
cy.seedConfirmedUser({
email: "alice@example.com",
displayName: "alice",
password: "longenoughpassword",
});
cy.clearMail();
cy.visit("/signup");
cy.get('input[type="email"]').type("alice@example.com");
cy.get('input[autocomplete="username"]').type("alice2");
cy.contains("button", "Continue").click();
cy.location("pathname").should("eq", "/signup");
cy.contains(".error", "email already registered").should("be.visible");
});
it("surfaces a 409 when the display name is taken", function () {
cy.seedConfirmedUser({
email: "alice@example.com",
displayName: "alice",
password: "longenoughpassword",
});
cy.clearMail();
cy.visit("/signup");
cy.get('input[type="email"]').type("other@example.com");
cy.get('input[autocomplete="username"]').type("alice");
cy.contains("button", "Continue").click();
cy.location("pathname").should("eq", "/signup");
cy.contains(".error", "displayName already taken").should("be.visible");
});
it("blocks invalid display name characters client-side", function () {
cy.visit("/signup");
cy.get('input[type="email"]').type("alice@example.com");
cy.get('input[autocomplete="username"]').type("Has Spaces");
cy.contains("button", "Continue").click();
cy.location("pathname").should("eq", "/signup");
cy.get('input[autocomplete="username"]:invalid').should("exist");
});
});