-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Select the start date (return requirements) (#574)
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
1 parent
ca49063
commit 4e54862
Showing
5 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
app/views/return-requirements/select-return-start-date.njk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
}) | ||
}) | ||
}) | ||
}) |