add cypress signup spec
This commit is contained in:
parent
178193bfd8
commit
75ada812bc
1 changed files with 67 additions and 0 deletions
67
frontend/blog_portal/cypress/e2e/signup_page.cy.ts
Normal file
67
frontend/blog_portal/cypress/e2e/signup_page.cy.ts
Normal 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");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue