Skip to content

Commit

Permalink
Add Select the start date (return requirements) (#574)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
robertparkinson authored and Beckyrose200 committed Dec 14, 2023
1 parent ca49063 commit 4e54862
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/controllers/licences.controller.js
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 2 additions & 0 deletions app/plugins/router.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -34,6 +35,7 @@ const routes = [
...BillRunRoutes,
...BillingAccountRoutes,
...ChargeElements,
...LicenceRoutes,
...CheckRoutes,
...DataRoutes
]
Expand Down
33 changes: 33 additions & 0 deletions app/routes/licence.routes.js
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions app/views/return-requirements/select-return-start-date.njk
Original file line number Diff line number Diff line change
@@ -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 #}
<div class="govuk-body">
<h1 class="govuk-heading-xl govuk-!-margin-bottom-3">Select the start date for the return requirement</h1>
</div>

<div class="govuk-body">
{{ govukButton({ text: "Continue" }) }}
</div>
{% endblock %}
54 changes: 54 additions & 0 deletions test/controllers/licences.controller.test.js
Original file line number Diff line number Diff line change
@@ -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')
})
})
})
})

0 comments on commit 4e54862

Please sign in to comment.