2023-10-23 23:33:39 +02:00
|
|
|
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"
|
2022-01-01 20:42:25 +01:00
|
|
|
|
|
|
|
const applicationPaths = [
|
2023-10-23 23:33:39 +02:00
|
|
|
"/application",
|
2022-01-01 20:42:25 +01:00
|
|
|
`/application/users/${userExample.id}`,
|
2022-03-05 18:22:30 +01:00
|
|
|
`/application/users/settings`,
|
2023-10-23 23:33:39 +02:00
|
|
|
"/application/guilds/create",
|
|
|
|
"/application/guilds/join",
|
2022-03-05 18:22:30 +01:00
|
|
|
`/application/${guildExample.id}/${channelExample.id}`,
|
|
|
|
`/application/${guildExample.id}/${channelExample.id}/settings`,
|
|
|
|
`/application/${guildExample.id}/channels/create`,
|
2023-10-23 23:33:39 +02:00
|
|
|
`/application/${guildExample.id}/settings`,
|
2022-01-01 20:42:25 +01:00
|
|
|
]
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
describe("Common > application/authentication", () => {
|
2022-01-01 20:42:25 +01:00
|
|
|
beforeEach(() => {
|
2023-10-23 23:33:39 +02:00
|
|
|
cy.task("stopMockServer")
|
2022-01-01 20:42:25 +01:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should redirect the user to `/authentication/signin` if not signed in", () => {
|
2022-01-01 20:42:25 +01:00
|
|
|
for (const applicationPath of applicationPaths) {
|
|
|
|
cy.visit(applicationPath)
|
2023-10-23 23:33:39 +02:00
|
|
|
.location("pathname")
|
|
|
|
.should("eq", "/authentication/signin")
|
2022-01-01 20:42:25 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should not redirect the user if signed in", () => {
|
|
|
|
cy.task("startMockServer", [
|
2022-01-01 20:42:25 +01:00
|
|
|
...authenticationHandlers,
|
|
|
|
getGuildMemberWithGuildIdHandler,
|
2022-02-19 23:20:33 +01:00
|
|
|
getChannelWithChannelIdHandler,
|
2023-10-23 23:33:39 +02:00
|
|
|
getUserByIdHandler,
|
|
|
|
]).setCookie("refreshToken", "refresh-token")
|
2022-01-01 20:42:25 +01:00
|
|
|
for (const applicationPath of applicationPaths) {
|
|
|
|
cy.visit(applicationPath)
|
2023-10-23 23:33:39 +02:00
|
|
|
.location("pathname")
|
|
|
|
.should("eq", applicationPath)
|
2022-01-01 20:42:25 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2022-08-23 21:51:20 +02:00
|
|
|
|
|
|
|
export {}
|