Skip to content

Commit

Permalink
add e2e tests for the notification pill
Browse files Browse the repository at this point in the history
  • Loading branch information
cstns committed Oct 14, 2024
1 parent 14d7cb1 commit 14cf1b1
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/e2e/frontend/cypress/fixtures/notifications/announcement.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "EgJbI5fg9k",
"type": "announcement",
"createdAt": null,
"read": false,
"data": {
"title": "Platform Wide Notification",
"message": "Hello, I'm your friendly neighborhood platform wide notification.",
"to": "{\"name\":\"Application\",\"params\":{\"id\":\"application-id\"}}"
}
}
56 changes: 56 additions & 0 deletions test/e2e/frontend/cypress/tests/notifications.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const aliceInviteToATeam = require('../fixtures/notifications/alice-invites-to-ateam.json')
const announcement = require('../fixtures/notifications/announcement.json')
const bobInviteToATeam = require('../fixtures/notifications/bob-invites-to-bteam.json')
const eddyAcceptedInvite = require('../fixtures/notifications/eddy-accepted-invite-to-ateam.json')
const instanceCrash = require('../fixtures/notifications/instance-crashed.json')
Expand Down Expand Up @@ -250,6 +251,61 @@ describe('FlowForge - Notifications', () => {
})
})

describe('Platform Announcements', () => {
it('appear as notification messages', () => {
cy.login('alice', 'aaPassword')

cy.intercept('/api/*/user').as('getUser')
cy.intercept('/api/*/settings').as('getSettings')
cy.intercept('/api/*/user/teams').as('getTeams')
cy.intercept('/api/*/user/notifications', {
meta: {},
count: 1,
notifications: [
{
...announcement,
createdAt: new Date().setTime((new Date()).getTime() - 3600000)
}
]
}).as('getNotifications')

cy.intercept('PUT', '/api/*/user/notifications/*', {}).as('markInvitationRead')

cy.intercept('/api/*/admin/stats').as('getAdminStats')
cy.intercept('/api/*/admin/license').as('getAdminLicense')

cy.visit('/')

cy.wait('@getUser')
cy.wait('@getSettings')
cy.wait('@getTeams')
cy.wait('@getNotifications')

cy.get('[data-el="desktop-nav-right"]').within(() => {
cy.get('[data-el="notifications-button"]')
.should('exist')
.contains(1)

cy.get('[data-el="notifications-button"]').click()
})

cy.get('[data-el="right-drawer"]').should('be.visible')

cy.get('[data-el="right-drawer"]').within(() => {
cy.get('[data-el="notifications-drawer"]')

cy.get('[data-el="generic-notification"]').should('have.length', 1)

cy.get('[data-el="generic-notification"]').contains('Platform Wide Notification')
cy.get('[data-el="generic-notification"]').contains('Hello, I\'m your friendly neighborhood platform wide notification.')

cy.get('[data-el="generic-notification"]').contains('Platform Wide Notification').click()
cy.wait('@markInvitationRead')
cy.url().should('match', /application\/application-id\/instances/i)
})
})
})

describe('Can preform bulk actions', () => {
beforeEach(() => {
cy.login('alice', 'aaPassword')
Expand Down

0 comments on commit 14cf1b1

Please sign in to comment.