2021-10-24 06:09:43 +02:00
|
|
|
import {
|
|
|
|
putUsersResetPasswordHandler,
|
2023-10-23 23:33:39 +02:00
|
|
|
putUsersResetPasswordInvalidTemporaryTokenHandler,
|
|
|
|
} from "../../../fixtures/users/reset-password/put"
|
2021-10-24 06:09:43 +02:00
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
describe("Pages > /authentication/reset-password", () => {
|
2021-10-24 06:09:43 +02:00
|
|
|
beforeEach(() => {
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.task("stopMockServer")
|
2021-10-24 06:09:43 +02:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should succeeds and redirect user to sign in page", () => {
|
|
|
|
cy.task("startMockServer", [putUsersResetPasswordHandler])
|
|
|
|
cy.visit("/authentication/reset-password?temporaryToken=abcdefg")
|
|
|
|
cy.get("#message").should("not.exist")
|
|
|
|
cy.get("[data-cy=input-password]").type("somepassword")
|
|
|
|
cy.get("[data-cy=submit]").click()
|
|
|
|
cy.location("pathname").should("eq", "/authentication/signin")
|
2021-10-24 06:09:43 +02:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should fails with invalid `temporaryToken`", () => {
|
|
|
|
cy.task("startMockServer", [
|
|
|
|
putUsersResetPasswordInvalidTemporaryTokenHandler,
|
2021-10-24 06:09:43 +02:00
|
|
|
])
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.visit("/authentication/reset-password")
|
|
|
|
cy.get("#message").should("not.exist")
|
|
|
|
cy.get("[data-cy=input-password]").type("somepassword")
|
|
|
|
cy.get("[data-cy=submit]").click()
|
|
|
|
cy.get("#message").should("have.text", "Error: Invalid value.")
|
2021-10-24 06:09:43 +02:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should fails with unreachable api server", () => {
|
|
|
|
cy.visit("/authentication/reset-password")
|
|
|
|
cy.get("#message").should("not.exist")
|
|
|
|
cy.get("[data-cy=input-password]").type("randompassword")
|
|
|
|
cy.get("[data-cy=submit]").click()
|
|
|
|
cy.get("#message").should("have.text", "Error: Internal Server Error.")
|
2021-10-24 06:09:43 +02:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should fails with empty password value", () => {
|
|
|
|
cy.visit("/authentication/reset-password")
|
|
|
|
cy.get("#message").should("not.exist")
|
|
|
|
cy.get("[data-cy=submit]").click()
|
|
|
|
cy.get("#message").should(
|
|
|
|
"have.text",
|
|
|
|
"Error: Oops, this field is required 🙈.",
|
2021-10-26 16:38:55 +02:00
|
|
|
)
|
2021-10-24 06:09:43 +02:00
|
|
|
})
|
|
|
|
})
|
2022-08-23 21:51:20 +02:00
|
|
|
|
|
|
|
export {}
|