Skip to content

Commit

Permalink
dev: Fix cypress specs after update
Browse files Browse the repository at this point in the history
  • Loading branch information
kschiffer committed Jun 27, 2023
1 parent 8cdc5a8 commit 26c307b
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 170 deletions.
1 change: 0 additions & 1 deletion cypress/downloads/cups.key

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion cypress/downloads/tc.key

This file was deleted.

2 changes: 1 addition & 1 deletion cypress/e2e/console/auth/login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Account App login', () => {

cy.get('header').within(() => {
cy.findByRole('link')
.should('have.attr', 'href', `${Cypress.config('accountAppRootPath')}/`)
.should('have.attr', 'href', Cypress.config('accountAppRootPath'))
.findByRole('img')
.should('be.visible')
.should('have.attr', 'src', `${Cypress.config('accountAppAssetsRootPath')}/account.svg`)
Expand Down
49 changes: 3 additions & 46 deletions cypress/e2e/console/devices/import.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { generateJoinServerOnlyConfig } from '../../../support/utils'

const userId = 'import-devices-test-user'
const user = {
ids: { user_id: userId },
Expand Down Expand Up @@ -59,7 +57,7 @@ describe('End device messaging', () => {
cy.findByTestId('notification')
.findByText('All end devices imported successfully')
.should('be.visible')
cy.findByRole('button', { name: 'Proceed to end device list' }).click()
cy.findByRole('link', { name: 'Proceed to end device list' }).click()
cy.location('pathname').should(
'eq',
`${Cypress.config('consoleRootPath')}/applications/${appId}/devices`,
Expand Down Expand Up @@ -94,7 +92,7 @@ describe('End device messaging', () => {
.should('be.visible')
.findByText('All end devices imported successfully')
.should('be.visible')
cy.findByRole('button', { name: 'Proceed to end device list' }).click()
cy.findByRole('link', { name: 'Proceed to end device list' }).click()
cy.location('pathname').should(
'eq',
`${Cypress.config('consoleRootPath')}/applications/${appId}/devices`,
Expand Down Expand Up @@ -157,7 +155,7 @@ describe('End device messaging', () => {
cy.findByTestId('notification')
.findByText('All end devices imported successfully')
.should('be.visible')
cy.findByRole('button', { name: 'Proceed to end device list' }).click()
cy.findByRole('link', { name: 'Proceed to end device list' }).click()
cy.location('pathname').should(
'eq',
`${Cypress.config('consoleRootPath')}/applications/${appId}/devices`,
Expand Down Expand Up @@ -209,45 +207,4 @@ describe('End device messaging', () => {
})
})
})

describe('Join Server only', () => {
before(() => {
cy.dropAndSeedDatabase()
cy.createUser(user)
cy.createApplication(application, userId)
})

beforeEach(() => {
cy.augmentStackConfig(generateJoinServerOnlyConfig)
cy.loginConsole({ user_id: user.ids.user_id, password: user.password })
cy.visit(`${Cypress.config('consoleRootPath')}/applications/${appId}/devices/import`)
})

it('allows importing on join server only deployments', () => {
cy.findByText('Import end devices').should('be.visible')
cy.findByLabelText('File format').selectOption('The Things Stack JSON')

const devicesFile = 'successful-devices.json'
cy.findByLabelText('File').attachFile(devicesFile)
cy.findByRole('button', { name: 'Import end devices' }).click()
cy.findByText('0 of 3 (0.00% finished)')
cy.findByText('Operation finished')
cy.findByText('3 of 3 (100.00% finished)')
cy.findByTestId('notification')
.should('be.visible')
.findByText('All end devices imported successfully')
.should('be.visible')
cy.findByRole('button', { name: 'Proceed to end device list' }).click()
cy.location('pathname').should(
'eq',
`${Cypress.config('consoleRootPath')}/applications/${appId}/devices`,
)
cy.findByTestId('error-notification').should('not.exist')
cy.findByText('migration-test-device').should('be.visible')
cy.findByText('some-nice-id').should('be.visible')
cy.findByText('this-is-test-id').should('be.visible').click()
cy.findByRole('heading', { name: /Test Device/ }).should('be.visible')
cy.findByTestId('error-notification').should('not.exist')
})
})
})
2 changes: 1 addition & 1 deletion cypress/e2e/console/devices/onboarding/claiming.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('End device repository claiming', () => {
cy.findByLabelText('JoinEUI').type(`${device3.joinEui}{enter}`)
cy.findByLabelText('DevEUI').type(device3.devEui)
cy.findByLabelText('Claim authentication code').type(device3.cac)
cy.findByLabelText('Claim authentication code').clear()
cy.findByLabelText('End device ID').clear()
cy.findByLabelText('End device ID').type(device3.id)
cy.findByLabelText('View registered end device').check()
cy.findByRole('button', { name: 'Register end device' }).click()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@ describe('End device repository manual registration', () => {

beforeEach(() => {
cy.loginConsole({ user_id: user.ids.user_id, password: user.password })
cy.visit(
`${Cypress.config('consoleRootPath')}/applications/${appId}/devices/add/repository`,
)
cy.visit(`${Cypress.config('consoleRootPath')}/applications/${appId}/devices/add`)
})

it('displays UI elements in place', () => {
Expand Down Expand Up @@ -443,9 +441,7 @@ describe('End device repository manual registration', () => {
})

cy.loginConsole({ user_id: user.ids.user_id, password: user.password })
cy.visit(
`${Cypress.config('consoleRootPath')}/applications/${appId}/devices/add/repository`,
)
cy.visit(`${Cypress.config('consoleRootPath')}/applications/${appId}/devices/add`)
})

it('validates before submitting an empty form', () => {
Expand All @@ -465,7 +461,7 @@ describe('End device repository manual registration', () => {

cy.location('pathname').should(
'eq',
`${Cypress.config('consoleRootPath')}/applications/${appId}/devices/add/repository`,
`${Cypress.config('consoleRootPath')}/applications/${appId}/devices/add`,
)

cy.findErrorByLabelText('Device address')
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/console/packet-broker/registration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ describe('Packet Broker registration', () => {
cy.loginConsole({ user_id: user.ids.user_id, password: user.password })

cy.visit(`${Cypress.config('consoleRootPath')}/admin/packet-broker`)
cy.location('pathname').should('eq', `${Cypress.config('consoleRootPath')}/`)
cy.location('pathname').should('eq', Cypress.config('consoleRootPath'))

cy.visit(`${Cypress.config('consoleRootPath')}/admin/packet-broker/networks/19`)
cy.location('pathname').should('eq', `${Cypress.config('consoleRootPath')}/`)
cy.location('pathname').should('eq', Cypress.config('consoleRootPath'))
})

it('displays a notification when Packet Broker is not set up', () => {
Expand Down
17 changes: 13 additions & 4 deletions cypress/e2e/console/shared/connection-losses.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ describe('Connection loss detection', () => {
cy.loginConsole({ user_id: user.ids.user_id, password: user.password })
cy.visit(Cypress.config('consoleRootPath'))
cy.findByText('Welcome to the Console!').should('be.visible')
cy.intercept('/api/v3/application*', { forceNetworkError: true })
cy.intercept('/api/v3/auth_info', { times: 2 }, { forceNetworkError: true })

cy.intercept('/api/v3/application*', { forceNetworkError: true }).as('offlineIntercept')
cy.intercept('/api/v3/auth_info', { times: 2 }, { forceNetworkError: true }).as(
'reconnectionIntercept',
)

cy.get('header').within(() => {
cy.findByRole('link', { name: /Applications/ }).click()
Expand All @@ -41,13 +44,19 @@ describe('Connection loss detection', () => {
cy.findByText(/Connection issues/).should('be.visible')
cy.findByText(/Offline/).should('be.visible')
})

cy.findByTestId('toast-notification')
.as('offlineToast')
.findByText(/offline/)
.should('be.visible')

cy.get('@offlineToast', { timeout: 20000 }).should('not.be.visible')
// Use an assertion to check that the 'offline' toast notification is no longer in the DOM.
cy.get('@offlineToast').should('not.exist')

// After the 'offline' toast has disappeared, wait for the reconnection intercept to resolve.
cy.wait('@reconnectionIntercept')

// Now the 'online' toast should appear.
cy.findByTestId('toast-notification')
.findByText(/online/)
.should('be.visible')
Expand All @@ -70,7 +79,7 @@ describe('Connection loss detection', () => {

cy.get('footer').within(() => {
// Connection issue note will appear in the footer and
// dissappear shortly thereafter.
// disappear shortly thereafter.
cy.findByText(/Connection issues/).should('be.visible')
cy.findByText(/Connection issues/).should('not.exist')

Expand Down
16 changes: 8 additions & 8 deletions cypress/e2e/console/shared/header.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
// limitations under the License.

describe('Header', () => {
before(() => {
cy.dropAndSeedDatabase()
})
describe('Console logout', () => {
const logout = userName => {
cy.get('header').within(() => {
Expand Down Expand Up @@ -49,14 +52,11 @@ describe('Header', () => {
const baseUrl = Cypress.config('baseUrl')
const consoleRootPath = Cypress.config('consoleRootPath')
const accountAppRootPath = Cypress.config('accountAppRootPath')
cy.server()
cy.route({
method: 'POST',
url: `${baseUrl}${consoleRootPath}/api/auth/logout`,
onRequest: req => {
expect(req.request.headers).to.have.property('X-CSRF-Token')
},
})

cy.intercept('POST', `${baseUrl}${consoleRootPath}/api/auth/logout`, req => {
// Asserting on the request headers
expect(req.headers).to.have.property('x-csrf-token')
}).as('logout')

cy.createUser(user)
cy.loginConsole({ user_id: user.ids.user_id, password: user.password })
Expand Down

0 comments on commit 26c307b

Please sign in to comment.