feat(pages): add /application/[guildId]/[channelId]
(#4)
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
import { channel } from '../../../../fixtures/channels/channel'
|
||||
import { guild } from '../../../../fixtures/guilds/guild'
|
||||
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'
|
||||
|
||||
@ -11,15 +14,19 @@ describe('Pages > /application/guilds/create', () => {
|
||||
it('should succeeds and create the guild', () => {
|
||||
cy.task('startMockServer', [
|
||||
...authenticationHandlers,
|
||||
postGuildsHandler
|
||||
postGuildsHandler,
|
||||
getGuildsHandler,
|
||||
getGuildMemberWithGuildIdHandler,
|
||||
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(guild.name)
|
||||
cy.get('[data-cy=input-name]').type(guildExample.name)
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.location('pathname').should(
|
||||
'eq',
|
||||
`/application/${guild.id}/${channel.id}`
|
||||
`/application/${guildExample.id}/${channelExample.id}`
|
||||
)
|
||||
})
|
||||
|
||||
@ -30,7 +37,7 @@ describe('Pages > /application/guilds/create', () => {
|
||||
)
|
||||
cy.visit('/application/guilds/create')
|
||||
cy.get('#error-name').should('not.exist')
|
||||
cy.get('[data-cy=input-name]').type(guild.name)
|
||||
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.')
|
||||
})
|
||||
|
@ -1,45 +1,39 @@
|
||||
import { guildExample, guildExample2 } from '../../../../fixtures/guilds/guild'
|
||||
import {
|
||||
getGuildsPublicEmptyHandler,
|
||||
getGuildsPublicHandler,
|
||||
getGuildsPublicSearchHandler
|
||||
} from '../../../../fixtures/guilds/public/get'
|
||||
import { authenticationHandlers } from '../../../../fixtures/handler'
|
||||
import { API_URL } from '../../../../../tools/api'
|
||||
|
||||
describe('Pages > /application/guilds/join', () => {
|
||||
beforeEach(() => {
|
||||
cy.task('stopMockServer')
|
||||
})
|
||||
|
||||
it('should shows no guild if there are no public guilds', () => {
|
||||
cy.task('startMockServer', [
|
||||
...authenticationHandlers,
|
||||
getGuildsPublicEmptyHandler
|
||||
]).setCookie('refreshToken', 'refresh-token')
|
||||
cy.visit('/application/guilds/join')
|
||||
cy.get('.guilds-list').children().should('have.length', 0)
|
||||
})
|
||||
|
||||
it('should shows loader with internal api server error', () => {
|
||||
cy.task('startMockServer', [...authenticationHandlers]).setCookie(
|
||||
'refreshToken',
|
||||
'refresh-token'
|
||||
)
|
||||
cy.visit('/application/guilds/join')
|
||||
cy.get('.guilds-list').children().should('have.length', 1)
|
||||
cy.get('[data-testid=progress-spinner]').should('be.visible')
|
||||
})
|
||||
|
||||
it('should shows all the guilds', () => {
|
||||
cy.task('startMockServer', [
|
||||
...authenticationHandlers,
|
||||
getGuildsPublicHandler
|
||||
]).setCookie('refreshToken', 'refresh-token')
|
||||
cy.visit('/application/guilds/join')
|
||||
cy.get('.guilds-list').children().should('have.length', 2)
|
||||
cy.get('.guilds-list [data-cy=guild-name]:first').should(
|
||||
'have.text',
|
||||
'GuildExample'
|
||||
cy.intercept(`${API_URL}${getGuildsPublicHandler.url}*`).as(
|
||||
'getGuildsPublicHandler'
|
||||
)
|
||||
cy.intercept(`/_next/*`).as('nextStaticAndImages')
|
||||
cy.visit('/application/guilds/join')
|
||||
cy.wait(['@getGuildsPublicHandler', '@nextStaticAndImages']).then(() => {
|
||||
cy.get('[data-cy=application-title]').should('have.text', 'Join a Guild')
|
||||
cy.get('.guilds-public-list').children().should('have.length', 2)
|
||||
cy.get('.guilds-public-list [data-cy=guild-name]:first').should(
|
||||
'have.text',
|
||||
guildExample.name
|
||||
)
|
||||
cy.get('.guilds-public-list [data-cy=guild-name]:last').should(
|
||||
'have.text',
|
||||
guildExample2.name
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('should shows the searched guild', () => {
|
||||
@ -48,8 +42,41 @@ describe('Pages > /application/guilds/join', () => {
|
||||
getGuildsPublicSearchHandler
|
||||
]).setCookie('refreshToken', 'refresh-token')
|
||||
cy.visit('/application/guilds/join')
|
||||
cy.get('[data-cy=search-guild-input]').type('app')
|
||||
cy.get('.guilds-list').children().should('have.length', 1)
|
||||
cy.get('.guilds-list [data-cy=guild-name]:first').should('have.text', 'app')
|
||||
cy.intercept(`${API_URL}${getGuildsPublicHandler.url}*`).as(
|
||||
'getGuildsPublicHandler'
|
||||
)
|
||||
cy.intercept(`/_next/*`).as('nextStaticAndImages')
|
||||
cy.wait(['@getGuildsPublicHandler', '@nextStaticAndImages']).then(() => {
|
||||
cy.get('[data-cy=search-guild-input]').type(guildExample2.name)
|
||||
cy.get('.guilds-public-list').children().should('have.length', 1)
|
||||
cy.get('.guilds-public-list [data-cy=guild-name]:first').should(
|
||||
'have.text',
|
||||
guildExample2.name
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('should shows no guild if there are no public guilds', () => {
|
||||
cy.task('startMockServer', [
|
||||
...authenticationHandlers,
|
||||
getGuildsPublicEmptyHandler
|
||||
]).setCookie('refreshToken', 'refresh-token')
|
||||
cy.intercept(`${API_URL}${getGuildsPublicEmptyHandler.url}*`).as(
|
||||
'getGuildsPublicEmptyHandler'
|
||||
)
|
||||
cy.visit('/application/guilds/join')
|
||||
cy.wait('@getGuildsPublicEmptyHandler').then(() => {
|
||||
cy.get('.guilds-public-list').children().should('have.length', 0)
|
||||
})
|
||||
})
|
||||
|
||||
it('should shows loader with internal api server error', () => {
|
||||
cy.task('startMockServer', [...authenticationHandlers]).setCookie(
|
||||
'refreshToken',
|
||||
'refresh-token'
|
||||
)
|
||||
cy.visit('/application/guilds/join')
|
||||
cy.get('.guilds-public-list').children().should('have.length', 1)
|
||||
cy.get('[data-testid=progress-spinner]').should('be.visible')
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user