Skip to content

Commit

Permalink
Merge branch 'main' into refactor-supplementary-billing-flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Beckyrose200 authored Nov 29, 2024
2 parents d025eb4 + a75057b commit f7e039b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ TRIGGER_SROC_TWO_PART_TARIFF=
TRIGGER_SROC_ANNUAL=
SHOW_RETURN_REQUIREMENTS=
USE_NEW_BILL_RUN_SETUP=
ENABLE_SYSTEM_NOTIFICATIONS=

# Set log level for app. Default is 'info'
WRLS_LOG_LEVEL=debug
1 change: 1 addition & 0 deletions src/internal/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
enableSystemNotifications: process.env.ENABLE_SYSTEM_NOTIFICATIONS === 'true',
enableMonitoringStationsView: process.env.ENABLE_MONITORING_STATIONS_VIEW === 'true'
},
billRunsToDisplayPerPage: process.env.BILL_RUNS_TO_DISPLAY_PER_PAGE || 20
Expand Down
15 changes: 12 additions & 3 deletions src/internal/modules/manage/lib/manage-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
],
Expand Down Expand Up @@ -65,4 +66,12 @@ const getManageTabConfig = request => mapValues(
links => links.filter(link => hasScope(request, link.scopes))
)

const _returnNotificationsInvitations = () => {
if (config.featureToggles.enableSystemNotifications) {
return '/system/notifications/setup/returns-period'
} else {
return '/returns-notifications/invitations'
}
}

exports.getManageTabConfig = getManageTabConfig
23 changes: 22 additions & 1 deletion test/internal/modules/manage/lib/manage-nav.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ({
Expand Down Expand Up @@ -44,6 +44,10 @@ experiment('getManageTabConfig', () => {
})

experiment('when user has bulk returns notifications scope', () => {
beforeEach(() => {
config.featureToggles.enableSystemNotifications = false
})

test('they can view notification report, return invitations and return reminders notifications', async () => {
const request = createRequest(scope.bulkReturnNotifications)
const config = getManageTabConfig(request)
Expand Down Expand Up @@ -219,4 +223,21 @@ experiment('getManageTabConfig', () => {
])
})
})

experiment('when the "enableSystemNotifications" flag is true', () => {
beforeEach(() => {
config.featureToggles.enableSystemNotifications = 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/setup/returns-period',
scopes: 'bulk_return_notifications'
})
})
})
})

0 comments on commit f7e039b

Please sign in to comment.