From 14cf1b103ed89c819cfb63e1fd09fd7efc0eb014 Mon Sep 17 00:00:00 2001 From: cstns Date: Mon, 14 Oct 2024 19:45:04 +0300 Subject: [PATCH] add e2e tests for the notification pill --- .../fixtures/notifications/announcement.json | 11 ++++ .../cypress/tests/notifications.spec.js | 56 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 test/e2e/frontend/cypress/fixtures/notifications/announcement.json diff --git a/test/e2e/frontend/cypress/fixtures/notifications/announcement.json b/test/e2e/frontend/cypress/fixtures/notifications/announcement.json new file mode 100644 index 0000000000..8aac7f2380 --- /dev/null +++ b/test/e2e/frontend/cypress/fixtures/notifications/announcement.json @@ -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\"}}" + } +} diff --git a/test/e2e/frontend/cypress/tests/notifications.spec.js b/test/e2e/frontend/cypress/tests/notifications.spec.js index 24546874d7..5d6fc77987 100644 --- a/test/e2e/frontend/cypress/tests/notifications.spec.js +++ b/test/e2e/frontend/cypress/tests/notifications.spec.js @@ -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') @@ -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')