chore: better Prettier config for easier reviews

This commit is contained in:
2023-10-23 23:33:39 +02:00
parent a8781724d4
commit 71ea41695f
209 changed files with 4093 additions and 4114 deletions

View File

@ -1,37 +1,37 @@
import { postUsersResetPasswordHandler } from '../../../fixtures/users/reset-password/post'
import { userExample } from '../../../fixtures/users/user'
import { postUsersResetPasswordHandler } from "../../../fixtures/users/reset-password/post"
import { userExample } from "../../../fixtures/users/user"
describe('Pages > /authentication/forgot-password', () => {
describe("Pages > /authentication/forgot-password", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.visit('/authentication/forgot-password')
cy.task("stopMockServer")
cy.visit("/authentication/forgot-password")
})
it('should succeeds and sends a password-reset request', () => {
cy.task('startMockServer', [postUsersResetPasswordHandler])
cy.get('#message').should('not.exist')
cy.get('[data-cy=input-email]').type(userExample.email)
cy.get('[data-cy=submit]').click()
cy.get('#message').should(
'have.text',
'Success: Password-reset request successful, please check your emails!'
it("should succeeds and sends a password-reset request", () => {
cy.task("startMockServer", [postUsersResetPasswordHandler])
cy.get("#message").should("not.exist")
cy.get("[data-cy=input-email]").type(userExample.email)
cy.get("[data-cy=submit]").click()
cy.get("#message").should(
"have.text",
"Success: Password-reset request successful, please check your emails!",
)
})
it('should fails with unreachable api server', () => {
cy.get('#message').should('not.exist')
cy.get('[data-cy=input-email]').type(userExample.email)
cy.get('[data-cy=submit]').click()
cy.get('#message').should('have.text', 'Error: Internal Server Error.')
it("should fails with unreachable api server", () => {
cy.get("#message").should("not.exist")
cy.get("[data-cy=input-email]").type(userExample.email)
cy.get("[data-cy=submit]").click()
cy.get("#message").should("have.text", "Error: Internal Server Error.")
})
it('should fails with wrong email format', () => {
cy.get('#message').should('not.exist')
cy.get('[data-cy=input-email]').type('test')
cy.get('[data-cy=submit]').click()
cy.get('#message').should(
'have.text',
'Error: Mmm… It seems that this email is not valid 🤔.'
it("should fails with wrong email format", () => {
cy.get("#message").should("not.exist")
cy.get("[data-cy=input-email]").type("test")
cy.get("[data-cy=submit]").click()
cy.get("#message").should(
"have.text",
"Error: Mmm… It seems that this email is not valid 🤔.",
)
})
})

View File

@ -1,48 +1,48 @@
import {
putUsersResetPasswordHandler,
putUsersResetPasswordInvalidTemporaryTokenHandler
} from '../../../fixtures/users/reset-password/put'
putUsersResetPasswordInvalidTemporaryTokenHandler,
} from "../../../fixtures/users/reset-password/put"
describe('Pages > /authentication/reset-password', () => {
describe("Pages > /authentication/reset-password", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.task("stopMockServer")
})
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')
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")
})
it('should fails with invalid `temporaryToken`', () => {
cy.task('startMockServer', [
putUsersResetPasswordInvalidTemporaryTokenHandler
it("should fails with invalid `temporaryToken`", () => {
cy.task("startMockServer", [
putUsersResetPasswordInvalidTemporaryTokenHandler,
])
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.')
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.")
})
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.')
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.")
})
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 🙈.'
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 🙈.",
)
})
})

View File

@ -1,56 +1,56 @@
import { authenticationHandlers } from '../../../fixtures/handler'
import { authenticationHandlers } from "../../../fixtures/handler"
import {
postUsersSigninHandler,
postUsersSigninInvalidCredentialsHandler
} from '../../../fixtures/users/signin/post'
import { userExample } from '../../../fixtures/users/user'
postUsersSigninInvalidCredentialsHandler,
} from "../../../fixtures/users/signin/post"
import { userExample } from "../../../fixtures/users/user"
describe('Pages > /authentication/signin', () => {
describe("Pages > /authentication/signin", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.visit('/authentication/signin')
cy.task("stopMockServer")
cy.visit("/authentication/signin")
})
it('should succeeds and sign in the user', () => {
cy.task('startMockServer', [
it("should succeeds and sign in the user", () => {
cy.task("startMockServer", [
...authenticationHandlers,
postUsersSigninHandler
postUsersSigninHandler,
])
cy.get('#error-email').should('not.exist')
cy.get('#error-password').should('not.exist')
cy.get('[data-cy=input-email]').type(userExample.email)
cy.get('[data-cy=input-password]').type('randompassword')
cy.get('[data-cy=submit]').click()
cy.location('pathname').should('eq', '/application')
cy.get("#error-email").should("not.exist")
cy.get("#error-password").should("not.exist")
cy.get("[data-cy=input-email]").type(userExample.email)
cy.get("[data-cy=input-password]").type("randompassword")
cy.get("[data-cy=submit]").click()
cy.location("pathname").should("eq", "/application")
})
it('should fails with unreachable api server', () => {
cy.get('#error-email').should('not.exist')
cy.get('#error-password').should('not.exist')
cy.get('[data-cy=input-email]').type(userExample.email)
cy.get('[data-cy=input-password]').type('randompassword')
cy.get('[data-cy=submit]').click()
cy.get('#message').should('have.text', 'Error: Internal Server Error.')
cy.get('#error-email').should('not.exist')
cy.get('#error-password').should('not.exist')
it("should fails with unreachable api server", () => {
cy.get("#error-email").should("not.exist")
cy.get("#error-password").should("not.exist")
cy.get("[data-cy=input-email]").type(userExample.email)
cy.get("[data-cy=input-password]").type("randompassword")
cy.get("[data-cy=submit]").click()
cy.get("#message").should("have.text", "Error: Internal Server Error.")
cy.get("#error-email").should("not.exist")
cy.get("#error-password").should("not.exist")
})
it('should fails with invalid credentials', () => {
cy.task('startMockServer', [
it("should fails with invalid credentials", () => {
cy.task("startMockServer", [
...authenticationHandlers,
postUsersSigninInvalidCredentialsHandler
postUsersSigninInvalidCredentialsHandler,
])
cy.get('#error-email').should('not.exist')
cy.get('#error-password').should('not.exist')
cy.get('[data-cy=input-email]').type(userExample.email)
cy.get('[data-cy=input-password]').type('randompassword')
cy.get('[data-cy=submit]').click()
cy.get('#message').should(
'have.text',
'Error: Invalid credentials. Please try again.'
cy.get("#error-email").should("not.exist")
cy.get("#error-password").should("not.exist")
cy.get("[data-cy=input-email]").type(userExample.email)
cy.get("[data-cy=input-password]").type("randompassword")
cy.get("[data-cy=submit]").click()
cy.get("#message").should(
"have.text",
"Error: Invalid credentials. Please try again.",
)
cy.get('#error-email').should('not.exist')
cy.get('#error-password').should('not.exist')
cy.get("#error-email").should("not.exist")
cy.get("#error-password").should("not.exist")
})
})

View File

@ -1,85 +1,85 @@
import { userExample } from '../../../fixtures/users/user'
import { userExample } from "../../../fixtures/users/user"
import {
postUsersSignupHandler,
postUsersSignupAlreadyUsedHandler
} from '../../../fixtures/users/signup/post'
postUsersSignupAlreadyUsedHandler,
} from "../../../fixtures/users/signup/post"
describe('Pages > /authentication/signup', () => {
describe("Pages > /authentication/signup", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.visit('/authentication/signup')
cy.task("stopMockServer")
cy.visit("/authentication/signup")
})
it('should succeeds and sign up the user', () => {
cy.task('startMockServer', [postUsersSignupHandler])
cy.get('#error-name').should('not.exist')
cy.get('#error-email').should('not.exist')
cy.get('#error-password').should('not.exist')
cy.get('[data-cy=input-name]').type(userExample.name)
cy.get('[data-cy=input-email]').type(userExample.email)
cy.get('[data-cy=input-password]').type('randompassword')
cy.get('[data-cy=submit]').click()
cy.get('#message').should(
'have.text',
"Success: You're almost there, please check your emails to confirm registration."
it("should succeeds and sign up the user", () => {
cy.task("startMockServer", [postUsersSignupHandler])
cy.get("#error-name").should("not.exist")
cy.get("#error-email").should("not.exist")
cy.get("#error-password").should("not.exist")
cy.get("[data-cy=input-name]").type(userExample.name)
cy.get("[data-cy=input-email]").type(userExample.email)
cy.get("[data-cy=input-password]").type("randompassword")
cy.get("[data-cy=submit]").click()
cy.get("#message").should(
"have.text",
"Success: You're almost there, please check your emails to confirm registration.",
)
})
it('should fails with name or email already used', () => {
cy.task('startMockServer', [postUsersSignupAlreadyUsedHandler])
cy.get('#error-name').should('not.exist')
cy.get('#error-email').should('not.exist')
cy.get('#error-password').should('not.exist')
cy.get('[data-cy=input-name]').type(userExample.name)
cy.get('[data-cy=input-email]').type(userExample.email)
cy.get('[data-cy=input-password]').type('randompassword')
cy.get('[data-cy=submit]').click()
cy.get('#message').should('have.text', 'Error: Name or Email already used.')
cy.get('#error-name').should('not.exist')
cy.get('#error-email').should('not.exist')
cy.get('#error-password').should('not.exist')
it("should fails with name or email already used", () => {
cy.task("startMockServer", [postUsersSignupAlreadyUsedHandler])
cy.get("#error-name").should("not.exist")
cy.get("#error-email").should("not.exist")
cy.get("#error-password").should("not.exist")
cy.get("[data-cy=input-name]").type(userExample.name)
cy.get("[data-cy=input-email]").type(userExample.email)
cy.get("[data-cy=input-password]").type("randompassword")
cy.get("[data-cy=submit]").click()
cy.get("#message").should("have.text", "Error: Name or Email already used.")
cy.get("#error-name").should("not.exist")
cy.get("#error-email").should("not.exist")
cy.get("#error-password").should("not.exist")
})
it('should fails with unreachable api server', () => {
cy.get('#error-name').should('not.exist')
cy.get('#error-email').should('not.exist')
cy.get('#error-password').should('not.exist')
cy.get('[data-cy=input-name]').type(userExample.name)
cy.get('[data-cy=input-email]').type(userExample.email)
cy.get('[data-cy=input-password]').type('randompassword')
cy.get('[data-cy=submit]').click()
cy.get('#message').should('have.text', 'Error: Internal Server Error.')
cy.get('#error-name').should('not.exist')
cy.get('#error-email').should('not.exist')
cy.get('#error-password').should('not.exist')
it("should fails with unreachable api server", () => {
cy.get("#error-name").should("not.exist")
cy.get("#error-email").should("not.exist")
cy.get("#error-password").should("not.exist")
cy.get("[data-cy=input-name]").type(userExample.name)
cy.get("[data-cy=input-email]").type(userExample.email)
cy.get("[data-cy=input-password]").type("randompassword")
cy.get("[data-cy=submit]").click()
cy.get("#message").should("have.text", "Error: Internal Server Error.")
cy.get("#error-name").should("not.exist")
cy.get("#error-email").should("not.exist")
cy.get("#error-password").should("not.exist")
})
it('should fails with all inputs as required with error messages and update error messages when updating language (translation)', () => {
it("should fails with all inputs as required with error messages and update error messages when updating language (translation)", () => {
const requiredErrorMessage = {
en: 'Error: Oops, this field is required 🙈.',
fr: 'Erreur: Oups, ce champ est obligatoire 🙈.'
en: "Error: Oops, this field is required 🙈.",
fr: "Erreur: Oups, ce champ est obligatoire 🙈.",
}
cy.get('#error-name').should('not.exist')
cy.get('#error-email').should('not.exist')
cy.get('#error-password').should('not.exist')
cy.get('[data-cy=submit]').click()
cy.get('#error-name').should('have.text', requiredErrorMessage.en)
cy.get('#error-email').should('have.text', requiredErrorMessage.en)
cy.get('#error-password').should('have.text', requiredErrorMessage.en)
cy.get('[data-cy=language-click]').click()
cy.get('[data-cy=languages-list] > li:first-child').contains('FR').click()
cy.get('#error-name').should('have.text', requiredErrorMessage.fr)
cy.get('#error-email').should('have.text', requiredErrorMessage.fr)
cy.get('#error-password').should('have.text', requiredErrorMessage.fr)
cy.get("#error-name").should("not.exist")
cy.get("#error-email").should("not.exist")
cy.get("#error-password").should("not.exist")
cy.get("[data-cy=submit]").click()
cy.get("#error-name").should("have.text", requiredErrorMessage.en)
cy.get("#error-email").should("have.text", requiredErrorMessage.en)
cy.get("#error-password").should("have.text", requiredErrorMessage.en)
cy.get("[data-cy=language-click]").click()
cy.get("[data-cy=languages-list] > li:first-child").contains("FR").click()
cy.get("#error-name").should("have.text", requiredErrorMessage.fr)
cy.get("#error-email").should("have.text", requiredErrorMessage.fr)
cy.get("#error-password").should("have.text", requiredErrorMessage.fr)
})
it('should fails with wrong email format', () => {
cy.get('#error-email').should('not.exist')
cy.get('[data-cy=input-email]').type('test')
cy.get('[data-cy=submit]').click()
cy.get('#error-email').should(
'have.text',
'Error: Mmm… It seems that this email is not valid 🤔.'
it("should fails with wrong email format", () => {
cy.get("#error-email").should("not.exist")
cy.get("[data-cy=input-email]").type("test")
cy.get("[data-cy=submit]").click()
cy.get("#error-email").should(
"have.text",
"Error: Mmm… It seems that this email is not valid 🤔.",
)
})
})