diff --git a/app/controllers/licences.controller.js b/app/controllers/licences.controller.js new file mode 100644 index 0000000000..835448f246 --- /dev/null +++ b/app/controllers/licences.controller.js @@ -0,0 +1,24 @@ +'use strict' + +/** + * Controller for /licences endpoints + * @module LicencesController + */ + +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 +} 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') + }) + }) + }) +})