2023-10-23 23:33:39 +02:00
|
|
|
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"
|
2021-10-26 16:38:55 +02:00
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
describe("Pages > /application/guilds/create", () => {
|
2021-10-26 16:38:55 +02:00
|
|
|
beforeEach(() => {
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.task("stopMockServer")
|
2021-10-26 16:38:55 +02:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should succeeds and create the guild", () => {
|
|
|
|
cy.task("startMockServer", [
|
2021-10-26 16:38:55 +02:00
|
|
|
...authenticationHandlers,
|
2022-01-01 20:42:25 +01:00
|
|
|
postGuildsHandler,
|
|
|
|
getGuildsHandler,
|
|
|
|
getGuildMemberWithGuildIdHandler,
|
2023-10-23 23:33:39 +02:00
|
|
|
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}`,
|
2021-10-26 16:38:55 +02:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should fails with internal api server error", () => {
|
|
|
|
cy.task("startMockServer", [...authenticationHandlers]).setCookie(
|
|
|
|
"refreshToken",
|
|
|
|
"refresh-token",
|
2021-10-26 16:38:55 +02:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
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.")
|
2021-10-26 16:38:55 +02:00
|
|
|
})
|
|
|
|
})
|
2022-08-23 21:51:20 +02:00
|
|
|
|
|
|
|
export {}
|