add cypress confirm-email spec
This commit is contained in:
parent
9db7920f80
commit
910bc98197
1 changed files with 48 additions and 0 deletions
48
frontend/blog_portal/cypress/e2e/confirm_email_page.cy.ts
Normal file
48
frontend/blog_portal/cypress/e2e/confirm_email_page.cy.ts
Normal 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",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue