Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Select the start date (return requirements) #574

Merged
merged 5 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'

robertparkinson marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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')
})
})
})
})
Loading