From c514ccddb483377c7ae707ba6919a9bc1c11fda2 Mon Sep 17 00:00:00 2001 From: Robert Parkinson Date: Thu, 7 Dec 2023 15:32:57 +0000 Subject: [PATCH 1/4] Add Select the start date (return requirements) https://eaflood.atlassian.net/browse/WATER-4249 We are starting work on adding support for setting up return requirements within the service. A return requirement sets out how a licensee is expected to submit their returns, for example, daily, weekly or monthly, by what date, and using what unit of measure. This is the second page in the return requirements setup journey when 'no returns required' is selected. This is just a stub page and controls and validation will come later. From 1bae7dd9a46da181e9a4e2ce6dbf95c89f153f4c Mon Sep 17 00:00:00 2001 From: Robert Parkinson Date: Mon, 11 Dec 2023 14:16:01 +0000 Subject: [PATCH 2/4] add the route and page for the select start date page --- app/controllers/licences.controller.js | 19 +++++++ app/plugins/router.plugin.js | 2 + app/routes/licence.routes.js | 33 ++++++++++++ .../select-return-start-date.njk | 24 +++++++++ test/controllers/licences.controller.test.js | 54 +++++++++++++++++++ 5 files changed, 132 insertions(+) create mode 100644 app/controllers/licences.controller.js create mode 100644 app/routes/licence.routes.js create mode 100644 app/views/return-requirements/select-return-start-date.njk create mode 100644 test/controllers/licences.controller.test.js diff --git a/app/controllers/licences.controller.js b/app/controllers/licences.controller.js new file mode 100644 index 0000000000..b1fc3a2227 --- /dev/null +++ b/app/controllers/licences.controller.js @@ -0,0 +1,19 @@ +'use strict' + +async function noReturnsRequired (_request, h) { + return h.response().code(200) +} + +async function selectReturnStartDate (request, h) { + const { id } = request.params + + return h.view('return-requirements/select-return-start-date.njk', { + activeNavBar: 'search', + licenceId: id + }) +} + +module.exports = { + noReturnsRequired, + selectReturnStartDate +} \ No newline at end of file diff --git a/app/plugins/router.plugin.js b/app/plugins/router.plugin.js index 483a25f427..a3fcd4e7ae 100644 --- a/app/plugins/router.plugin.js +++ b/app/plugins/router.plugin.js @@ -21,6 +21,7 @@ const CheckRoutes = require('../routes/check.routes.js') const DataRoutes = require('../routes/data.routes.js') const FilterRoutesService = require('../services/plugins/filter-routes.service.js') const HealthRoutes = require('../routes/health.routes.js') +const LicenceRoutes = require('../routes/licence.routes.js') const RootRoutes = require('../routes/root.routes.js') const AirbrakeConfig = require('../../config/airbrake.config.js') @@ -34,6 +35,7 @@ const routes = [ ...BillRunRoutes, ...BillingAccountRoutes, ...ChargeElements, + ...LicenceRoutes, ...CheckRoutes, ...DataRoutes ] diff --git a/app/routes/licence.routes.js b/app/routes/licence.routes.js new file mode 100644 index 0000000000..3f1fabd64f --- /dev/null +++ b/app/routes/licence.routes.js @@ -0,0 +1,33 @@ +'use strict' + +const LicencesController = require('../controllers/licences.controller.js') + +const routes = [ + { + method: 'GET', + path: '/licences/{id}/no-returns-required', + handler: LicencesController.noReturnsRequired, + options: { + auth: { + access: { + scope: ['billing'] + } + }, + description: 'Review two-part tariff match and allocation results' + } + }, { + method: 'GET', + path: '/licences/{id}/select-return-start-date', + handler: LicencesController.selectReturnStartDate, + options: { + auth: { + access: { + scope: ['billing'] + } + }, + description: 'Select the start date of the return' + } + } +] + +module.exports = routes diff --git a/app/views/return-requirements/select-return-start-date.njk b/app/views/return-requirements/select-return-start-date.njk new file mode 100644 index 0000000000..b508f313ef --- /dev/null +++ b/app/views/return-requirements/select-return-start-date.njk @@ -0,0 +1,24 @@ +{% extends 'layout.njk' %} +{% from "govuk/components/back-link/macro.njk" import govukBackLink %} +{% from "govuk/components/button/macro.njk" import govukButton %} + +{% block breadcrumbs %} + {# Back link #} + {{ + govukBackLink({ + text: 'back', + href: "/licences/{{ licenceId }}/no-returns-required" + }) + }} +{% endblock %} + +{% block content %} + {# Main heading #} +
+

Select the start date for the return requirement

+
+ +
+ {{ govukButton({ text: "Continue" }) }} +
+{% endblock %} diff --git a/test/controllers/licences.controller.test.js b/test/controllers/licences.controller.test.js new file mode 100644 index 0000000000..1f76f5a985 --- /dev/null +++ b/test/controllers/licences.controller.test.js @@ -0,0 +1,54 @@ +'use strict' + +// Test framework dependencies +const Lab = require('@hapi/lab') +const Code = require('@hapi/code') +const Sinon = require('sinon') + +const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { expect } = Code + +// Things we need to stub + +// For running our service +const { init } = require('../../app/server.js') + +describe('Liicences controller', () => { + let server + + beforeEach(async () => { + // Create server before each test + server = await init() + + // We silence any calls to server.logger.error made in the plugin to try and keep the test output as clean as + // possible + Sinon.stub(server.logger, 'error') + + // We silence sending a notification to our Errbit instance using Airbrake + Sinon.stub(server.app.airbrake, 'notify').resolvesThis() + }) + + afterEach(() => { + Sinon.restore() + }) + + describe('GET /licences/{id}/select-return-start-date', () => { + const options = { + method: 'GET', + url: '/licences/64924759-8142-4a08-9d1e-1e902cd9d316/select-return-start-date', + auth: { + strategy: 'session', + credentials: { scope: ['billing'] } + } + } + + describe('when the request succeeds', () => { + it('returns the page successfully', async () => { + const response = await server.inject(options) + + expect(response.statusCode).to.equal(200) + expect(response.payload).to.contain('Select the start date for the return requirement') + }) + }) + }) +}) From 22110b20ad64b8fa8374e1ff8b695561c63b8a04 Mon Sep 17 00:00:00 2001 From: Robert Parkinson Date: Mon, 11 Dec 2023 14:21:08 +0000 Subject: [PATCH 3/4] fix linting issues --- app/controllers/licences.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/licences.controller.js b/app/controllers/licences.controller.js index b1fc3a2227..08b2fe897a 100644 --- a/app/controllers/licences.controller.js +++ b/app/controllers/licences.controller.js @@ -16,4 +16,4 @@ async function selectReturnStartDate (request, h) { module.exports = { noReturnsRequired, selectReturnStartDate -} \ No newline at end of file +} From d459ee828269c272651503e71011ea1681f9e5c3 Mon Sep 17 00:00:00 2001 From: Robert Parkinson Date: Tue, 12 Dec 2023 09:04:06 +0000 Subject: [PATCH 4/4] add JSDoc comments --- app/controllers/licences.controller.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/licences.controller.js b/app/controllers/licences.controller.js index 08b2fe897a..835448f246 100644 --- a/app/controllers/licences.controller.js +++ b/app/controllers/licences.controller.js @@ -1,5 +1,10 @@ 'use strict' +/** + * Controller for /licences endpoints + * @module LicencesController + */ + async function noReturnsRequired (_request, h) { return h.response().code(200) }