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,18 +1,18 @@
import { isStringWithOnlyOneEmoji } from '../../../../components/Emoji/isStringWithOnlyOneEmoji'
import { isStringWithOnlyOneEmoji } from "../../../../components/Emoji/isStringWithOnlyOneEmoji"
describe('components/Emoji/isStringWithOnlyOneEmoji', () => {
it('returns true with a string with only one emoji', () => {
expect(isStringWithOnlyOneEmoji(':wave:')).equal(true)
expect(isStringWithOnlyOneEmoji(':smile:')).equal(true)
describe("components/Emoji/isStringWithOnlyOneEmoji", () => {
it("returns true with a string with only one emoji", () => {
expect(isStringWithOnlyOneEmoji(":wave:")).equal(true)
expect(isStringWithOnlyOneEmoji(":smile:")).equal(true)
})
it('returns false with a string with multiple emoji or with text', () => {
expect(isStringWithOnlyOneEmoji(':wave: :smile:')).equal(false)
expect(isStringWithOnlyOneEmoji(':wave: some text')).equal(false)
expect(isStringWithOnlyOneEmoji('some text :wave:')).equal(false)
it("returns false with a string with multiple emoji or with text", () => {
expect(isStringWithOnlyOneEmoji(":wave: :smile:")).equal(false)
expect(isStringWithOnlyOneEmoji(":wave: some text")).equal(false)
expect(isStringWithOnlyOneEmoji("some text :wave:")).equal(false)
})
it('returns false with a string without emoji', () => {
expect(isStringWithOnlyOneEmoji('some text')).equal(false)
it("returns false with a string without emoji", () => {
expect(isStringWithOnlyOneEmoji("some text")).equal(false)
})
})

View File

@ -1,16 +1,16 @@
import { Footer } from '../../../components/Footer'
import { Footer } from "../../../components/Footer"
describe('<Footer />', () => {
it('should render with appropriate link tag version', () => {
const version = '1.0.0'
describe("<Footer />", () => {
it("should render with appropriate link tag version", () => {
const version = "1.0.0"
cy.mount(<Footer version={version} />)
cy.contains('Thream')
.get('[data-cy=version-link-website]')
.should('have.text', `website v${version}`)
cy.contains("Thream")
.get("[data-cy=version-link-website]")
.should("have.text", `website v${version}`)
.should(
'have.attr',
'href',
`https://github.com/Thream/website/releases/tag/v${version}`
"have.attr",
"href",
`https://github.com/Thream/website/releases/tag/v${version}`,
)
})
})

View File

@ -1,35 +1,35 @@
import { FormState } from '../../../../components/design/FormState'
import { FormState } from "../../../../components/design/FormState"
describe('<FormState />', () => {
it('should return nothing if the state is idle', () => {
cy.mount(<FormState state='idle' />)
.get('[data-cy-root]')
.should('be.empty')
describe("<FormState />", () => {
it("should return nothing if the state is idle", () => {
cy.mount(<FormState state="idle" />)
.get("[data-cy-root]")
.should("be.empty")
})
it('should return nothing if the message is null', () => {
cy.mount(<FormState state='error' />)
.get('[data-cy-root]')
.should('be.empty')
it("should return nothing if the message is null", () => {
cy.mount(<FormState state="error" />)
.get("[data-cy-root]")
.should("be.empty")
})
it('should render the <Loader /> if state is loading', () => {
cy.mount(<FormState state='loading' />)
.get('[data-cy=loader]')
.should('be.visible')
it("should render the <Loader /> if state is loading", () => {
cy.mount(<FormState state="loading" />)
.get("[data-cy=loader]")
.should("be.visible")
})
it('should render the success message if state is success', () => {
const message = 'Success Message'
cy.mount(<FormState state='success' message={message} id='success' />)
.get('#success')
it("should render the success message if state is success", () => {
const message = "Success Message"
cy.mount(<FormState state="success" message={message} id="success" />)
.get("#success")
.contains(message)
})
it('should render the error message if state is error', () => {
const message = 'Error Message'
cy.mount(<FormState state='error' message={message} id='error' />)
.get('#error')
it("should render the error message if state is error", () => {
const message = "Error Message"
cy.mount(<FormState state="error" message={message} id="error" />)
.get("#error")
.contains(message)
})
})

View File

@ -1,48 +1,48 @@
import { Input, getInputType } from '../../../../components/design/Input'
import { Input, getInputType } from "../../../../components/design/Input"
describe('<Input />', () => {
it('should render the label', () => {
const labelContent = 'label content'
describe("<Input />", () => {
it("should render the label", () => {
const labelContent = "label content"
cy.mount(<Input label={labelContent} />)
.get('label')
.should('have.text', labelContent)
.get("label")
.should("have.text", labelContent)
})
it('should not render forgot password link', () => {
cy.mount(<Input type='text' label='content' showForgotPassword />)
.get('[data-cy=forgot-password-link]')
.should('not.exist')
it("should not render forgot password link", () => {
cy.mount(<Input type="text" label="content" showForgotPassword />)
.get("[data-cy=forgot-password-link]")
.should("not.exist")
})
it('should render forgot password link', () => {
cy.mount(<Input type='password' label='content' showForgotPassword />)
.get('[data-cy=forgot-password-link]')
.should('exist')
it("should render forgot password link", () => {
cy.mount(<Input type="password" label="content" showForgotPassword />)
.get("[data-cy=forgot-password-link]")
.should("exist")
})
it('should not render the eye icon if the input is not of type "password"', () => {
cy.mount(<Input type='text' label='content' />)
.get('[data-cy=password-eye]')
.should('not.exist')
cy.mount(<Input type="text" label="content" />)
.get("[data-cy=password-eye]")
.should("not.exist")
})
it('should handlePassword with eye icon', async () => {
cy.mount(<Input type='password' label='content' />)
.get('input')
.should('have.attr', 'type', 'password')
.get('[data-cy=password-eye]')
it("should handlePassword with eye icon", async () => {
cy.mount(<Input type="password" label="content" />)
.get("input")
.should("have.attr", "type", "password")
.get("[data-cy=password-eye]")
.click()
.get('input')
.should('have.attr', 'type', 'text')
.get("input")
.should("have.attr", "type", "text")
})
describe('getInputType', () => {
it('should return `text`', () => {
expect(getInputType('password')).equal('text')
describe("getInputType", () => {
it("should return `text`", () => {
expect(getInputType("password")).equal("text")
})
it('should return `password`', () => {
expect(getInputType('text')).equal('password')
it("should return `password`", () => {
expect(getInputType("text")).equal("password")
})
})
})

View File

@ -1,10 +1,10 @@
import { capitalize } from '../../../../tools/utils/capitalize'
import { capitalize } from "../../../../tools/utils/capitalize"
describe('tools/utils/capitalize', () => {
it('should capitalize the first letter of a string', () => {
expect(capitalize('hello')).equal('Hello')
expect(capitalize('HeLlo')).equal('HeLlo')
expect(capitalize('member(s)')).equal('Member(s)')
expect(capitalize('Member(s)')).equal('Member(s)')
describe("tools/utils/capitalize", () => {
it("should capitalize the first letter of a string", () => {
expect(capitalize("hello")).equal("Hello")
expect(capitalize("HeLlo")).equal("HeLlo")
expect(capitalize("member(s)")).equal("Member(s)")
expect(capitalize("Member(s)")).equal("Member(s)")
})
})

View File

@ -1,53 +1,53 @@
describe('Common > Header', () => {
describe("Common > Header", () => {
beforeEach(() => {
return cy.visit('/')
return cy.visit("/")
})
describe('Switch theme color (dark/light)', () => {
it('should switch theme from `dark` (default) to `light`', () => {
cy.get('[data-cy=switch-theme-dark]').should('be.visible')
cy.get('[data-cy=switch-theme-light]').should('not.be.visible')
cy.get('body').should(
'not.have.css',
'background-color',
'rgb(255, 255, 255)'
describe("Switch theme color (dark/light)", () => {
it("should switch theme from `dark` (default) to `light`", () => {
cy.get("[data-cy=switch-theme-dark]").should("be.visible")
cy.get("[data-cy=switch-theme-light]").should("not.be.visible")
cy.get("body").should(
"not.have.css",
"background-color",
"rgb(255, 255, 255)",
)
cy.get('[data-cy=switch-theme-click]').click()
cy.get("[data-cy=switch-theme-click]").click()
cy.get('[data-cy=switch-theme-dark]').should('not.be.visible')
cy.get('[data-cy=switch-theme-light]').should('be.visible')
cy.get('body').should(
'have.css',
'background-color',
'rgb(255, 255, 255)'
cy.get("[data-cy=switch-theme-dark]").should("not.be.visible")
cy.get("[data-cy=switch-theme-light]").should("be.visible")
cy.get("body").should(
"have.css",
"background-color",
"rgb(255, 255, 255)",
)
})
})
describe('Switch Language', () => {
it('should switch language from EN (default) to FR', () => {
cy.get('[data-cy=main-description]').contains(
'Your open source platform to stay close with your friends and communities, talk, chat, collaborate, share and have fun.'
describe("Switch Language", () => {
it("should switch language from EN (default) to FR", () => {
cy.get("[data-cy=main-description]").contains(
"Your open source platform to stay close with your friends and communities, talk, chat, collaborate, share and have fun.",
)
cy.get('[data-cy=language-flag-text]').contains('EN')
cy.get('[data-cy=languages-list]').should('not.be.visible')
cy.get('[data-cy=language-click]').click()
cy.get('[data-cy=languages-list]').should('be.visible')
cy.get('[data-cy=languages-list] > li:first-child').contains('FR').click()
cy.get('[data-cy=languages-list]').should('not.be.visible')
cy.get('[data-cy=language-flag-text]').contains('FR')
cy.get('[data-cy=main-description]').contains(
'Votre plateforme open source pour rester proche de vos amis et communautés, parler, discuter, collaborer, partager et amusez-vous.'
cy.get("[data-cy=language-flag-text]").contains("EN")
cy.get("[data-cy=languages-list]").should("not.be.visible")
cy.get("[data-cy=language-click]").click()
cy.get("[data-cy=languages-list]").should("be.visible")
cy.get("[data-cy=languages-list] > li:first-child").contains("FR").click()
cy.get("[data-cy=languages-list]").should("not.be.visible")
cy.get("[data-cy=language-flag-text]").contains("FR")
cy.get("[data-cy=main-description]").contains(
"Votre plateforme open source pour rester proche de vos amis et communautés, parler, discuter, collaborer, partager et amusez-vous.",
)
})
it('should close the language list menu when clicking outside', () => {
cy.get('[data-cy=languages-list]').should('not.be.visible')
cy.get('[data-cy=language-click]').click()
cy.get('[data-cy=languages-list]').should('be.visible')
cy.get('[data-cy=main-description]').click()
cy.get('[data-cy=languages-list]').should('not.be.visible')
it("should close the language list menu when clicking outside", () => {
cy.get("[data-cy=languages-list]").should("not.be.visible")
cy.get("[data-cy=language-click]").click()
cy.get("[data-cy=languages-list]").should("be.visible")
cy.get("[data-cy=main-description]").click()
cy.get("[data-cy=languages-list]").should("not.be.visible")
})
})
})

View File

@ -1,47 +1,47 @@
import { channelExample } from '../../../fixtures/channels/channel'
import { guildExample } from '../../../fixtures/guilds/guild'
import { userExample } from '../../../fixtures/users/user'
import { authenticationHandlers } from '../../../fixtures/handler'
import { getGuildMemberWithGuildIdHandler } from '../../../fixtures/guilds/[guildId]/get'
import { getChannelWithChannelIdHandler } from '../../../fixtures/channels/[channelId]/get'
import { getUserByIdHandler } from '../../../fixtures/users/[userId]/get'
import { channelExample } from "../../../fixtures/channels/channel"
import { guildExample } from "../../../fixtures/guilds/guild"
import { userExample } from "../../../fixtures/users/user"
import { authenticationHandlers } from "../../../fixtures/handler"
import { getGuildMemberWithGuildIdHandler } from "../../../fixtures/guilds/[guildId]/get"
import { getChannelWithChannelIdHandler } from "../../../fixtures/channels/[channelId]/get"
import { getUserByIdHandler } from "../../../fixtures/users/[userId]/get"
const applicationPaths = [
'/application',
"/application",
`/application/users/${userExample.id}`,
`/application/users/settings`,
'/application/guilds/create',
'/application/guilds/join',
"/application/guilds/create",
"/application/guilds/join",
`/application/${guildExample.id}/${channelExample.id}`,
`/application/${guildExample.id}/${channelExample.id}/settings`,
`/application/${guildExample.id}/channels/create`,
`/application/${guildExample.id}/settings`
`/application/${guildExample.id}/settings`,
]
describe('Common > application/authentication', () => {
describe("Common > application/authentication", () => {
beforeEach(() => {
cy.task('stopMockServer')
cy.task("stopMockServer")
})
it('should redirect the user to `/authentication/signin` if not signed in', () => {
it("should redirect the user to `/authentication/signin` if not signed in", () => {
for (const applicationPath of applicationPaths) {
cy.visit(applicationPath)
.location('pathname')
.should('eq', '/authentication/signin')
.location("pathname")
.should("eq", "/authentication/signin")
}
})
it('should not redirect the user if signed in', () => {
cy.task('startMockServer', [
it("should not redirect the user if signed in", () => {
cy.task("startMockServer", [
...authenticationHandlers,
getGuildMemberWithGuildIdHandler,
getChannelWithChannelIdHandler,
getUserByIdHandler
]).setCookie('refreshToken', 'refresh-token')
getUserByIdHandler,
]).setCookie("refreshToken", "refresh-token")
for (const applicationPath of applicationPaths) {
cy.visit(applicationPath)
.location('pathname')
.should('eq', applicationPath)
.location("pathname")
.should("eq", applicationPath)
}
})
})

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")
})
})

View File

@ -1,14 +1,14 @@
import type { Handler } from '../../handler'
import { channelExample, channelExample2 } from '../channel'
import type { Handler } from "../../handler"
import { channelExample, channelExample2 } from "../channel"
export const deleteChannelWithChannelIdHandler: Handler = {
method: 'DELETE',
method: "DELETE",
url: `/channels/${channelExample.id}`,
response: {
statusCode: 200,
body: {
...channelExample,
defaultChannelId: channelExample2.id
}
}
defaultChannelId: channelExample2.id,
},
},
}

View File

@ -1,24 +1,24 @@
import type { Handler } from '../../handler'
import { channelExample, channelExample2 } from '../channel'
import type { Handler } from "../../handler"
import { channelExample, channelExample2 } from "../channel"
export const getChannelWithChannelIdHandler: Handler = {
method: 'GET',
method: "GET",
url: `/channels/${channelExample.id}`,
response: {
statusCode: 200,
body: {
channel: channelExample
}
}
channel: channelExample,
},
},
}
export const getChannelWithChannelIdHandler2: Handler = {
method: 'GET',
method: "GET",
url: `/channels/${channelExample2.id}`,
response: {
statusCode: 200,
body: {
channel: channelExample2
}
}
channel: channelExample2,
},
},
}

View File

@ -1,4 +1,4 @@
import type { Handler } from '../../../handler'
import type { Handler } from "../../../handler"
import {
messageExampleComplete,
messageExampleComplete2,
@ -8,12 +8,12 @@ import {
messageExampleComplete6,
messageExampleComplete7,
messageExampleComplete8,
messageExampleComplete9
} from '../../../messages/message'
import { channelExample } from '../../channel'
messageExampleComplete9,
} from "../../../messages/message"
import { channelExample } from "../../channel"
export const getMessagesWithChannelIdHandler: Handler = {
method: 'GET',
method: "GET",
url: `/channels/${channelExample.id}/messages`,
response: {
statusCode: 200,
@ -26,7 +26,7 @@ export const getMessagesWithChannelIdHandler: Handler = {
messageExampleComplete6,
messageExampleComplete7,
messageExampleComplete8,
messageExampleComplete9
]
}
messageExampleComplete9,
],
},
}

View File

@ -1,15 +1,15 @@
import type { Handler } from '../../handler'
import { channelExample, channelExample2 } from '../channel'
import type { Handler } from "../../handler"
import { channelExample, channelExample2 } from "../channel"
export const putChannelWithChannelIdHandler: Handler = {
method: 'PUT',
method: "PUT",
url: `/channels/${channelExample.id}`,
response: {
statusCode: 200,
body: {
...channelExample,
name: 'New channel name',
defaultChannelId: channelExample2.id
}
}
name: "New channel name",
defaultChannelId: channelExample2.id,
},
},
}

View File

@ -1,15 +1,15 @@
import { guildExample } from '../guilds/guild'
import { guildExample } from "../guilds/guild"
export const channelExample = {
id: 1,
name: 'general',
name: "general",
guildId: guildExample.id,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString()
updatedAt: new Date().toISOString(),
}
export const channelExample2 = {
...channelExample,
id: 2,
name: 'general2'
name: "general2",
}

View File

@ -1,12 +1,12 @@
import { guildExample } from '../../guild'
import type { Handler } from '../../../handler'
import { channelExample, channelExample2 } from '../../../channels/channel'
import { guildExample } from "../../guild"
import type { Handler } from "../../../handler"
import { channelExample, channelExample2 } from "../../../channels/channel"
export const getChannelsWithGuildIdHandler: Handler = {
method: 'GET',
method: "GET",
url: `/guilds/${guildExample.id}/channels`,
response: {
statusCode: 200,
body: [channelExample, channelExample2]
}
body: [channelExample, channelExample2],
},
}

View File

@ -1,15 +1,15 @@
import { guildExample } from '../../guild'
import type { Handler } from '../../../handler'
import { channelExample, channelExample2 } from '../../../channels/channel'
import { guildExample } from "../../guild"
import type { Handler } from "../../../handler"
import { channelExample, channelExample2 } from "../../../channels/channel"
export const postChannelsWithGuildIdHandler: Handler = {
method: 'POST',
method: "POST",
url: `/guilds/${guildExample.id}/channels`,
response: {
statusCode: 200,
body: {
...channelExample2,
defaultChannelId: channelExample.id
}
}
defaultChannelId: channelExample.id,
},
},
}

View File

@ -1,13 +1,13 @@
import type { Handler } from '../../handler'
import { guildExample } from '../guild'
import type { Handler } from "../../handler"
import { guildExample } from "../guild"
export const deleteGuildWithGuildIdHandler: Handler = {
method: 'DELETE',
method: "DELETE",
url: `/guilds/${guildExample.id}`,
response: {
statusCode: 200,
body: {
...guildExample
}
}
...guildExample,
},
},
}

View File

@ -1,21 +1,21 @@
import type { Handler } from '../../handler'
import { guildExample } from '../guild'
import { memberExampleComplete } from '../../members/member'
import type { Handler } from "../../handler"
import { guildExample } from "../guild"
import { memberExampleComplete } from "../../members/member"
export const getGuildMemberWithGuildIdHandler: Handler = {
method: 'GET',
method: "GET",
url: `/guilds/${guildExample.id}`,
response: {
statusCode: 200,
body: {
guild: guildExample,
member: memberExampleComplete
}
}
member: memberExampleComplete,
},
},
}
export const getGuildMemberNotOwnerWithGuildIdHandler: Handler = {
method: 'GET',
method: "GET",
url: `/guilds/${guildExample.id}`,
response: {
statusCode: 200,
@ -23,8 +23,8 @@ export const getGuildMemberNotOwnerWithGuildIdHandler: Handler = {
guild: guildExample,
member: {
...memberExampleComplete,
isOwner: false
}
}
}
isOwner: false,
},
},
},
}

View File

@ -1,12 +1,12 @@
import { guildExample } from '../../guild'
import type { Handler } from '../../../handler'
import { memberExampleComplete } from '../../../members/member'
import { guildExample } from "../../guild"
import type { Handler } from "../../../handler"
import { memberExampleComplete } from "../../../members/member"
export const getMembersWithGuildIdHandler: Handler = {
method: 'GET',
method: "GET",
url: `/guilds/${guildExample.id}/members`,
response: {
statusCode: 200,
body: [memberExampleComplete]
}
body: [memberExampleComplete],
},
}

View File

@ -1,10 +1,10 @@
import { guildExample } from '../../guild'
import type { Handler } from '../../../handler'
import { memberExampleComplete } from '../../../members/member'
import { channelExample } from '../../../channels/channel'
import { guildExample } from "../../guild"
import type { Handler } from "../../../handler"
import { memberExampleComplete } from "../../../members/member"
import { channelExample } from "../../../channels/channel"
export const postMembersWithGuildIdHandler: Handler = {
method: 'POST',
method: "POST",
url: `/guilds/${guildExample.id}/members/join`,
response: {
statusCode: 201,
@ -12,8 +12,8 @@ export const postMembersWithGuildIdHandler: Handler = {
...memberExampleComplete,
guild: {
...guildExample,
defaultChannelId: channelExample.id
}
}
}
defaultChannelId: channelExample.id,
},
},
},
}

View File

@ -1,14 +1,14 @@
import { guildExample } from '../../guild'
import type { Handler } from '../../../handler'
import { memberExample } from '../../../members/member'
import { guildExample } from "../../guild"
import type { Handler } from "../../../handler"
import { memberExample } from "../../../members/member"
export const deleteLeaveMembersWithGuildIdHandler: Handler = {
method: 'DELETE',
method: "DELETE",
url: `/guilds/${guildExample.id}/members/leave`,
response: {
statusCode: 200,
body: {
...memberExample
}
}
...memberExample,
},
},
}

View File

@ -1,14 +1,14 @@
import type { Handler } from '../handler'
import { guildExample, guildExample2 } from './guild'
import type { Handler } from "../handler"
import { guildExample, guildExample2 } from "./guild"
export const getGuildsHandler: Handler = {
method: 'GET',
url: '/guilds',
method: "GET",
url: "/guilds",
response: {
statusCode: 200,
body: [
{ ...guildExample, defaultChannelId: 1 },
{ ...guildExample2, defaultChannelId: 2 }
]
}
{ ...guildExample2, defaultChannelId: 2 },
],
},
}

View File

@ -1,16 +1,16 @@
import type { Guild } from '../../../models/Guild'
import type { Guild } from "../../../models/Guild"
export const guildExample: Guild = {
id: 1,
name: 'GuildExample',
description: 'guild example.',
name: "GuildExample",
description: "guild example.",
icon: null,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString()
updatedAt: new Date().toISOString(),
}
export const guildExample2: Guild = {
...guildExample,
id: 2,
name: 'app'
name: "app",
}

View File

@ -1,19 +1,19 @@
import type { Handler } from '../handler'
import { guildExample } from './guild'
import { channelExample } from '../channels/channel'
import { memberExampleComplete } from '../members/member'
import type { Handler } from "../handler"
import { guildExample } from "./guild"
import { channelExample } from "../channels/channel"
import { memberExampleComplete } from "../members/member"
export const postGuildsHandler: Handler = {
method: 'POST',
url: '/guilds',
method: "POST",
url: "/guilds",
response: {
statusCode: 201,
body: {
guild: {
...guildExample,
channels: [channelExample],
members: [memberExampleComplete]
}
}
}
members: [memberExampleComplete],
},
},
},
}

View File

@ -1,32 +1,32 @@
import type { Handler } from '../../handler'
import { guildExample, guildExample2 } from '../guild'
import type { Handler } from "../../handler"
import { guildExample, guildExample2 } from "../guild"
export const getGuildsPublicEmptyHandler: Handler = {
method: 'GET',
url: '/guilds/public',
method: "GET",
url: "/guilds/public",
response: {
statusCode: 200,
body: []
}
body: [],
},
}
export const getGuildsPublicHandler: Handler = {
method: 'GET',
url: '/guilds/public',
method: "GET",
url: "/guilds/public",
response: {
statusCode: 200,
body: [
{ ...guildExample, membersCount: 1 },
{ ...guildExample2, membersCount: 1 }
]
}
{ ...guildExample2, membersCount: 1 },
],
},
}
export const getGuildsPublicSearchHandler: Handler = {
method: 'GET',
url: '/guilds/public',
method: "GET",
url: "/guilds/public",
response: {
statusCode: 200,
body: [{ ...guildExample2, membersCount: 1 }]
}
body: [{ ...guildExample2, membersCount: 1 }],
},
}

View File

@ -1,7 +1,7 @@
import { getUsersCurrentHandler } from './users/current/get'
import { postUsersRefreshTokenHandler } from './users/refresh-token/post'
import { getUsersCurrentHandler } from "./users/current/get"
import { postUsersRefreshTokenHandler } from "./users/refresh-token/post"
export type Method = 'GET' | 'POST' | 'PUT' | 'DELETE'
export type Method = "GET" | "POST" | "PUT" | "DELETE"
export interface Handler {
method: Method
@ -17,5 +17,5 @@ export type Handlers = Handler[]
export const authenticationHandlers = [
getUsersCurrentHandler,
postUsersRefreshTokenHandler
postUsersRefreshTokenHandler,
]

View File

@ -1,5 +1,5 @@
import { guildExample } from '../guilds/guild'
import { userExample } from '../users/user'
import { guildExample } from "../guilds/guild"
import { userExample } from "../users/user"
export const memberExample = {
id: 1,
@ -7,10 +7,10 @@ export const memberExample = {
userId: userExample.id,
guildId: guildExample.id,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString()
updatedAt: new Date().toISOString(),
}
export const memberExampleComplete = {
...memberExample,
user: userExample
user: userExample,
}

View File

@ -1,33 +1,33 @@
import { channelExample } from '../channels/channel'
import { memberExampleComplete } from '../members/member'
import { channelExample } from "../channels/channel"
import { memberExampleComplete } from "../members/member"
export const messageExample = {
id: 1,
value: 'Hello, world!',
type: 'text' as 'text' | 'file',
mimetype: 'text/plain',
value: "Hello, world!",
type: "text" as "text" | "file",
mimetype: "text/plain",
memberId: memberExampleComplete.id,
channelId: channelExample.id,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString()
updatedAt: new Date().toISOString(),
}
export const messageExampleComplete = {
...messageExample,
member: memberExampleComplete
member: memberExampleComplete,
}
export const messageExampleComplete2 = {
...messageExampleComplete,
id: 2,
value: 'Message with bad html: <script>alert("xss")</script>'
value: 'Message with bad html: <script>alert("xss")</script>',
}
export const messageExampleComplete3 = {
...messageExampleComplete,
id: 3,
value:
'Message with **bold text** and *italic text*.\nNewlines and some emoji: :smile:'
"Message with **bold text** and *italic text*.\nNewlines and some emoji: :smile:",
}
export const messageExampleComplete4 = {
@ -38,43 +38,43 @@ export const messageExampleComplete4 = {
**Theorem 1**: $(a, b, c) \\in \\mathbb{R}^3$, the solutions of $ax^2 + bx + c = 0$ are:
$x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}$
`
`,
}
export const messageExampleComplete5 = {
...messageExampleComplete,
id: 5,
value: ':wave:'
value: ":wave:",
}
export const messageExampleComplete6 = {
...messageExampleComplete,
id: 6,
value: '/uploads/messages/image.png',
type: 'file',
mimetype: 'image/png'
value: "/uploads/messages/image.png",
type: "file",
mimetype: "image/png",
}
export const messageExampleComplete7 = {
...messageExampleComplete,
id: 7,
value: '/uploads/messages/audio.mp3',
type: 'file',
mimetype: 'audio/mp3'
value: "/uploads/messages/audio.mp3",
type: "file",
mimetype: "audio/mp3",
}
export const messageExampleComplete8 = {
...messageExampleComplete,
id: 8,
value: '/uploads/messages/video.mp4',
type: 'file',
mimetype: 'video/mp4'
value: "/uploads/messages/video.mp4",
type: "file",
mimetype: "video/mp4",
}
export const messageExampleComplete9 = {
...messageExampleComplete,
id: 9,
value: '/uploads/messages/download.zip',
type: 'file',
mimetype: 'application/zip'
value: "/uploads/messages/download.zip",
type: "file",
mimetype: "application/zip",
}

View File

@ -1,47 +1,47 @@
import type { Handler } from '../../handler'
import type { Handler } from "../../handler"
import {
messageExampleComplete6,
messageExampleComplete7,
messageExampleComplete8,
messageExampleComplete9
} from '../../messages/message'
messageExampleComplete9,
} from "../../messages/message"
export const getMessagesUploadsImageHandler: Handler = {
method: 'GET',
method: "GET",
url: messageExampleComplete6.value as `/${string}`,
response: {
statusCode: 200,
isFile: true,
body: ['image.png']
}
body: ["image.png"],
},
}
export const getMessagesUploadsAudioHandler: Handler = {
method: 'GET',
method: "GET",
url: messageExampleComplete7.value as `/${string}`,
response: {
statusCode: 200,
isFile: true,
body: ['audio.mp3']
}
body: ["audio.mp3"],
},
}
export const getMessagesUploadsVideoHandler: Handler = {
method: 'GET',
method: "GET",
url: messageExampleComplete8.value as `/${string}`,
response: {
statusCode: 200,
isFile: true,
body: ['video.mp4']
}
body: ["video.mp4"],
},
}
export const getMessagesUploadsDownloadHandler: Handler = {
method: 'GET',
method: "GET",
url: messageExampleComplete9.value as `/${string}`,
response: {
statusCode: 200,
isFile: true,
body: ['download.zip']
}
body: ["download.zip"],
},
}

View File

@ -1,17 +1,17 @@
import type { Handler } from '../../handler'
import { userExample, userSettingsExample } from '../user'
import type { Handler } from "../../handler"
import { userExample, userSettingsExample } from "../user"
export const getUserByIdHandler: Handler = {
method: 'GET',
method: "GET",
url: `/users/${userExample.id}`,
response: {
statusCode: 200,
body: {
user: {
...userExample,
settings: userSettingsExample
settings: userSettingsExample,
},
guilds: []
}
}
guilds: [],
},
},
}

View File

@ -1,18 +1,18 @@
import type { Handler } from '../../handler'
import { userExample, userSettingsExample } from '../user'
import type { Handler } from "../../handler"
import { userExample, userSettingsExample } from "../user"
export const getUsersCurrentHandler: Handler = {
method: 'GET',
url: '/users/current',
method: "GET",
url: "/users/current",
response: {
statusCode: 200,
body: {
user: {
...userExample,
settings: userSettingsExample,
currentStrategy: 'local',
strategies: ['local']
}
}
}
currentStrategy: "local",
strategies: ["local"],
},
},
},
}

View File

@ -1,14 +1,14 @@
import type { Handler } from '../../handler'
import type { Handler } from "../../handler"
export const postUsersRefreshTokenHandler: Handler = {
method: 'POST',
url: '/users/refresh-token',
method: "POST",
url: "/users/refresh-token",
response: {
statusCode: 200,
body: {
accessToken: 'access-token',
accessToken: "access-token",
expiresIn: 3600000,
type: 'Bearer'
}
}
type: "Bearer",
},
},
}

View File

@ -1,10 +1,10 @@
import type { Handler } from '../../handler'
import type { Handler } from "../../handler"
export const postUsersResetPasswordHandler: Handler = {
method: 'POST',
url: '/users/reset-password',
method: "POST",
url: "/users/reset-password",
response: {
statusCode: 200,
body: 'Password-reset request successful, please check your emails!'
}
body: "Password-reset request successful, please check your emails!",
},
}

View File

@ -1,23 +1,23 @@
import type { Handler } from '../../handler'
import type { Handler } from "../../handler"
export const putUsersResetPasswordHandler: Handler = {
method: 'PUT',
url: '/users/reset-password',
method: "PUT",
url: "/users/reset-password",
response: {
statusCode: 200,
body: 'The new password has been saved!'
}
body: "The new password has been saved!",
},
}
export const putUsersResetPasswordInvalidTemporaryTokenHandler: Handler = {
method: 'PUT',
url: '/users/reset-password',
method: "PUT",
url: "/users/reset-password",
response: {
statusCode: 400,
body: {
statusCode: 400,
error: 'Bad Request',
message: '"tempToken" is invalid'
}
}
error: "Bad Request",
message: '"tempToken" is invalid',
},
},
}

View File

@ -1,28 +1,28 @@
import type { Handler } from '../../handler'
import type { Handler } from "../../handler"
export const postUsersSigninHandler: Handler = {
method: 'POST',
url: '/users/signin',
method: "POST",
url: "/users/signin",
response: {
statusCode: 200,
body: {
accessToken: 'access-token',
refreshToken: 'refresh-token',
accessToken: "access-token",
refreshToken: "refresh-token",
expiresIn: 3600000,
type: 'Bearer'
}
}
type: "Bearer",
},
},
}
export const postUsersSigninInvalidCredentialsHandler: Handler = {
method: 'POST',
url: '/users/signin',
method: "POST",
url: "/users/signin",
response: {
statusCode: 400,
body: {
statusCode: 400,
error: 'Bad Request',
message: 'Invalid credentials.'
}
}
error: "Bad Request",
message: "Invalid credentials.",
},
},
}

View File

@ -1,29 +1,29 @@
import type { Handler } from '../../handler'
import { userExample, userSettingsExample } from '../user'
import type { Handler } from "../../handler"
import { userExample, userSettingsExample } from "../user"
export const postUsersSignupHandler: Handler = {
method: 'POST',
url: '/users/signup',
method: "POST",
url: "/users/signup",
response: {
statusCode: 201,
body: {
user: {
...userExample,
settings: userSettingsExample
}
}
}
settings: userSettingsExample,
},
},
},
}
export const postUsersSignupAlreadyUsedHandler: Handler = {
method: 'POST',
url: '/users/signup',
method: "POST",
url: "/users/signup",
response: {
statusCode: 400,
body: {
statusCode: 400,
error: 'Bad Request',
message: 'body.email or body.name already taken.'
}
}
error: "Bad Request",
message: "body.email or body.name already taken.",
},
},
}

View File

@ -1,29 +1,29 @@
import type { UserSettings } from '../../../models/UserSettings'
import type { User } from '../../../models/User'
import type { UserSettings } from "../../../models/UserSettings"
import type { User } from "../../../models/User"
export const userExample: User = {
id: 1,
name: 'Divlo',
email: 'contact@divlo.fr',
password: 'somepassword',
name: "Divlo",
email: "contact@divlo.fr",
password: "somepassword",
logo: null,
status: null,
biography: null,
website: 'https://divlo.fr',
website: "https://divlo.fr",
isConfirmed: true,
temporaryToken: 'temporaryUUIDtoken',
temporaryExpirationToken: '2021-10-20T20:59:08.485Z',
createdAt: '2021-10-20T20:30:51.595Z',
updatedAt: '2021-10-20T20:59:08.485Z'
temporaryToken: "temporaryUUIDtoken",
temporaryExpirationToken: "2021-10-20T20:59:08.485Z",
createdAt: "2021-10-20T20:30:51.595Z",
updatedAt: "2021-10-20T20:59:08.485Z",
}
export const userSettingsExample: UserSettings = {
id: 1,
language: 'en',
theme: 'dark',
language: "en",
theme: "dark",
isPublicEmail: false,
isPublicGuilds: false,
createdAt: '2021-10-20T20:30:51.605Z',
updatedAt: '2021-10-22T07:22:07.956Z',
userId: 1
createdAt: "2021-10-20T20:30:51.605Z",
updatedAt: "2021-10-22T07:22:07.956Z",
userId: 1,
}

View File

@ -1,7 +1,7 @@
import { mount } from 'cypress/react'
import { mount } from "cypress/react"
import './commands'
import '../../styles/global.css'
import "./commands"
import "../../styles/global.css"
declare global {
namespace Cypress {
@ -11,4 +11,4 @@ declare global {
}
}
Cypress.Commands.add('mount', mount)
Cypress.Commands.add("mount", mount)