2023-10-23 23:33:39 +02:00
|
|
|
import { deleteLeaveMembersWithGuildIdHandler } from "../../../../fixtures/guilds/[guildId]/members/leave"
|
|
|
|
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 { authenticationHandlers } from "../../../../fixtures/handler"
|
|
|
|
import { API_URL } from "../../../../../tools/api"
|
|
|
|
import { deleteGuildWithGuildIdHandler } from "../../../../fixtures/guilds/[guildId]/delete"
|
2022-03-05 18:22:30 +01:00
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
describe("Pages > /application/[guildId]/settings", () => {
|
2022-03-05 18:22:30 +01:00
|
|
|
beforeEach(() => {
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.task("stopMockServer")
|
2022-03-05 18:22:30 +01:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should succeeds and display correctly the settings of the guild (member is owner)", () => {
|
|
|
|
cy.task("startMockServer", [
|
2022-03-05 18:22:30 +01:00
|
|
|
...authenticationHandlers,
|
2023-10-23 23:33:39 +02:00
|
|
|
getGuildMemberWithGuildIdHandler,
|
|
|
|
]).setCookie("refreshToken", "refresh-token")
|
2022-03-05 18:22:30 +01:00
|
|
|
cy.visit(`/application/${guildExample.id}/settings`)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=guild-name-input]").should("have.value", guildExample.name)
|
|
|
|
cy.get("[data-cy=guild-description-input]").should(
|
|
|
|
"have.value",
|
|
|
|
guildExample.description,
|
2022-03-05 18:22:30 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
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")
|
2022-03-05 18:22:30 +01:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should succeeds and display correctly the settings of the guild (member is not owner)", () => {
|
|
|
|
cy.task("startMockServer", [
|
2022-03-05 18:22:30 +01:00
|
|
|
...authenticationHandlers,
|
2023-10-23 23:33:39 +02:00
|
|
|
getGuildMemberNotOwnerWithGuildIdHandler,
|
|
|
|
]).setCookie("refreshToken", "refresh-token")
|
2022-03-05 18:22:30 +01:00
|
|
|
cy.visit(`/application/${guildExample.id}/settings`)
|
2023-10-23 23:33:39 +02:00
|
|
|
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")
|
2022-03-05 18:22:30 +01:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should succeeds and leave the guild (member is not owner)", () => {
|
|
|
|
cy.task("startMockServer", [
|
2022-03-05 18:22:30 +01:00
|
|
|
...authenticationHandlers,
|
|
|
|
getGuildMemberNotOwnerWithGuildIdHandler,
|
2023-10-23 23:33:39 +02:00
|
|
|
deleteLeaveMembersWithGuildIdHandler,
|
|
|
|
]).setCookie("refreshToken", "refresh-token")
|
2022-03-05 18:22:30 +01:00
|
|
|
cy.intercept(`${API_URL}${deleteLeaveMembersWithGuildIdHandler.url}*`).as(
|
2023-10-23 23:33:39 +02:00
|
|
|
"deleteLeaveMembersWithGuildIdHandler",
|
2022-03-05 18:22:30 +01:00
|
|
|
)
|
|
|
|
cy.visit(`/application/${guildExample.id}/settings`)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=button-leave-guild-settings]").click()
|
|
|
|
cy.wait("@deleteLeaveMembersWithGuildIdHandler").then(() => {
|
|
|
|
cy.location("pathname").should("eq", "/application")
|
2022-03-05 18:22:30 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should succeeds and delete the guild", () => {
|
|
|
|
cy.task("startMockServer", [
|
2022-03-05 18:22:30 +01:00
|
|
|
...authenticationHandlers,
|
|
|
|
getGuildMemberWithGuildIdHandler,
|
2023-10-23 23:33:39 +02:00
|
|
|
deleteGuildWithGuildIdHandler,
|
|
|
|
]).setCookie("refreshToken", "refresh-token")
|
2022-03-05 18:22:30 +01:00
|
|
|
cy.intercept(`${API_URL}${deleteGuildWithGuildIdHandler.url}*`).as(
|
2023-10-23 23:33:39 +02:00
|
|
|
"deleteGuildWithGuildIdHandler",
|
2022-03-05 18:22:30 +01:00
|
|
|
)
|
|
|
|
cy.visit(`/application/${guildExample.id}/settings`)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.get("[data-cy=button-delete-guild-settings]").click()
|
|
|
|
cy.get("[data-cy=confirm-popup-yes-button]").click()
|
|
|
|
cy.wait("@deleteGuildWithGuildIdHandler").then((interception) => {
|
2022-03-05 18:22:30 +01:00
|
|
|
expect(interception.response).to.not.be.eql(undefined)
|
|
|
|
if (interception.response !== undefined) {
|
|
|
|
expect(interception.response.statusCode).to.eq(200)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should redirect the user to `/404` if `guildId` is not a number", () => {
|
|
|
|
cy.task("startMockServer", authenticationHandlers).setCookie(
|
|
|
|
"refreshToken",
|
|
|
|
"refresh-token",
|
2022-03-05 18:22:30 +01:00
|
|
|
)
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.visit("/application/abc/settings", {
|
|
|
|
failOnStatusCode: false,
|
2022-03-05 18:22:30 +01:00
|
|
|
})
|
2023-10-23 23:33:39 +02:00
|
|
|
.get("[data-cy=status-code]")
|
|
|
|
.contains("404")
|
2022-03-05 18:22:30 +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", [...authenticationHandlers]).setCookie(
|
|
|
|
"refreshToken",
|
|
|
|
"refresh-token",
|
2022-03-05 18:22:30 +01:00
|
|
|
)
|
|
|
|
cy.visit(`/application/123/settings`, {
|
2023-10-23 23:33:39 +02:00
|
|
|
failOnStatusCode: false,
|
2022-03-05 18:22:30 +01:00
|
|
|
})
|
2023-10-23 23:33:39 +02:00
|
|
|
.get("[data-cy=status-code]")
|
|
|
|
.contains("404")
|
2022-03-05 18:22:30 +01:00
|
|
|
})
|
|
|
|
})
|
2022-08-23 21:51:20 +02:00
|
|
|
|
|
|
|
export {}
|