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,10 +1,10 @@
describe('Page > /404', () => {
describe("Page > /404", () => {
beforeEach(() => {
cy.visit('/404', { failOnStatusCode: false })
cy.visit("/404", { failOnStatusCode: false })
})
it('should display the statusCode of 404', () => {
cy.get('[data-cy=status-code]').contains('404')
it("should display the statusCode of 404", () => {
cy.get("[data-cy=status-code]").contains("404")
})
})

View File

@ -1,10 +1,10 @@
describe('Page > /500', () => {
describe("Page > /500", () => {
beforeEach(() => {
cy.visit('/500', { failOnStatusCode: false })
cy.visit("/500", { failOnStatusCode: false })
})
it('should display the statusCode of 500', () => {
cy.get('[data-cy=status-code]').contains('500')
it("should display the statusCode of 500", () => {
cy.get("[data-cy=status-code]").contains("500")
})
})

View File

@ -1,122 +1,122 @@
import date from 'date-and-time'
import date from "date-and-time"
import {
channelExample,
channelExample2
} from '../../../../../fixtures/channels/channel'
import { guildExample } from '../../../../../fixtures/guilds/guild'
channelExample2,
} from "../../../../../fixtures/channels/channel"
import { guildExample } from "../../../../../fixtures/guilds/guild"
import {
getGuildMemberNotOwnerWithGuildIdHandler,
getGuildMemberWithGuildIdHandler
} from '../../../../../fixtures/guilds/[guildId]/get'
import { getChannelWithChannelIdHandler } from '../../../../../fixtures/channels/[channelId]/get'
import { authenticationHandlers } from '../../../../../fixtures/handler'
import { getGuildsHandler } from '../../../../../fixtures/guilds/get'
import { getChannelsWithGuildIdHandler } from '../../../../../fixtures/guilds/[guildId]/channels/get'
import { getMessagesWithChannelIdHandler } from '../../../../../fixtures/channels/[channelId]/messages/get'
getGuildMemberWithGuildIdHandler,
} from "../../../../../fixtures/guilds/[guildId]/get"
import { getChannelWithChannelIdHandler } from "../../../../../fixtures/channels/[channelId]/get"
import { authenticationHandlers } from "../../../../../fixtures/handler"
import { getGuildsHandler } from "../../../../../fixtures/guilds/get"
import { getChannelsWithGuildIdHandler } from "../../../../../fixtures/guilds/[guildId]/channels/get"
import { getMessagesWithChannelIdHandler } from "../../../../../fixtures/channels/[channelId]/messages/get"
import {
messageExampleComplete,
messageExampleComplete2
} from '../../../../../fixtures/messages/message'
import { getMembersWithGuildIdHandler } from '../../../../../fixtures/guilds/[guildId]/members/get'
import { memberExampleComplete } from '../../../../../fixtures/members/member'
import { API_URL } from '../../../../../../tools/api'
messageExampleComplete2,
} from "../../../../../fixtures/messages/message"
import { getMembersWithGuildIdHandler } from "../../../../../fixtures/guilds/[guildId]/members/get"
import { memberExampleComplete } from "../../../../../fixtures/members/member"
import { API_URL } from "../../../../../../tools/api"
import {
getMessagesUploadsAudioHandler,
getMessagesUploadsDownloadHandler,
getMessagesUploadsImageHandler,
getMessagesUploadsVideoHandler
} from '../../../../../fixtures/uploads/messages/get'
getMessagesUploadsVideoHandler,
} from "../../../../../fixtures/uploads/messages/get"
describe('Pages > /application/[guildId]/[channelId]', () => {
describe("Pages > /application/[guildId]/[channelId]", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.task("stopMockServer")
})
it('should succeeds and display the left sidebar correctly (member is owner)', () => {
cy.task('startMockServer', [
it("should succeeds and display the left sidebar correctly (member is owner)", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler,
getChannelWithChannelIdHandler,
getGuildsHandler
]).setCookie('refreshToken', 'refresh-token')
cy.intercept(`${API_URL}${getGuildsHandler.url}*`).as('getGuildsHandler')
getGuildsHandler,
]).setCookie("refreshToken", "refresh-token")
cy.intercept(`${API_URL}${getGuildsHandler.url}*`).as("getGuildsHandler")
cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
cy.wait(['@getGuildsHandler']).then(() => {
cy.get('[data-cy=application-title]').should(
'have.text',
`# ${channelExample.name}`
cy.wait(["@getGuildsHandler"]).then(() => {
cy.get("[data-cy=application-title]").should(
"have.text",
`# ${channelExample.name}`,
)
cy.get('[data-cy=guild-left-sidebar-title]').should(
'have.text',
guildExample.name
cy.get("[data-cy=guild-left-sidebar-title]").should(
"have.text",
guildExample.name,
)
cy.get('.guilds-list').children().should('have.length', 2)
cy.get('[data-cy=link-add-channel]')
.should('be.visible')
cy.get(".guilds-list").children().should("have.length", 2)
cy.get("[data-cy=link-add-channel]")
.should("be.visible")
.should(
'have.attr',
'href',
`/application/${guildExample.id}/channels/create`
"have.attr",
"href",
`/application/${guildExample.id}/channels/create`,
)
cy.get('[data-cy=link-settings-guild]')
.should('be.visible')
.should('have.attr', 'href', `/application/${guildExample.id}/settings`)
cy.get("[data-cy=link-settings-guild]")
.should("be.visible")
.should("have.attr", "href", `/application/${guildExample.id}/settings`)
})
})
it('should succeeds and display the left sidebar correctly (member is not owner)', () => {
cy.task('startMockServer', [
it("should succeeds and display the left sidebar correctly (member is not owner)", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberNotOwnerWithGuildIdHandler,
getChannelWithChannelIdHandler,
getGuildsHandler
]).setCookie('refreshToken', 'refresh-token')
cy.intercept(`${API_URL}${getGuildsHandler.url}*`).as('getGuildsHandler')
getGuildsHandler,
]).setCookie("refreshToken", "refresh-token")
cy.intercept(`${API_URL}${getGuildsHandler.url}*`).as("getGuildsHandler")
cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
cy.wait(['@getGuildsHandler']).then(() => {
cy.get('[data-cy=application-title]').should(
'have.text',
`# ${channelExample.name}`
cy.wait(["@getGuildsHandler"]).then(() => {
cy.get("[data-cy=application-title]").should(
"have.text",
`# ${channelExample.name}`,
)
cy.get('[data-cy=guild-left-sidebar-title]').should(
'have.text',
guildExample.name
cy.get("[data-cy=guild-left-sidebar-title]").should(
"have.text",
guildExample.name,
)
cy.get('.guilds-list').children().should('have.length', 2)
cy.get('[data-cy=link-add-channel]').should('not.exist')
cy.get('[data-cy=link-settings-guild]')
.should('be.visible')
.should('have.attr', 'href', `/application/${guildExample.id}/settings`)
cy.get(".guilds-list").children().should("have.length", 2)
cy.get("[data-cy=link-add-channel]").should("not.exist")
cy.get("[data-cy=link-settings-guild]")
.should("be.visible")
.should("have.attr", "href", `/application/${guildExample.id}/settings`)
})
})
it('should succeeds and display the channels in left sidebar correctly', () => {
cy.task('startMockServer', [
it("should succeeds and display the channels in left sidebar correctly", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler,
getChannelWithChannelIdHandler,
getChannelsWithGuildIdHandler
]).setCookie('refreshToken', 'refresh-token')
getChannelsWithGuildIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.intercept(`${API_URL}${getChannelsWithGuildIdHandler.url}*`).as(
'getChannelsWithGuildIdHandler'
"getChannelsWithGuildIdHandler",
)
cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
cy.wait(['@getChannelsWithGuildIdHandler']).then(() => {
cy.get('.channels-list').children().should('have.length', 2)
cy.get('.channels-list [data-cy=channel-name]:first').should(
'have.text',
`# ${channelExample.name}`
cy.wait(["@getChannelsWithGuildIdHandler"]).then(() => {
cy.get(".channels-list").children().should("have.length", 2)
cy.get(".channels-list [data-cy=channel-name]:first").should(
"have.text",
`# ${channelExample.name}`,
)
cy.get('.channels-list [data-cy=channel-name]:last').should(
'have.text',
`# ${channelExample2.name}`
cy.get(".channels-list [data-cy=channel-name]:last").should(
"have.text",
`# ${channelExample2.name}`,
)
})
})
it('should succeeds and display the messages correctly', () => {
cy.task('startMockServer', [
it("should succeeds and display the messages correctly", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler,
getChannelWithChannelIdHandler,
@ -124,147 +124,147 @@ describe('Pages > /application/[guildId]/[channelId]', () => {
getMessagesUploadsImageHandler,
getMessagesUploadsAudioHandler,
getMessagesUploadsVideoHandler,
getMessagesUploadsDownloadHandler
]).setCookie('refreshToken', 'refresh-token')
getMessagesUploadsDownloadHandler,
]).setCookie("refreshToken", "refresh-token")
cy.intercept(`${API_URL}${getMessagesWithChannelIdHandler.url}*`).as(
'getMessagesWithChannelIdHandler'
"getMessagesWithChannelIdHandler",
)
cy.intercept(`${API_URL}${getMessagesUploadsImageHandler.url}`).as(
'getMessagesUploadsImageHandler'
"getMessagesUploadsImageHandler",
)
cy.intercept(`${API_URL}${getMessagesUploadsAudioHandler.url}`).as(
'getMessagesUploadsAudioHandler'
"getMessagesUploadsAudioHandler",
)
cy.intercept(`${API_URL}${getMessagesUploadsVideoHandler.url}`).as(
'getMessagesUploadsVideoHandler'
"getMessagesUploadsVideoHandler",
)
cy.intercept(`${API_URL}${getMessagesUploadsDownloadHandler.url}`).as(
'getMessagesUploadsDownloadHandler'
"getMessagesUploadsDownloadHandler",
)
cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
cy.wait([
'@getMessagesWithChannelIdHandler',
'@getMessagesUploadsImageHandler',
'@getMessagesUploadsAudioHandler',
'@getMessagesUploadsVideoHandler',
'@getMessagesUploadsDownloadHandler'
"@getMessagesWithChannelIdHandler",
"@getMessagesUploadsImageHandler",
"@getMessagesUploadsAudioHandler",
"@getMessagesUploadsVideoHandler",
"@getMessagesUploadsDownloadHandler",
]).then(() => {
cy.get('.messages-list').children().should('have.length', 9)
cy.get('[data-cy=message-1] p').should(
'have.text',
messageExampleComplete.value
cy.get(".messages-list").children().should("have.length", 9)
cy.get("[data-cy=message-1] p").should(
"have.text",
messageExampleComplete.value,
)
cy.get('[data-cy=message-1] [data-cy=message-member-user-name]').should(
'have.text',
messageExampleComplete.member.user.name
cy.get("[data-cy=message-1] [data-cy=message-member-user-name]").should(
"have.text",
messageExampleComplete.member.user.name,
)
cy.get('[data-cy=message-1] [data-cy=message-date]').should(
'have.text',
cy.get("[data-cy=message-1] [data-cy=message-date]").should(
"have.text",
date.format(
new Date(messageExampleComplete.createdAt),
'DD/MM/YYYY - HH:mm:ss'
)
"DD/MM/YYYY - HH:mm:ss",
),
)
cy.get('[data-cy=message-2] p').should(
'have.text',
messageExampleComplete2.value
cy.get("[data-cy=message-2] p").should(
"have.text",
messageExampleComplete2.value,
)
cy.get('[data-cy=message-3] p').should(
'have.text',
'Message with bold text and italic text.\nNewlines and some emoji: '
cy.get("[data-cy=message-3] p").should(
"have.text",
"Message with bold text and italic text.\nNewlines and some emoji: ",
)
cy.get('[data-cy=message-3] strong').should('have.text', 'bold text')
cy.get('[data-cy=message-3] em').should('have.text', 'italic text')
cy.get('[data-cy=message-3] span[title=smile]').should('exist')
cy.get('[data-cy=message-3] span[title=smile]').should(
'have.css',
'width',
'20px'
cy.get("[data-cy=message-3] strong").should("have.text", "bold text")
cy.get("[data-cy=message-3] em").should("have.text", "italic text")
cy.get("[data-cy=message-3] span[title=smile]").should("exist")
cy.get("[data-cy=message-3] span[title=smile]").should(
"have.css",
"width",
"20px",
)
cy.get('[data-cy=message-3] span[title=smile]').should(
'have.css',
'height',
'20px'
cy.get("[data-cy=message-3] span[title=smile]").should(
"have.css",
"height",
"20px",
)
cy.get('[data-cy=message-4] p:first').should(
'have.text',
'The Quadratic Formula:'
cy.get("[data-cy=message-4] p:first").should(
"have.text",
"The Quadratic Formula:",
)
cy.get('[data-cy=message-4] .math').should('have.length', 3)
cy.get('[data-cy=message-5] span[title=wave]').should('exist')
cy.get('[data-cy=message-5] span[title=wave]').should(
'have.css',
'width',
'40px'
cy.get("[data-cy=message-4] .math").should("have.length", 3)
cy.get("[data-cy=message-5] span[title=wave]").should("exist")
cy.get("[data-cy=message-5] span[title=wave]").should(
"have.css",
"width",
"40px",
)
cy.get('[data-cy=message-5] span[title=wave]').should(
'have.css',
'height',
'40px'
cy.get("[data-cy=message-5] span[title=wave]").should(
"have.css",
"height",
"40px",
)
cy.get('[data-cy=message-file-image-6]').should('exist')
cy.get('[data-cy=message-file-audio-7]').should('exist')
cy.get('[data-cy=message-file-video-8]').should('exist')
cy.get('[data-cy=message-file-download-9]').should('exist')
cy.get("[data-cy=message-file-image-6]").should("exist")
cy.get("[data-cy=message-file-audio-7]").should("exist")
cy.get("[data-cy=message-file-video-8]").should("exist")
cy.get("[data-cy=message-file-download-9]").should("exist")
})
})
it('should succeeds and display the members in right sidebar correctly', () => {
cy.task('startMockServer', [
it("should succeeds and display the members in right sidebar correctly", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler,
getChannelWithChannelIdHandler,
getMembersWithGuildIdHandler
]).setCookie('refreshToken', 'refresh-token')
getMembersWithGuildIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.intercept(`${API_URL}${getMembersWithGuildIdHandler.url}*`).as(
'getMembersWithGuildIdHandler'
"getMembersWithGuildIdHandler",
)
cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
cy.wait(['@getMembersWithGuildIdHandler']).then(() => {
cy.get('.members-list').should('not.be.visible')
cy.get('[data-cy=icon-button-right-sidebar-members]').click()
cy.get('.members-list').should('be.visible')
cy.get('[data-cy=members-title]').should('have.text', 'Member(s)')
cy.get('.members-list').children().should('have.length', 1)
cy.get('.members-list [data-cy=member-user-name]:first').should(
'have.text',
memberExampleComplete.user.name
cy.wait(["@getMembersWithGuildIdHandler"]).then(() => {
cy.get(".members-list").should("not.be.visible")
cy.get("[data-cy=icon-button-right-sidebar-members]").click()
cy.get(".members-list").should("be.visible")
cy.get("[data-cy=members-title]").should("have.text", "Member(s)")
cy.get(".members-list").children().should("have.length", 1)
cy.get(".members-list [data-cy=member-user-name]:first").should(
"have.text",
memberExampleComplete.user.name,
)
})
})
it('should redirect the user to `/404` if `guildId` or `channelId` are not numbers', () => {
cy.task('startMockServer', authenticationHandlers).setCookie(
'refreshToken',
'refresh-token'
it("should redirect the user to `/404` if `guildId` or `channelId` are not numbers", () => {
cy.task("startMockServer", authenticationHandlers).setCookie(
"refreshToken",
"refresh-token",
)
cy.visit('/application/abc/abc', {
failOnStatusCode: false
cy.visit("/application/abc/abc", {
failOnStatusCode: false,
})
.get('[data-cy=status-code]')
.contains('404')
.get("[data-cy=status-code]")
.contains("404")
})
it("should redirect the user to `/404` if `guildId` doesn't exist", () => {
cy.task('startMockServer', [
cy.task("startMockServer", [
...authenticationHandlers,
getChannelWithChannelIdHandler
]).setCookie('refreshToken', 'refresh-token')
getChannelWithChannelIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.visit(`/application/123/${channelExample.id}`, {
failOnStatusCode: false
failOnStatusCode: false,
})
.get('[data-cy=status-code]')
.contains('404')
.get("[data-cy=status-code]")
.contains("404")
})
it("should redirect the user to `/404` if `channelId` doesn't exist", () => {
cy.task('startMockServer', [
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler
]).setCookie('refreshToken', 'refresh-token')
getGuildMemberWithGuildIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.visit(`/application/${guildExample.id}/123`, { failOnStatusCode: false })
.get('[data-cy=status-code]')
.contains('404')
.get("[data-cy=status-code]")
.contains("404")
})
})

View File

@ -1,135 +1,135 @@
import { deleteChannelWithChannelIdHandler } from '../../../../../fixtures/channels/[channelId]/delete'
import { putChannelWithChannelIdHandler } from '../../../../../fixtures/channels/[channelId]/put'
import { deleteChannelWithChannelIdHandler } from "../../../../../fixtures/channels/[channelId]/delete"
import { putChannelWithChannelIdHandler } from "../../../../../fixtures/channels/[channelId]/put"
import {
channelExample,
channelExample2
} from '../../../../../fixtures/channels/channel'
import { guildExample } from '../../../../../fixtures/guilds/guild'
channelExample2,
} from "../../../../../fixtures/channels/channel"
import { guildExample } from "../../../../../fixtures/guilds/guild"
import {
getGuildMemberNotOwnerWithGuildIdHandler,
getGuildMemberWithGuildIdHandler
} from '../../../../../fixtures/guilds/[guildId]/get'
getGuildMemberWithGuildIdHandler,
} from "../../../../../fixtures/guilds/[guildId]/get"
import {
getChannelWithChannelIdHandler,
getChannelWithChannelIdHandler2
} from '../../../../../fixtures/channels/[channelId]/get'
import { authenticationHandlers } from '../../../../../fixtures/handler'
import { API_URL } from '../../../../../../tools/api'
getChannelWithChannelIdHandler2,
} from "../../../../../fixtures/channels/[channelId]/get"
import { authenticationHandlers } from "../../../../../fixtures/handler"
import { API_URL } from "../../../../../../tools/api"
describe('Pages > /application/[guildId]/[channelId]/settings', () => {
describe("Pages > /application/[guildId]/[channelId]/settings", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.task("stopMockServer")
})
it('should succeeds and update the channel name', () => {
cy.task('startMockServer', [
it("should succeeds and update the channel name", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler,
getChannelWithChannelIdHandler,
putChannelWithChannelIdHandler
]).setCookie('refreshToken', 'refresh-token')
putChannelWithChannelIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.intercept(`${API_URL}${putChannelWithChannelIdHandler.url}*`).as(
'putChannelWithChannelIdHandler'
"putChannelWithChannelIdHandler",
)
cy.visit(`/application/${guildExample.id}/${channelExample.id}/settings`)
cy.get('[data-cy=channel-name-input]')
cy.get("[data-cy=channel-name-input]")
.clear()
.type(putChannelWithChannelIdHandler.response.body.name)
cy.get('[data-cy=button-save-channel-settings]').click()
cy.wait('@putChannelWithChannelIdHandler').then(() => {
cy.location('pathname').should(
'eq',
`/application/${guildExample.id}/${channelExample.id}`
cy.get("[data-cy=button-save-channel-settings]").click()
cy.wait("@putChannelWithChannelIdHandler").then(() => {
cy.location("pathname").should(
"eq",
`/application/${guildExample.id}/${channelExample.id}`,
)
})
})
it('should succeeds and delete the channel', () => {
cy.task('startMockServer', [
it("should succeeds and delete the channel", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler,
getChannelWithChannelIdHandler,
getChannelWithChannelIdHandler2,
deleteChannelWithChannelIdHandler
]).setCookie('refreshToken', 'refresh-token')
deleteChannelWithChannelIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.intercept(`${API_URL}${deleteChannelWithChannelIdHandler.url}*`).as(
'deleteChannelWithChannelIdHandler'
"deleteChannelWithChannelIdHandler",
)
cy.visit(`/application/${guildExample.id}/${channelExample.id}/settings`)
cy.get('[data-cy=button-delete-channel-settings]').click()
cy.get('[data-cy=confirm-popup-yes-button]').click()
cy.wait('@deleteChannelWithChannelIdHandler').then(() => {
cy.location('pathname').should(
'eq',
`/application/${guildExample.id}/${channelExample2.id}`
cy.get("[data-cy=button-delete-channel-settings]").click()
cy.get("[data-cy=confirm-popup-yes-button]").click()
cy.wait("@deleteChannelWithChannelIdHandler").then(() => {
cy.location("pathname").should(
"eq",
`/application/${guildExample.id}/${channelExample2.id}`,
)
})
})
it('should fails with too long channel name on update', () => {
cy.task('startMockServer', [
it("should fails with too long channel name on update", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler,
getChannelWithChannelIdHandler
]).setCookie('refreshToken', 'refresh-token')
getChannelWithChannelIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.visit(`/application/${guildExample.id}/${channelExample.id}/settings`)
cy.get('[data-cy=channel-name-input]').type(
'random channel name that is really too long for a channel name'
cy.get("[data-cy=channel-name-input]").type(
"random channel name that is really too long for a channel name",
)
cy.get('[data-cy=button-save-channel-settings]').click()
cy.get('#error-name').should(
'have.text',
'Error: The field must contain at most 20 characters.'
cy.get("[data-cy=button-save-channel-settings]").click()
cy.get("#error-name").should(
"have.text",
"Error: The field must contain at most 20 characters.",
)
})
it('should redirect the user to `/404` if member is not owner', () => {
cy.task('startMockServer', [
it("should redirect the user to `/404` if member is not owner", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberNotOwnerWithGuildIdHandler,
getChannelWithChannelIdHandler
]).setCookie('refreshToken', 'refresh-token')
getChannelWithChannelIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.visit(`/application/${guildExample.id}/${channelExample.id}/settings`, {
failOnStatusCode: false
failOnStatusCode: false,
})
.get('[data-cy=status-code]')
.contains('404')
.get("[data-cy=status-code]")
.contains("404")
})
it('should redirect the user to `/404` if `guildId` or `channelId` are not numbers', () => {
cy.task('startMockServer', authenticationHandlers).setCookie(
'refreshToken',
'refresh-token'
it("should redirect the user to `/404` if `guildId` or `channelId` are not numbers", () => {
cy.task("startMockServer", authenticationHandlers).setCookie(
"refreshToken",
"refresh-token",
)
cy.visit('/application/abc/abc/settings', {
failOnStatusCode: false
cy.visit("/application/abc/abc/settings", {
failOnStatusCode: false,
})
.get('[data-cy=status-code]')
.contains('404')
.get("[data-cy=status-code]")
.contains("404")
})
it("should redirect the user to `/404` if `guildId` doesn't exist", () => {
cy.task('startMockServer', [
cy.task("startMockServer", [
...authenticationHandlers,
getChannelWithChannelIdHandler
]).setCookie('refreshToken', 'refresh-token')
getChannelWithChannelIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.visit(`/application/123/${channelExample.id}/settings`, {
failOnStatusCode: false
failOnStatusCode: false,
})
.get('[data-cy=status-code]')
.contains('404')
.get("[data-cy=status-code]")
.contains("404")
})
it("should redirect the user to `/404` if `channelId` doesn't exist", () => {
cy.task('startMockServer', [
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler
]).setCookie('refreshToken', 'refresh-token')
getGuildMemberWithGuildIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.visit(`/application/${guildExample.id}/123/settings`, {
failOnStatusCode: false
failOnStatusCode: false,
})
.get('[data-cy=status-code]')
.contains('404')
.get("[data-cy=status-code]")
.contains("404")
})
})

View File

@ -1,75 +1,75 @@
import { postChannelsWithGuildIdHandler } from '../../../../../fixtures/guilds/[guildId]/channels/post'
import { API_URL } from '../../../../../../tools/api'
import { channelExample2 } from '../../../../../fixtures/channels/channel'
import { guildExample } from '../../../../../fixtures/guilds/guild'
import { getGuildMemberWithGuildIdHandler } from '../../../../../fixtures/guilds/[guildId]/get'
import { authenticationHandlers } from '../../../../../fixtures/handler'
import { getChannelWithChannelIdHandler2 } from '../../../../../fixtures/channels/[channelId]/get'
import { postChannelsWithGuildIdHandler } from "../../../../../fixtures/guilds/[guildId]/channels/post"
import { API_URL } from "../../../../../../tools/api"
import { channelExample2 } from "../../../../../fixtures/channels/channel"
import { guildExample } from "../../../../../fixtures/guilds/guild"
import { getGuildMemberWithGuildIdHandler } from "../../../../../fixtures/guilds/[guildId]/get"
import { authenticationHandlers } from "../../../../../fixtures/handler"
import { getChannelWithChannelIdHandler2 } from "../../../../../fixtures/channels/[channelId]/get"
describe('Pages > /application/[guildId]/channels/create', () => {
describe("Pages > /application/[guildId]/channels/create", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.task("stopMockServer")
})
it('should succeeds and create the channel', () => {
cy.task('startMockServer', [
it("should succeeds and create the channel", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler,
postChannelsWithGuildIdHandler,
getChannelWithChannelIdHandler2
]).setCookie('refreshToken', 'refresh-token')
getChannelWithChannelIdHandler2,
]).setCookie("refreshToken", "refresh-token")
cy.intercept(`${API_URL}${postChannelsWithGuildIdHandler.url}*`).as(
'postChannelsWithGuildIdHandler'
"postChannelsWithGuildIdHandler",
)
cy.visit(`/application/${guildExample.id}/channels/create`)
cy.get('[data-cy=channel-name-input]').type(channelExample2.name)
cy.get('[data-cy=button-create-channel]').click()
cy.wait('@postChannelsWithGuildIdHandler').then(() => {
cy.location('pathname').should(
'eq',
`/application/${guildExample.id}/${channelExample2.id}`
cy.get("[data-cy=channel-name-input]").type(channelExample2.name)
cy.get("[data-cy=button-create-channel]").click()
cy.wait("@postChannelsWithGuildIdHandler").then(() => {
cy.location("pathname").should(
"eq",
`/application/${guildExample.id}/${channelExample2.id}`,
)
})
})
it('should fails with too long channel name on update', () => {
cy.task('startMockServer', [
it("should fails with too long channel name on update", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler
]).setCookie('refreshToken', 'refresh-token')
getGuildMemberWithGuildIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.visit(`/application/${guildExample.id}/channels/create`)
cy.get('[data-cy=channel-name-input]').type(
'random channel name that is really too long for a channel name'
cy.get("[data-cy=channel-name-input]").type(
"random channel name that is really too long for a channel name",
)
cy.get('[data-cy=button-create-channel]').click()
cy.get('#error-name').should(
'have.text',
'Error: The field must contain at most 20 characters.'
cy.get("[data-cy=button-create-channel]").click()
cy.get("#error-name").should(
"have.text",
"Error: The field must contain at most 20 characters.",
)
})
it('should redirect the user to `/404` if `guildId` is not a number', () => {
cy.task('startMockServer', authenticationHandlers).setCookie(
'refreshToken',
'refresh-token'
it("should redirect the user to `/404` if `guildId` is not a number", () => {
cy.task("startMockServer", authenticationHandlers).setCookie(
"refreshToken",
"refresh-token",
)
cy.visit('/application/abc/channels/create', {
failOnStatusCode: false
cy.visit("/application/abc/channels/create", {
failOnStatusCode: false,
})
.get('[data-cy=status-code]')
.contains('404')
.get("[data-cy=status-code]")
.contains("404")
})
it("should redirect the user to `/404` if `guildId` doesn't exist", () => {
cy.task('startMockServer', [...authenticationHandlers]).setCookie(
'refreshToken',
'refresh-token'
cy.task("startMockServer", [...authenticationHandlers]).setCookie(
"refreshToken",
"refresh-token",
)
cy.visit(`/application/123/channels/create`, {
failOnStatusCode: false
failOnStatusCode: false,
})
.get('[data-cy=status-code]')
.contains('404')
.get("[data-cy=status-code]")
.contains("404")
})
})

View File

@ -1,76 +1,76 @@
import { deleteLeaveMembersWithGuildIdHandler } from '../../../../fixtures/guilds/[guildId]/members/leave'
import { guildExample } from '../../../../fixtures/guilds/guild'
import { deleteLeaveMembersWithGuildIdHandler } from "../../../../fixtures/guilds/[guildId]/members/leave"
import { guildExample } from "../../../../fixtures/guilds/guild"
import {
getGuildMemberNotOwnerWithGuildIdHandler,
getGuildMemberWithGuildIdHandler
} from '../../../../fixtures/guilds/[guildId]/get'
import { authenticationHandlers } from '../../../../fixtures/handler'
import { API_URL } from '../../../../../tools/api'
import { deleteGuildWithGuildIdHandler } from '../../../../fixtures/guilds/[guildId]/delete'
getGuildMemberWithGuildIdHandler,
} from "../../../../fixtures/guilds/[guildId]/get"
import { authenticationHandlers } from "../../../../fixtures/handler"
import { API_URL } from "../../../../../tools/api"
import { deleteGuildWithGuildIdHandler } from "../../../../fixtures/guilds/[guildId]/delete"
describe('Pages > /application/[guildId]/settings', () => {
describe("Pages > /application/[guildId]/settings", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.task("stopMockServer")
})
it('should succeeds and display correctly the settings of the guild (member is owner)', () => {
cy.task('startMockServer', [
it("should succeeds and display correctly the settings of the guild (member is owner)", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler
]).setCookie('refreshToken', 'refresh-token')
getGuildMemberWithGuildIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.visit(`/application/${guildExample.id}/settings`)
cy.get('[data-cy=guild-name-input]').should('have.value', guildExample.name)
cy.get('[data-cy=guild-description-input]').should(
'have.value',
guildExample.description
cy.get("[data-cy=guild-name-input]").should("have.value", guildExample.name)
cy.get("[data-cy=guild-description-input]").should(
"have.value",
guildExample.description,
)
cy.get('[data-cy=button-save-guild-settings]').should('be.visible')
cy.get('[data-cy=button-delete-guild-settings]').should('be.visible')
cy.get('[data-cy=button-leave-guild-settings]').should('not.exist')
cy.get("[data-cy=button-save-guild-settings]").should("be.visible")
cy.get("[data-cy=button-delete-guild-settings]").should("be.visible")
cy.get("[data-cy=button-leave-guild-settings]").should("not.exist")
})
it('should succeeds and display correctly the settings of the guild (member is not owner)', () => {
cy.task('startMockServer', [
...authenticationHandlers,
getGuildMemberNotOwnerWithGuildIdHandler
]).setCookie('refreshToken', 'refresh-token')
cy.visit(`/application/${guildExample.id}/settings`)
cy.get('[data-cy=guild-name-input]').should('not.exist')
cy.get('[data-cy=guild-description-input]').should('not.exist')
cy.get('[data-cy=button-save-guild-settings]').should('not.exist')
cy.get('[data-cy=button-delete-guild-settings]').should('not.exist')
cy.get('[data-cy=button-leave-guild-settings]').should('be.visible')
})
it('should succeeds and leave the guild (member is not owner)', () => {
cy.task('startMockServer', [
it("should succeeds and display correctly the settings of the guild (member is not owner)", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberNotOwnerWithGuildIdHandler,
deleteLeaveMembersWithGuildIdHandler
]).setCookie('refreshToken', 'refresh-token')
]).setCookie("refreshToken", "refresh-token")
cy.visit(`/application/${guildExample.id}/settings`)
cy.get("[data-cy=guild-name-input]").should("not.exist")
cy.get("[data-cy=guild-description-input]").should("not.exist")
cy.get("[data-cy=button-save-guild-settings]").should("not.exist")
cy.get("[data-cy=button-delete-guild-settings]").should("not.exist")
cy.get("[data-cy=button-leave-guild-settings]").should("be.visible")
})
it("should succeeds and leave the guild (member is not owner)", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberNotOwnerWithGuildIdHandler,
deleteLeaveMembersWithGuildIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.intercept(`${API_URL}${deleteLeaveMembersWithGuildIdHandler.url}*`).as(
'deleteLeaveMembersWithGuildIdHandler'
"deleteLeaveMembersWithGuildIdHandler",
)
cy.visit(`/application/${guildExample.id}/settings`)
cy.get('[data-cy=button-leave-guild-settings]').click()
cy.wait('@deleteLeaveMembersWithGuildIdHandler').then(() => {
cy.location('pathname').should('eq', '/application')
cy.get("[data-cy=button-leave-guild-settings]").click()
cy.wait("@deleteLeaveMembersWithGuildIdHandler").then(() => {
cy.location("pathname").should("eq", "/application")
})
})
it('should succeeds and delete the guild', () => {
cy.task('startMockServer', [
it("should succeeds and delete the guild", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler,
deleteGuildWithGuildIdHandler
]).setCookie('refreshToken', 'refresh-token')
deleteGuildWithGuildIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.intercept(`${API_URL}${deleteGuildWithGuildIdHandler.url}*`).as(
'deleteGuildWithGuildIdHandler'
"deleteGuildWithGuildIdHandler",
)
cy.visit(`/application/${guildExample.id}/settings`)
cy.get('[data-cy=button-delete-guild-settings]').click()
cy.get('[data-cy=confirm-popup-yes-button]').click()
cy.wait('@deleteGuildWithGuildIdHandler').then((interception) => {
cy.get("[data-cy=button-delete-guild-settings]").click()
cy.get("[data-cy=confirm-popup-yes-button]").click()
cy.wait("@deleteGuildWithGuildIdHandler").then((interception) => {
expect(interception.response).to.not.be.eql(undefined)
if (interception.response !== undefined) {
expect(interception.response.statusCode).to.eq(200)
@ -78,28 +78,28 @@ describe('Pages > /application/[guildId]/settings', () => {
})
})
it('should redirect the user to `/404` if `guildId` is not a number', () => {
cy.task('startMockServer', authenticationHandlers).setCookie(
'refreshToken',
'refresh-token'
it("should redirect the user to `/404` if `guildId` is not a number", () => {
cy.task("startMockServer", authenticationHandlers).setCookie(
"refreshToken",
"refresh-token",
)
cy.visit('/application/abc/settings', {
failOnStatusCode: false
cy.visit("/application/abc/settings", {
failOnStatusCode: false,
})
.get('[data-cy=status-code]')
.contains('404')
.get("[data-cy=status-code]")
.contains("404")
})
it("should redirect the user to `/404` if `guildId` doesn't exist", () => {
cy.task('startMockServer', [...authenticationHandlers]).setCookie(
'refreshToken',
'refresh-token'
cy.task("startMockServer", [...authenticationHandlers]).setCookie(
"refreshToken",
"refresh-token",
)
cy.visit(`/application/123/settings`, {
failOnStatusCode: false
failOnStatusCode: false,
})
.get('[data-cy=status-code]')
.contains('404')
.get("[data-cy=status-code]")
.contains("404")
})
})

View File

@ -1,45 +1,45 @@
import { getChannelWithChannelIdHandler } from '../../../../fixtures/channels/[channelId]/get'
import { getGuildsHandler } from '../../../../fixtures/guilds/get'
import { getGuildMemberWithGuildIdHandler } from '../../../../fixtures/guilds/[guildId]/get'
import { channelExample } from '../../../../fixtures/channels/channel'
import { guildExample } from '../../../../fixtures/guilds/guild'
import { postGuildsHandler } from '../../../../fixtures/guilds/post'
import { authenticationHandlers } from '../../../../fixtures/handler'
import { getChannelWithChannelIdHandler } from "../../../../fixtures/channels/[channelId]/get"
import { getGuildsHandler } from "../../../../fixtures/guilds/get"
import { getGuildMemberWithGuildIdHandler } from "../../../../fixtures/guilds/[guildId]/get"
import { channelExample } from "../../../../fixtures/channels/channel"
import { guildExample } from "../../../../fixtures/guilds/guild"
import { postGuildsHandler } from "../../../../fixtures/guilds/post"
import { authenticationHandlers } from "../../../../fixtures/handler"
describe('Pages > /application/guilds/create', () => {
describe("Pages > /application/guilds/create", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.task("stopMockServer")
})
it('should succeeds and create the guild', () => {
cy.task('startMockServer', [
it("should succeeds and create the guild", () => {
cy.task("startMockServer", [
...authenticationHandlers,
postGuildsHandler,
getGuildsHandler,
getGuildMemberWithGuildIdHandler,
getChannelWithChannelIdHandler
]).setCookie('refreshToken', 'refresh-token')
cy.visit('/application/guilds/create')
cy.get('[data-cy=application-title]').should('have.text', 'Create a Guild')
cy.get('#error-name').should('not.exist')
cy.get('[data-cy=input-name]').type(guildExample.name)
cy.get('[data-cy=submit]').click()
cy.location('pathname').should(
'eq',
`/application/${guildExample.id}/${channelExample.id}`
getChannelWithChannelIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.visit("/application/guilds/create")
cy.get("[data-cy=application-title]").should("have.text", "Create a Guild")
cy.get("#error-name").should("not.exist")
cy.get("[data-cy=input-name]").type(guildExample.name)
cy.get("[data-cy=submit]").click()
cy.location("pathname").should(
"eq",
`/application/${guildExample.id}/${channelExample.id}`,
)
})
it('should fails with internal api server error', () => {
cy.task('startMockServer', [...authenticationHandlers]).setCookie(
'refreshToken',
'refresh-token'
it("should fails with internal api server error", () => {
cy.task("startMockServer", [...authenticationHandlers]).setCookie(
"refreshToken",
"refresh-token",
)
cy.visit('/application/guilds/create')
cy.get('#error-name').should('not.exist')
cy.get('[data-cy=input-name]').type(guildExample.name)
cy.get('[data-cy=submit]').click()
cy.get('#message').should('have.text', 'Error: Internal Server Error.')
cy.visit("/application/guilds/create")
cy.get("#error-name").should("not.exist")
cy.get("[data-cy=input-name]").type(guildExample.name)
cy.get("[data-cy=submit]").click()
cy.get("#message").should("have.text", "Error: Internal Server Error.")
})
})

View File

@ -1,81 +1,81 @@
import { guildExample, guildExample2 } from '../../../../fixtures/guilds/guild'
import { guildExample, guildExample2 } from "../../../../fixtures/guilds/guild"
import {
getGuildsPublicEmptyHandler,
getGuildsPublicHandler,
getGuildsPublicSearchHandler
} from '../../../../fixtures/guilds/public/get'
import { authenticationHandlers } from '../../../../fixtures/handler'
import { API_URL } from '../../../../../tools/api'
getGuildsPublicSearchHandler,
} from "../../../../fixtures/guilds/public/get"
import { authenticationHandlers } from "../../../../fixtures/handler"
import { API_URL } from "../../../../../tools/api"
describe('Pages > /application/guilds/join', () => {
describe("Pages > /application/guilds/join", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.task("stopMockServer")
})
it('should shows all the guilds', () => {
cy.task('startMockServer', [
it("should shows all the guilds", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildsPublicHandler
]).setCookie('refreshToken', 'refresh-token')
getGuildsPublicHandler,
]).setCookie("refreshToken", "refresh-token")
cy.intercept(`${API_URL}${getGuildsPublicHandler.url}*`).as(
'getGuildsPublicHandler'
"getGuildsPublicHandler",
)
cy.visit('/application/guilds/join')
cy.wait(['@getGuildsPublicHandler']).then(() => {
cy.get('[data-cy=application-title]').should('have.text', 'Join a Guild')
cy.get('.guilds-public-list').children().should('have.length', 2)
cy.get('.guilds-public-list [data-cy=guild-name]:first').should(
'have.text',
guildExample.name
cy.visit("/application/guilds/join")
cy.wait(["@getGuildsPublicHandler"]).then(() => {
cy.get("[data-cy=application-title]").should("have.text", "Join a Guild")
cy.get(".guilds-public-list").children().should("have.length", 2)
cy.get(".guilds-public-list [data-cy=guild-name]:first").should(
"have.text",
guildExample.name,
)
cy.get('.guilds-public-list [data-cy=guild-name]:last').should(
'have.text',
guildExample2.name
cy.get(".guilds-public-list [data-cy=guild-name]:last").should(
"have.text",
guildExample2.name,
)
})
})
it('should shows the searched guild', () => {
cy.task('startMockServer', [
it("should shows the searched guild", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildsPublicSearchHandler
]).setCookie('refreshToken', 'refresh-token')
cy.visit('/application/guilds/join')
getGuildsPublicSearchHandler,
]).setCookie("refreshToken", "refresh-token")
cy.visit("/application/guilds/join")
cy.intercept(`${API_URL}${getGuildsPublicHandler.url}*`).as(
'getGuildsPublicHandler'
"getGuildsPublicHandler",
)
cy.wait(['@getGuildsPublicHandler']).then(() => {
cy.get('[data-cy=search-guild-input]').type(guildExample2.name)
cy.get('.guilds-public-list').children().should('have.length', 1)
cy.get('.guilds-public-list [data-cy=guild-name]:first').should(
'have.text',
guildExample2.name
cy.wait(["@getGuildsPublicHandler"]).then(() => {
cy.get("[data-cy=search-guild-input]").type(guildExample2.name)
cy.get(".guilds-public-list").children().should("have.length", 1)
cy.get(".guilds-public-list [data-cy=guild-name]:first").should(
"have.text",
guildExample2.name,
)
})
})
it('should shows no guild if there are no public guilds', () => {
cy.task('startMockServer', [
it("should shows no guild if there are no public guilds", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildsPublicEmptyHandler
]).setCookie('refreshToken', 'refresh-token')
getGuildsPublicEmptyHandler,
]).setCookie("refreshToken", "refresh-token")
cy.intercept(`${API_URL}${getGuildsPublicEmptyHandler.url}*`).as(
'getGuildsPublicEmptyHandler'
"getGuildsPublicEmptyHandler",
)
cy.visit('/application/guilds/join')
cy.wait('@getGuildsPublicEmptyHandler').then(() => {
cy.get('.guilds-public-list').children().should('have.length', 0)
cy.visit("/application/guilds/join")
cy.wait("@getGuildsPublicEmptyHandler").then(() => {
cy.get(".guilds-public-list").children().should("have.length", 0)
})
})
it('should shows loader with internal api server error', () => {
cy.task('startMockServer', [...authenticationHandlers]).setCookie(
'refreshToken',
'refresh-token'
it("should shows loader with internal api server error", () => {
cy.task("startMockServer", [...authenticationHandlers]).setCookie(
"refreshToken",
"refresh-token",
)
cy.visit('/application/guilds/join')
cy.get('.guilds-public-list').children().should('have.length', 1)
cy.get('[data-cy=progress-spinner]').should('be.visible')
cy.visit("/application/guilds/join")
cy.get(".guilds-public-list").children().should("have.length", 1)
cy.get("[data-cy=progress-spinner]").should("be.visible")
})
})

View File

@ -1,33 +1,33 @@
import { authenticationHandlers } from '../../../fixtures/handler'
import { authenticationHandlers } from "../../../fixtures/handler"
describe('Pages > /application', () => {
describe("Pages > /application", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.task("stopMockServer")
})
it('should redirect user to `/application/guilds/create` on click on "Create a Guild"', () => {
cy.task('startMockServer', [...authenticationHandlers]).setCookie(
'refreshToken',
'refresh-token'
cy.task("startMockServer", [...authenticationHandlers]).setCookie(
"refreshToken",
"refresh-token",
)
cy.visit('/application')
cy.get('[data-cy=application-title]').should('have.text', 'Application')
cy.visit("/application")
cy.get("[data-cy=application-title]").should("have.text", "Application")
cy.get('a[href="/application/guilds/create"]')
.click()
.location('pathname')
.should('eq', '/application/guilds/create')
.location("pathname")
.should("eq", "/application/guilds/create")
})
it('should redirect user to `/application/guilds/join` on click on "Join a Guild"', () => {
cy.task('startMockServer', [...authenticationHandlers]).setCookie(
'refreshToken',
'refresh-token'
cy.task("startMockServer", [...authenticationHandlers]).setCookie(
"refreshToken",
"refresh-token",
)
cy.visit('/application')
cy.visit("/application")
cy.get('a[href="/application/guilds/join"]')
.click()
.location('pathname')
.should('eq', '/application/guilds/join')
.location("pathname")
.should("eq", "/application/guilds/join")
})
})

View File

@ -1,36 +1,36 @@
import date from 'date-and-time'
import date from "date-and-time"
import { userExample } from '../../../../../fixtures/users/user'
import { getUserByIdHandler } from '../../../../../fixtures/users/[userId]/get'
import { authenticationHandlers } from '../../../../../fixtures/handler'
import { userExample } from "../../../../../fixtures/users/user"
import { getUserByIdHandler } from "../../../../../fixtures/users/[userId]/get"
import { authenticationHandlers } from "../../../../../fixtures/handler"
describe('Pages > /application/users/[userId]', () => {
describe("Pages > /application/users/[userId]", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.task("stopMockServer")
})
it('should succeeds and display the public user profile correctly', () => {
cy.task('startMockServer', [
it("should succeeds and display the public user profile correctly", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getUserByIdHandler
]).setCookie('refreshToken', 'refresh-token')
getUserByIdHandler,
]).setCookie("refreshToken", "refresh-token")
cy.visit(`/application/users/${userExample.id}`)
cy.get('[data-cy=user-name]').should('have.text', userExample.name)
cy.get('[data-cy=user-email]').should('have.text', userExample.email)
cy.get('[data-cy=user-createdAt]').should(
'have.text',
date.format(new Date(userExample.createdAt), 'DD/MM/YYYY')
cy.get("[data-cy=user-name]").should("have.text", userExample.name)
cy.get("[data-cy=user-email]").should("have.text", userExample.email)
cy.get("[data-cy=user-createdAt]").should(
"have.text",
date.format(new Date(userExample.createdAt), "DD/MM/YYYY"),
)
})
it("should redirect the user to `/404` if `userId` doesn't exist", () => {
cy.task('startMockServer', [...authenticationHandlers]).setCookie(
'refreshToken',
'refresh-token'
cy.task("startMockServer", [...authenticationHandlers]).setCookie(
"refreshToken",
"refresh-token",
)
cy.visit(`/application/users/123`, { failOnStatusCode: false })
.get('[data-cy=status-code]')
.contains('404')
.get("[data-cy=status-code]")
.contains("404")
})
})

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 🤔.",
)
})
})

View File

@ -1,13 +1,13 @@
describe('Page > /', () => {
describe("Page > /", () => {
beforeEach(() => {
cy.visit('/')
cy.visit("/")
})
it('should redirect the user to signup page when clicking "Get started"', () => {
cy.get('[data-cy=get-started]')
cy.get("[data-cy=get-started]")
.click()
.location('pathname')
.should('eq', '/authentication/signup')
.location("pathname")
.should("eq", "/authentication/signup")
})
})