2
2
mirror of https://github.com/Thream/website.git synced 2024-07-21 09:28:32 +02:00
website/cypress/e2e/pages/application/guilds/create.cy.ts

47 lines
1.7 KiB
TypeScript
Raw Normal View History

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'
2021-10-26 16:38:55 +02:00
import { postGuildsHandler } from '../../../../fixtures/guilds/post'
import { authenticationHandlers } from '../../../../fixtures/handler'
describe('Pages > /application/guilds/create', () => {
beforeEach(() => {
cy.task('stopMockServer')
})
it('should succeeds and create the guild', () => {
cy.task('startMockServer', [
...authenticationHandlers,
postGuildsHandler,
getGuildsHandler,
getGuildMemberWithGuildIdHandler,
getChannelWithChannelIdHandler
2021-10-26 16:38:55 +02:00
]).setCookie('refreshToken', 'refresh-token')
cy.visit('/application/guilds/create')
cy.get('[data-cy=application-title]').should('have.text', 'Create a Guild')
2021-10-26 16:38:55 +02:00
cy.get('#error-name').should('not.exist')
cy.get('[data-cy=input-name]').type(guildExample.name)
2021-10-26 16:38:55 +02:00
cy.get('[data-cy=submit]').click()
cy.location('pathname').should(
'eq',
`/application/${guildExample.id}/${channelExample.id}`
2021-10-26 16:38:55 +02:00
)
})
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)
2021-10-26 16:38:55 +02:00
cy.get('[data-cy=submit]').click()
cy.get('#message').should('have.text', 'Error: Internal Server Error.')
})
})
export {}