48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
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",
|
|
);
|
|
});
|
|
});
|
|
});
|