Skip to content

Commit

Permalink
Merge pull request #7293 from TheThingsNetwork/fix/e2e-tests-notifica…
Browse files Browse the repository at this point in the history
…tions

Fix toast component in e2e tests
  • Loading branch information
ryaplots authored Sep 13, 2024
2 parents ee7c2e9 + 1263ec7 commit e9460fd
Show file tree
Hide file tree
Showing 27 changed files with 129 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Packet Broker routing policies', () => {
cy.findByRole('button', { name: 'Save default gateway visibility' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.findByText('Default gateway visibility set')
.should('be.visible')
cy.get('@putCall').should('have.property', 'state', 'Complete')
Expand All @@ -67,7 +67,7 @@ describe('Packet Broker routing policies', () => {
cy.findByRole('button', { name: 'Save default gateway visibility' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.findByText('Default gateway visibility set')
.should('be.visible')
cy.get('@putCall').should('have.property', 'state', 'Complete')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Packet Broker routing policies', () => {
cy.findByRole('button', { name: 'Save routing configuration' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText('Default routing configuration set')
.should('be.visible')
Expand All @@ -71,7 +71,7 @@ describe('Packet Broker routing policies', () => {
cy.findByRole('button', { name: 'Save routing configuration' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText('Default routing configuration set')
.should('be.visible')
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('Packet Broker routing policies', () => {
cy.findByRole('button', { name: 'Save routing configuration' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText('Default routing configuration set')
.should('be.visible')
Expand All @@ -133,7 +133,7 @@ describe('Packet Broker routing policies', () => {
cy.findByRole('button', { name: 'Save routing configuration' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText('Default routing configuration set')
.should('be.visible')
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('Packet Broker routing policies', () => {
})

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText('Routing policy set')
.should('be.visible')
Expand Down Expand Up @@ -208,7 +208,7 @@ describe('Packet Broker routing policies', () => {
cy.findByRole('button', { name: 'Save routing policy' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText('Routing policy set')
.should('be.visible')
Expand All @@ -235,7 +235,7 @@ describe('Packet Broker routing policies', () => {
cy.findByRole('button', { name: 'Save routing policy' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText('Routing policy set')
.should('be.visible')
Expand Down
12 changes: 8 additions & 4 deletions cypress/e2e/console/applications/edit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Application general settings', () => {
cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText(`Application updated`)
.should('be.visible')
Expand All @@ -71,7 +71,7 @@ describe('Application general settings', () => {
cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText(`Application updated`)
.should('be.visible')
Expand All @@ -85,7 +85,9 @@ describe('Application general settings', () => {
cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification').findByText(`Application updated`).should('be.visible')
cy.findByTestId('toast-notification-success')
.findByText(`Application updated`)
.should('be.visible')
})

it('fails adding non-collaborator contact information', () => {
Expand Down Expand Up @@ -117,7 +119,9 @@ describe('Application general settings', () => {
cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification').findByText(`Application updated`).should('be.visible')
cy.findByTestId('toast-notification-success')
.findByText(`Application updated`)
.should('be.visible')
})

it('succeeds setting current user as contact', () => {
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/console/devices/device-overview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ describe('Device overview', () => {
cy.findByRole('button', { name: /Download MAC data/ }).click()
})
cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification').should('not.exist')
cy.findByTestId('toast-notification-success').should('not.exist')
})

it('succeeds showing warning when there is no MAC state', () => {
it('succeeds showing error when there is no MAC state', () => {
const response = {
ids: {
device_id: endDeviceId,
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('Device overview', () => {
cy.findByText('Download MAC data', { selector: 'h1' }).should('be.visible')
cy.findByRole('button', { name: /Download MAC data/ }).click()
})
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-error')
.findByText(`There was an error and MAC state could not be included in the MAC data`)
.should('be.visible')
})
Expand Down
22 changes: 16 additions & 6 deletions cypress/e2e/console/devices/edit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ describe('Device general settings', () => {
cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification').findByText(`End device updated`).should('be.visible')
cy.findByTestId('toast-notification-success')
.findByText(`End device updated`)
.should('be.visible')
})

it('succeeds editing Network layer', () => {
Expand All @@ -136,7 +138,9 @@ describe('Device general settings', () => {
})

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification').findByText(`End device updated`).should('be.visible')
cy.findByTestId('toast-notification-success')
.findByText(`End device updated`)
.should('be.visible')
})

it('succeeds editing Application layer', () => {
Expand All @@ -153,7 +157,7 @@ describe('Device general settings', () => {
})

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText(`End device updated`)
.should('be.visible')
Expand All @@ -177,7 +181,9 @@ describe('Device general settings', () => {
})

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification').findByText(`End device updated`).should('be.visible')
cy.findByTestId('toast-notification-success')
.findByText(`End device updated`)
.should('be.visible')
})

it('succeeds editing server adresses', () => {
Expand All @@ -187,7 +193,9 @@ describe('Device general settings', () => {
cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification').findByText(`End device updated`).should('be.visible')
cy.findByTestId('toast-notification-success')
.findByText(`End device updated`)
.should('be.visible')
})

it('succeeds adding end device attributes', () => {
Expand All @@ -201,7 +209,9 @@ describe('Device general settings', () => {
cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification').findByText(`End device updated`).should('be.visible')
cy.findByTestId('toast-notification-success')
.findByText(`End device updated`)
.should('be.visible')
})

it('succeeds deleting end device', () => {
Expand Down
4 changes: 3 additions & 1 deletion cypress/e2e/console/devices/messaging/edit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ describe('End device messaging', () => {

cy.findAllByRole('button', { name: 'Simulate uplink' }).filter('[type="submit"]').click()

cy.findByTestId('toast-notification').should('be.visible').and('contain', 'Uplink sent')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.and('contain', 'Uplink sent')

cy.findByTestId('error-notification').should('not.exist')
})
Expand Down
12 changes: 9 additions & 3 deletions cypress/e2e/console/devices/onboarding/claiming.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ describe('End device repository claiming', () => {
cy.wait('@claim-request')
.its('request.body')
.should('deep.equal', composeExpectedRequest(device1))
cy.findByTestId('toast-notification').findByText('End device registered').should('be.visible')
cy.findByTestId('toast-notification-success')
.findByText('End device registered')
.should('be.visible')
cy.findByRole('button', { name: 'Register end device' }).should('not.be.disabled')

cy.intercept('POST', '/api/v3/edcs/claim', composeClaimResponse(device2)).as('claim-request')
Expand Down Expand Up @@ -184,7 +186,9 @@ describe('End device repository claiming', () => {
.its('request.body')
.should('deep.equal', composeExpectedRequest(device1))
// Properly wait for the form to finish submitting.
cy.findByTestId('toast-notification').findByText('End device registered').should('be.visible')
cy.findByTestId('toast-notification-success')
.findByText('End device registered')
.should('be.visible')
cy.findByRole('button', { name: 'Register end device' }).should('not.be.disabled')

cy.intercept('POST', '/api/v3/edcs/claim', composeClaimResponse(device2)).as('claim-request')
Expand All @@ -200,7 +204,9 @@ describe('End device repository claiming', () => {
.its('request.body')
.should('deep.equal', composeExpectedRequest(device2))
// Properly wait for the form to finish submitting.
cy.findByTestId('toast-notification').findByText('End device registered').should('be.visible')
cy.findByTestId('toast-notification-success')
.findByText('End device registered')
.should('be.visible')
cy.findByRole('button', { name: 'Register end device' }).should('not.be.disabled')

cy.intercept('POST', '/api/v3/edcs/claim', composeClaimResponse(device3)).as('claim-request')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ describe('End device manual create', () => {

cy.findByRole('button', { name: 'Register end device' }).click()

cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.findByText('End device registered')
.should('be.visible')
cy.findByRole('button', { name: 'Register end device' }).should('not.be.disabled')
Expand All @@ -772,7 +772,7 @@ describe('End device manual create', () => {

cy.findByRole('button', { name: 'Register end device' }).click()

cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.findByText('End device registered')
.should('be.visible')
cy.findByRole('button', { name: 'Register end device' }).should('not.be.disabled')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ describe('End device repository manual registration', () => {

cy.findByRole('button', { name: 'Register end device' }).click()
cy.findByRole('button', { name: 'Register end device' }).should('not.be.disabled')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.findByText('End device registered')
.should('be.visible')

Expand Down Expand Up @@ -506,7 +506,7 @@ describe('End device repository manual registration', () => {
cy.findByLabelText('Register another end device of this type').check()

cy.findByRole('button', { name: 'Register end device' }).click()
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.findByText('End device registered')
.should('be.visible')
cy.findByRole('button', { name: 'Register end device' }).should('not.be.disabled')
Expand All @@ -521,7 +521,7 @@ describe('End device repository manual registration', () => {
cy.findByLabelText('Register another end device of this type').check()

cy.findByRole('button', { name: 'Register end device' }).click()
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.findByText('End device registered')
.should('be.visible')
cy.findByRole('button', { name: 'Register end device' }).should('not.be.disabled')
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/console/gateways/edit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ describe('Gateway general settings', () => {
cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification').findByText('Gateway updated').should('be.visible')
cy.findByTestId('toast-notification-success').findByText('Gateway updated').should('be.visible')
cy.reload()

cy.findByLabelText('Gateway name').should('have.value', newGatewayName)
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('Gateway general settings', () => {
})

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification').findByText('Gateway updated').should('be.visible')
cy.findByTestId('toast-notification-success').findByText('Gateway updated').should('be.visible')
cy.reload()

cy.findByText('LoRaWAN options', { selector: 'h3' })
Expand Down Expand Up @@ -266,7 +266,7 @@ describe('Gateway general settings', () => {
cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification').findByText(`Gateway updated`).should('be.visible')
cy.findByTestId('toast-notification-success').findByText(`Gateway updated`).should('be.visible')
})

it('succeeds setting current user as contact', () => {
Expand Down Expand Up @@ -317,7 +317,7 @@ describe('Gateway general settings', () => {
})

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification').findByText('Gateway updated').should('be.visible')
cy.findByTestId('toast-notification-success').findByText('Gateway updated').should('be.visible')
cy.reload()

cy.findByText('LoRaWAN options', { selector: 'h3' })
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/console/gateways/location/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('Gateway location create', () => {

cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText(`Location updated`)
.should('be.visible')
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/console/gateways/location/edit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('Gateway location', () => {
cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText(`Location updated`)
.should('be.visible')
Expand All @@ -94,7 +94,7 @@ describe('Gateway location', () => {
cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText(`Location updated`)
.should('be.visible')
Expand All @@ -113,7 +113,7 @@ describe('Gateway location', () => {
cy.findByRole('button', { name: 'Save changes' }).click()

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText(`Location updated`)
.should('be.visible')
Expand All @@ -132,7 +132,7 @@ describe('Gateway location', () => {
})

cy.findByTestId('error-notification').should('not.exist')
cy.findByTestId('toast-notification')
cy.findByTestId('toast-notification-success')
.should('be.visible')
.findByText(`Location deleted`)
.should('be.visible')
Expand Down
Loading

0 comments on commit e9460fd

Please sign in to comment.