From 910bc98197a01d5ebbc07baa5a4436f8101f3674 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Wed, 6 May 2026 23:25:14 +0300 Subject: [PATCH] add cypress confirm-email spec --- .../cypress/e2e/confirm_email_page.cy.ts | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 frontend/blog_portal/cypress/e2e/confirm_email_page.cy.ts diff --git a/frontend/blog_portal/cypress/e2e/confirm_email_page.cy.ts b/frontend/blog_portal/cypress/e2e/confirm_email_page.cy.ts new file mode 100644 index 0000000..09415f5 --- /dev/null +++ b/frontend/blog_portal/cypress/e2e/confirm_email_page.cy.ts @@ -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", + ); + }); + }); +});