test(e2e): remove usage of @nextStaticAndImages intercept

This commit is contained in:
Divlo 2022-06-29 06:50:35 +02:00
parent 8f9ff8de07
commit db4ab7cf6f
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9
2 changed files with 26 additions and 38 deletions

View File

@ -41,9 +41,8 @@ describe('Pages > /application/[guildId]/[channelId]', () => {
getGuildsHandler getGuildsHandler
]).setCookie('refreshToken', 'refresh-token') ]).setCookie('refreshToken', 'refresh-token')
cy.intercept(`${API_URL}${getGuildsHandler.url}*`).as('getGuildsHandler') cy.intercept(`${API_URL}${getGuildsHandler.url}*`).as('getGuildsHandler')
cy.intercept(`/_next/*`).as('nextStaticAndImages')
cy.visit(`/application/${guildExample.id}/${channelExample.id}`) cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
cy.wait(['@getGuildsHandler', '@nextStaticAndImages']).then(() => { cy.wait(['@getGuildsHandler']).then(() => {
cy.get('[data-cy=application-title]').should( cy.get('[data-cy=application-title]').should(
'have.text', 'have.text',
`# ${channelExample.name}` `# ${channelExample.name}`
@ -74,9 +73,8 @@ describe('Pages > /application/[guildId]/[channelId]', () => {
getGuildsHandler getGuildsHandler
]).setCookie('refreshToken', 'refresh-token') ]).setCookie('refreshToken', 'refresh-token')
cy.intercept(`${API_URL}${getGuildsHandler.url}*`).as('getGuildsHandler') cy.intercept(`${API_URL}${getGuildsHandler.url}*`).as('getGuildsHandler')
cy.intercept(`/_next/*`).as('nextStaticAndImages')
cy.visit(`/application/${guildExample.id}/${channelExample.id}`) cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
cy.wait(['@getGuildsHandler', '@nextStaticAndImages']).then(() => { cy.wait(['@getGuildsHandler']).then(() => {
cy.get('[data-cy=application-title]').should( cy.get('[data-cy=application-title]').should(
'have.text', 'have.text',
`# ${channelExample.name}` `# ${channelExample.name}`
@ -103,21 +101,18 @@ describe('Pages > /application/[guildId]/[channelId]', () => {
cy.intercept(`${API_URL}${getChannelsWithGuildIdHandler.url}*`).as( cy.intercept(`${API_URL}${getChannelsWithGuildIdHandler.url}*`).as(
'getChannelsWithGuildIdHandler' 'getChannelsWithGuildIdHandler'
) )
cy.intercept(`/_next/*`).as('nextStaticAndImages')
cy.visit(`/application/${guildExample.id}/${channelExample.id}`) cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
cy.wait(['@getChannelsWithGuildIdHandler', '@nextStaticAndImages']).then( cy.wait(['@getChannelsWithGuildIdHandler']).then(() => {
() => { cy.get('.channels-list').children().should('have.length', 2)
cy.get('.channels-list').children().should('have.length', 2) cy.get('.channels-list [data-cy=channel-name]:first').should(
cy.get('.channels-list [data-cy=channel-name]:first').should( 'have.text',
'have.text', `# ${channelExample.name}`
`# ${channelExample.name}` )
) cy.get('.channels-list [data-cy=channel-name]:last').should(
cy.get('.channels-list [data-cy=channel-name]:last').should( 'have.text',
'have.text', `# ${channelExample2.name}`
`# ${channelExample2.name}` )
) })
}
)
}) })
it('should succeeds and display the messages correctly', () => { it('should succeeds and display the messages correctly', () => {
@ -146,11 +141,9 @@ describe('Pages > /application/[guildId]/[channelId]', () => {
cy.intercept(`${API_URL}${getMessagesUploadsDownloadHandler.url}`).as( cy.intercept(`${API_URL}${getMessagesUploadsDownloadHandler.url}`).as(
'getMessagesUploadsDownloadHandler' 'getMessagesUploadsDownloadHandler'
) )
cy.intercept(`/_next/*`).as('nextStaticAndImages')
cy.visit(`/application/${guildExample.id}/${channelExample.id}`) cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
cy.wait([ cy.wait([
'@getMessagesWithChannelIdHandler', '@getMessagesWithChannelIdHandler',
'@nextStaticAndImages',
'@getMessagesUploadsImageHandler', '@getMessagesUploadsImageHandler',
'@getMessagesUploadsAudioHandler', '@getMessagesUploadsAudioHandler',
'@getMessagesUploadsVideoHandler', '@getMessagesUploadsVideoHandler',
@ -226,21 +219,18 @@ describe('Pages > /application/[guildId]/[channelId]', () => {
cy.intercept(`${API_URL}${getMembersWithGuildIdHandler.url}*`).as( cy.intercept(`${API_URL}${getMembersWithGuildIdHandler.url}*`).as(
'getMembersWithGuildIdHandler' 'getMembersWithGuildIdHandler'
) )
cy.intercept(`/_next/*`).as('nextStaticAndImages')
cy.visit(`/application/${guildExample.id}/${channelExample.id}`) cy.visit(`/application/${guildExample.id}/${channelExample.id}`)
cy.wait(['@getMembersWithGuildIdHandler', '@nextStaticAndImages']).then( cy.wait(['@getMembersWithGuildIdHandler']).then(() => {
() => { cy.get('.members-list').should('not.be.visible')
cy.get('.members-list').should('not.be.visible') cy.get('[data-cy=icon-button-right-sidebar-members]').click()
cy.get('[data-cy=icon-button-right-sidebar-members]').click() cy.get('.members-list').should('be.visible')
cy.get('.members-list').should('be.visible') cy.get('[data-cy=members-title]').should('have.text', 'Member(s)')
cy.get('[data-cy=members-title]').should('have.text', 'Member(s)') cy.get('.members-list').children().should('have.length', 1)
cy.get('.members-list').children().should('have.length', 1) cy.get('.members-list [data-cy=member-user-name]:first').should(
cy.get('.members-list [data-cy=member-user-name]:first').should( 'have.text',
'have.text', memberExampleComplete.user.name
memberExampleComplete.user.name )
) })
}
)
}) })
it('should redirect the user to `/404` if `guildId` or `channelId` are not numbers', () => { it('should redirect the user to `/404` if `guildId` or `channelId` are not numbers', () => {

View File

@ -20,9 +20,8 @@ describe('Pages > /application/guilds/join', () => {
cy.intercept(`${API_URL}${getGuildsPublicHandler.url}*`).as( cy.intercept(`${API_URL}${getGuildsPublicHandler.url}*`).as(
'getGuildsPublicHandler' 'getGuildsPublicHandler'
) )
cy.intercept(`/_next/*`).as('nextStaticAndImages')
cy.visit('/application/guilds/join') cy.visit('/application/guilds/join')
cy.wait(['@getGuildsPublicHandler', '@nextStaticAndImages']).then(() => { cy.wait(['@getGuildsPublicHandler']).then(() => {
cy.get('[data-cy=application-title]').should('have.text', 'Join a Guild') 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').children().should('have.length', 2)
cy.get('.guilds-public-list [data-cy=guild-name]:first').should( cy.get('.guilds-public-list [data-cy=guild-name]:first').should(
@ -45,8 +44,7 @@ describe('Pages > /application/guilds/join', () => {
cy.intercept(`${API_URL}${getGuildsPublicHandler.url}*`).as( cy.intercept(`${API_URL}${getGuildsPublicHandler.url}*`).as(
'getGuildsPublicHandler' 'getGuildsPublicHandler'
) )
cy.intercept(`/_next/*`).as('nextStaticAndImages') cy.wait(['@getGuildsPublicHandler']).then(() => {
cy.wait(['@getGuildsPublicHandler', '@nextStaticAndImages']).then(() => {
cy.get('[data-cy=search-guild-input]').type(guildExample2.name) 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').children().should('have.length', 1)
cy.get('.guilds-public-list [data-cy=guild-name]:first').should( cy.get('.guilds-public-list [data-cy=guild-name]:first').should(