2023-10-23 23:33:39 +02:00
|
|
|
import date from "date-and-time"
|
2022-01-01 20:42:25 +01:00
|
|
|
|
|
|
|
import {
|
|
|
|
channelExample,
|
2023-10-23 23:33:39 +02:00
|
|
|
channelExample2,
|
|
|
|
} from "../../../../../fixtures/channels/channel"
|
|
|
|
import { guildExample } from "../../../../../fixtures/guilds/guild"
|
2022-03-05 18:22:30 +01:00
|
|
|
import {
|
|
|
|
getGuildMemberNotOwnerWithGuildIdHandler,
|
2023-10-23 23:33:39 +02:00
|
|
|
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"
|
2022-01-01 20:42:25 +01:00
|
|
|
import {
|
|
|
|
messageExampleComplete,
|
2023-10-23 23:33:39 +02:00
|
|
|
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"
|
2022-01-07 21:21:38 +01:00
|
|
|
import {
|
|
|
|
getMessagesUploadsAudioHandler,
|
|
|
|
getMessagesUploadsDownloadHandler,
|
|
|
|
getMessagesUploadsImageHandler,
|
2023-10-23 23:33:39 +02:00
|
|
|
getMessagesUploadsVideoHandler,
|
|
|
|
} from "../../../../../fixtures/uploads/messages/get"
|
2021-10-24 06:09:43 +02:00
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
describe("Pages > /application/[guildId]/[channelId]", () => {
|
2021-10-24 06:09:43 +02:00
|
|
|
beforeEach(() => {
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.task("stopMockServer")
|
2021-10-24 06:09:43 +02:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should succeeds and display the left sidebar correctly (member is owner)", () => {
|
|
|
|
cy.task("startMockServer", [
|
2022-01-01 20:42:25 +01:00
|
|
|
...authenticationHandlers,
|
|
|
|
getGuildMemberWithGuildIdHandler,
|
|
|
|
getChannelWithChannelIdHandler,
|
2023-10-23 23:33:39 +02:00
|
|
|
getGuildsHandler,
|
|
|
|
]).setCookie("refreshToken", "refresh-token")
|
|
|
|
cy.intercept(`${API_URL}${getGuildsHandler.url}*`).as("getGuildsHandler")
|
2022-01-01 20:42:25 +01:00
|
|
|
cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.wait(["@getGuildsHandler"]).then(() => {
|
|
|
|
cy.get("[data-cy=application-title]").should(
|
|
|
|
"have.text",
|
|
|
|
`# ${channelExample.name}`,
|
2022-01-01 20:42:25 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=guild-left-sidebar-title]").should(
|
|
|
|
"have.text",
|
|
|
|
guildExample.name,
|
2022-01-01 20:42:25 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get(".guilds-list").children().should("have.length", 2)
|
|
|
|
cy.get("[data-cy=link-add-channel]")
|
|
|
|
.should("be.visible")
|
2022-03-05 18:22:30 +01:00
|
|
|
.should(
|
2023-10-23 23:33:39 +02:00
|
|
|
"have.attr",
|
|
|
|
"href",
|
|
|
|
`/application/${guildExample.id}/channels/create`,
|
2022-03-05 18:22:30 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=link-settings-guild]")
|
|
|
|
.should("be.visible")
|
|
|
|
.should("have.attr", "href", `/application/${guildExample.id}/settings`)
|
2022-03-05 18:22:30 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should succeeds and display the left sidebar correctly (member is not owner)", () => {
|
|
|
|
cy.task("startMockServer", [
|
2022-03-05 18:22:30 +01:00
|
|
|
...authenticationHandlers,
|
|
|
|
getGuildMemberNotOwnerWithGuildIdHandler,
|
|
|
|
getChannelWithChannelIdHandler,
|
2023-10-23 23:33:39 +02:00
|
|
|
getGuildsHandler,
|
|
|
|
]).setCookie("refreshToken", "refresh-token")
|
|
|
|
cy.intercept(`${API_URL}${getGuildsHandler.url}*`).as("getGuildsHandler")
|
2022-03-05 18:22:30 +01:00
|
|
|
cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.wait(["@getGuildsHandler"]).then(() => {
|
|
|
|
cy.get("[data-cy=application-title]").should(
|
|
|
|
"have.text",
|
|
|
|
`# ${channelExample.name}`,
|
2022-03-05 18:22:30 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=guild-left-sidebar-title]").should(
|
|
|
|
"have.text",
|
|
|
|
guildExample.name,
|
2022-03-05 18:22:30 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
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`)
|
2022-01-01 20:42:25 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should succeeds and display the channels in left sidebar correctly", () => {
|
|
|
|
cy.task("startMockServer", [
|
2022-01-01 20:42:25 +01:00
|
|
|
...authenticationHandlers,
|
|
|
|
getGuildMemberWithGuildIdHandler,
|
|
|
|
getChannelWithChannelIdHandler,
|
2023-10-23 23:33:39 +02:00
|
|
|
getChannelsWithGuildIdHandler,
|
|
|
|
]).setCookie("refreshToken", "refresh-token")
|
2022-01-01 20:42:25 +01:00
|
|
|
cy.intercept(`${API_URL}${getChannelsWithGuildIdHandler.url}*`).as(
|
2023-10-23 23:33:39 +02:00
|
|
|
"getChannelsWithGuildIdHandler",
|
2022-01-01 20:42:25 +01:00
|
|
|
)
|
|
|
|
cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
|
2023-10-23 23:33:39 +02:00
|
|
|
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}`,
|
2022-06-29 06:50:35 +02:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get(".channels-list [data-cy=channel-name]:last").should(
|
|
|
|
"have.text",
|
|
|
|
`# ${channelExample2.name}`,
|
2022-06-29 06:50:35 +02:00
|
|
|
)
|
|
|
|
})
|
2022-01-01 20:42:25 +01:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should succeeds and display the messages correctly", () => {
|
|
|
|
cy.task("startMockServer", [
|
2022-01-01 20:42:25 +01:00
|
|
|
...authenticationHandlers,
|
|
|
|
getGuildMemberWithGuildIdHandler,
|
|
|
|
getChannelWithChannelIdHandler,
|
2022-01-07 21:21:38 +01:00
|
|
|
getMessagesWithChannelIdHandler,
|
|
|
|
getMessagesUploadsImageHandler,
|
|
|
|
getMessagesUploadsAudioHandler,
|
|
|
|
getMessagesUploadsVideoHandler,
|
2023-10-23 23:33:39 +02:00
|
|
|
getMessagesUploadsDownloadHandler,
|
|
|
|
]).setCookie("refreshToken", "refresh-token")
|
2022-01-01 20:42:25 +01:00
|
|
|
cy.intercept(`${API_URL}${getMessagesWithChannelIdHandler.url}*`).as(
|
2023-10-23 23:33:39 +02:00
|
|
|
"getMessagesWithChannelIdHandler",
|
2022-01-01 20:42:25 +01:00
|
|
|
)
|
2022-01-07 21:21:38 +01:00
|
|
|
cy.intercept(`${API_URL}${getMessagesUploadsImageHandler.url}`).as(
|
2023-10-23 23:33:39 +02:00
|
|
|
"getMessagesUploadsImageHandler",
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
|
|
|
cy.intercept(`${API_URL}${getMessagesUploadsAudioHandler.url}`).as(
|
2023-10-23 23:33:39 +02:00
|
|
|
"getMessagesUploadsAudioHandler",
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
|
|
|
cy.intercept(`${API_URL}${getMessagesUploadsVideoHandler.url}`).as(
|
2023-10-23 23:33:39 +02:00
|
|
|
"getMessagesUploadsVideoHandler",
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
|
|
|
cy.intercept(`${API_URL}${getMessagesUploadsDownloadHandler.url}`).as(
|
2023-10-23 23:33:39 +02:00
|
|
|
"getMessagesUploadsDownloadHandler",
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
2022-01-01 20:42:25 +01:00
|
|
|
cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
|
2022-01-07 21:21:38 +01:00
|
|
|
cy.wait([
|
2023-10-23 23:33:39 +02:00
|
|
|
"@getMessagesWithChannelIdHandler",
|
|
|
|
"@getMessagesUploadsImageHandler",
|
|
|
|
"@getMessagesUploadsAudioHandler",
|
|
|
|
"@getMessagesUploadsVideoHandler",
|
|
|
|
"@getMessagesUploadsDownloadHandler",
|
2022-01-07 21:21:38 +01:00
|
|
|
]).then(() => {
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get(".messages-list").children().should("have.length", 9)
|
|
|
|
cy.get("[data-cy=message-1] p").should(
|
|
|
|
"have.text",
|
|
|
|
messageExampleComplete.value,
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=message-1] [data-cy=message-member-user-name]").should(
|
|
|
|
"have.text",
|
|
|
|
messageExampleComplete.member.user.name,
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=message-1] [data-cy=message-date]").should(
|
|
|
|
"have.text",
|
2022-01-07 21:21:38 +01:00
|
|
|
date.format(
|
|
|
|
new Date(messageExampleComplete.createdAt),
|
2023-10-23 23:33:39 +02:00
|
|
|
"DD/MM/YYYY - HH:mm:ss",
|
|
|
|
),
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=message-2] p").should(
|
|
|
|
"have.text",
|
|
|
|
messageExampleComplete2.value,
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=message-3] p").should(
|
|
|
|
"have.text",
|
|
|
|
"Message with bold text and italic text.\nNewlines and some emoji: ",
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
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",
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=message-3] span[title=smile]").should(
|
|
|
|
"have.css",
|
|
|
|
"height",
|
|
|
|
"20px",
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=message-4] p:first").should(
|
|
|
|
"have.text",
|
|
|
|
"The Quadratic Formula:",
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
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",
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=message-5] span[title=wave]").should(
|
|
|
|
"have.css",
|
|
|
|
"height",
|
|
|
|
"40px",
|
2022-01-07 21:21:38 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
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")
|
2022-01-07 21:21:38 +01:00
|
|
|
})
|
2022-01-01 20:42:25 +01:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should succeeds and display the members in right sidebar correctly", () => {
|
|
|
|
cy.task("startMockServer", [
|
2022-01-01 20:42:25 +01:00
|
|
|
...authenticationHandlers,
|
|
|
|
getGuildMemberWithGuildIdHandler,
|
|
|
|
getChannelWithChannelIdHandler,
|
2023-10-23 23:33:39 +02:00
|
|
|
getMembersWithGuildIdHandler,
|
|
|
|
]).setCookie("refreshToken", "refresh-token")
|
2022-01-01 20:42:25 +01:00
|
|
|
cy.intercept(`${API_URL}${getMembersWithGuildIdHandler.url}*`).as(
|
2023-10-23 23:33:39 +02:00
|
|
|
"getMembersWithGuildIdHandler",
|
2022-01-01 20:42:25 +01:00
|
|
|
)
|
|
|
|
cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
|
2023-10-23 23:33:39 +02:00
|
|
|
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,
|
2022-06-29 06:50:35 +02:00
|
|
|
)
|
|
|
|
})
|
2022-01-01 20:42:25 +01:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should redirect the user to `/404` if `guildId` or `channelId` are not numbers", () => {
|
|
|
|
cy.task("startMockServer", authenticationHandlers).setCookie(
|
|
|
|
"refreshToken",
|
|
|
|
"refresh-token",
|
2021-10-24 06:09:43 +02:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.visit("/application/abc/abc", {
|
|
|
|
failOnStatusCode: false,
|
2022-02-19 23:20:33 +01:00
|
|
|
})
|
2023-10-23 23:33:39 +02:00
|
|
|
.get("[data-cy=status-code]")
|
|
|
|
.contains("404")
|
2021-10-24 06:09:43 +02:00
|
|
|
})
|
2022-01-01 20:42:25 +01:00
|
|
|
|
|
|
|
it("should redirect the user to `/404` if `guildId` doesn't exist", () => {
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.task("startMockServer", [
|
2022-01-01 20:42:25 +01:00
|
|
|
...authenticationHandlers,
|
2023-10-23 23:33:39 +02:00
|
|
|
getChannelWithChannelIdHandler,
|
|
|
|
]).setCookie("refreshToken", "refresh-token")
|
2022-01-01 20:42:25 +01:00
|
|
|
cy.visit(`/application/123/${channelExample.id}`, {
|
2023-10-23 23:33:39 +02:00
|
|
|
failOnStatusCode: false,
|
2022-01-01 20:42:25 +01:00
|
|
|
})
|
2023-10-23 23:33:39 +02:00
|
|
|
.get("[data-cy=status-code]")
|
|
|
|
.contains("404")
|
2022-01-01 20:42:25 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it("should redirect the user to `/404` if `channelId` doesn't exist", () => {
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.task("startMockServer", [
|
2022-01-01 20:42:25 +01:00
|
|
|
...authenticationHandlers,
|
2023-10-23 23:33:39 +02:00
|
|
|
getGuildMemberWithGuildIdHandler,
|
|
|
|
]).setCookie("refreshToken", "refresh-token")
|
2022-01-01 20:42:25 +01:00
|
|
|
cy.visit(`/application/${guildExample.id}/123`, { failOnStatusCode: false })
|
2023-10-23 23:33:39 +02:00
|
|
|
.get("[data-cy=status-code]")
|
|
|
|
.contains("404")
|
2022-01-01 20:42:25 +01:00
|
|
|
})
|
2021-10-24 06:09:43 +02:00
|
|
|
})
|
2022-08-23 21:51:20 +02:00
|
|
|
|
|
|
|
export {}
|