From 83eaad88f5671027c2465eeef09560b9decf5f73 Mon Sep 17 00:00:00 2001 From: Jonathan Goulding <58443816+jonathangoulding@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:49:31 +0000 Subject: [PATCH] Add feature flag and link for system returns notifications (#2643) https://eaflood.atlassian.net/browse/WATER-4716 As part of the ongoing work to migrate the legacy ui pages into the system repo. We need to redirect the user to the newly created pages / journey when it is ready. This change adds a feature flag to the mangae page for the return notifications invitations link. When the feature flag is on it will redirect the user to the new page / journey built in system --- .env.example | 1 + src/internal/config.js | 1 + src/internal/modules/manage/lib/manage-nav.js | 15 +++++++++--- .../modules/manage/lib/manage-nav.test.js | 23 ++++++++++++++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 4d3f4fb94..999e217ea 100644 --- a/.env.example +++ b/.env.example @@ -55,6 +55,7 @@ TRIGGER_SROC_TWO_PART_TARIFF= TRIGGER_SROC_ANNUAL= SHOW_RETURN_REQUIREMENTS= USE_NEW_BILL_RUN_SETUP= +ENABLE_SYSTEM_NOTIFICATIONS_INVITATIONS= # Set log level for app. Default is 'info' WRLS_LOG_LEVEL=debug diff --git a/src/internal/config.js b/src/internal/config.js index d238c2f6e..88bbf8520 100644 --- a/src/internal/config.js +++ b/src/internal/config.js @@ -175,6 +175,7 @@ module.exports = { useNewBillRunSetup: (get(process.env, 'USE_NEW_BILL_RUN_SETUP') || '').toLowerCase() === 'true', useWorkflowSetupLinks: (get(process.env, 'USE_WORKFLOW_SETUP_LINKS') || 'true').toLowerCase() === 'true', enableSystemLicenceView: process.env.ENABLE_SYSTEM_LICENCE_VIEW === 'true', + enableSystemNotificationsInvitations: process.env.ENABLE_SYSTEM_NOTIFICATIONS_INVITATIONS === 'true', enableMonitoringStationsView: process.env.ENABLE_MONITORING_STATIONS_VIEW === 'true' }, billRunsToDisplayPerPage: process.env.BILL_RUNS_TO_DISPLAY_PER_PAGE || 20 diff --git a/src/internal/modules/manage/lib/manage-nav.js b/src/internal/modules/manage/lib/manage-nav.js index a9446c6bd..bd6d29293 100644 --- a/src/internal/modules/manage/lib/manage-nav.js +++ b/src/internal/modules/manage/lib/manage-nav.js @@ -2,10 +2,11 @@ * Contains functions to help with building a list of notifications that * can be sent by the current authenticated user */ -const { hasScope } = require('../../../lib/permissions') -const { scope } = require('../../../lib/constants') +const config = require('internal/config') const { featureToggles } = require('../../../config') +const { hasScope } = require('../../../lib/permissions') const { mapValues } = require('lodash') +const { scope } = require('../../../lib/constants') /** * Creates a link object for the manage tab view @@ -28,7 +29,7 @@ const manageTabSkeleton = () => ({ createLink('Key performance indicators', '/reporting/kpi-reporting', scope.hasManageTab) ], returnNotifications: [ - createLink('Invitations', '/returns-notifications/invitations', scope.bulkReturnNotifications), + createLink('Invitations', _returnNotificationsInvitations(), scope.bulkReturnNotifications), createLink('Paper forms', '/returns-notifications/forms', scope.returns), createLink('Reminders', '/returns-notifications/reminders', scope.bulkReturnNotifications) ], @@ -65,4 +66,12 @@ const getManageTabConfig = request => mapValues( links => links.filter(link => hasScope(request, link.scopes)) ) +const _returnNotificationsInvitations = () => { + if (config.featureToggles.enableSystemNotificationsInvitations) { + return '/system/notifications/invitations/setup/returns-period' + } else { + return '/returns-notifications/invitations' + } +} + exports.getManageTabConfig = getManageTabConfig diff --git a/test/internal/modules/manage/lib/manage-nav.test.js b/test/internal/modules/manage/lib/manage-nav.test.js index f63355a7a..435645cc4 100644 --- a/test/internal/modules/manage/lib/manage-nav.test.js +++ b/test/internal/modules/manage/lib/manage-nav.test.js @@ -5,9 +5,9 @@ const { expect } = require('@hapi/code') const { getManageTabConfig } = require('internal/modules/manage/lib/manage-nav') const { scope } = require('internal/lib/constants') +const config = require('internal/config') const { flatMap } = require('lodash') -const config = require('internal/config') const sinon = require('sinon') const mapLinkGroup = (links, group) => links.map(link => ({ @@ -44,6 +44,10 @@ experiment('getManageTabConfig', () => { }) experiment('when user has bulk returns notifications scope', () => { + beforeEach(() => { + config.featureToggles.enableSystemNotificationsInvitations = false + }) + test('they can view notification report, return invitations and return reminders notifications', async () => { const request = createRequest(scope.bulkReturnNotifications) const config = getManageTabConfig(request) @@ -219,4 +223,21 @@ experiment('getManageTabConfig', () => { ]) }) }) + + experiment('when the "enableSystemNotificationsInvitations" flag is true', () => { + beforeEach(() => { + config.featureToggles.enableSystemNotificationsInvitations = true + }) + + test('they click the link to "system"', async () => { + const request = createRequest(scope.bulkReturnNotifications) + const config = getManageTabConfig(request) + + expect(config.returnNotifications[0]).to.equal({ + name: 'Invitations', + path: '/system/notifications/invitations/setup/returns-period', + scopes: 'bulk_return_notifications' + }) + }) + }) })