diff --git a/app/controllers/licences.controller.js b/app/controllers/licences.controller.js index 9b4cbaec4f..821e7b8f1d 100644 --- a/app/controllers/licences.controller.js +++ b/app/controllers/licences.controller.js @@ -6,7 +6,8 @@ */ const InitiateReturnRequirementSessionService = require('../services/return-requirements/initiate-return-requirement-session.service.js') -const ViewLicenceSummaryService = require('../services/licences/view-license-summary.service') +const ViewLicenceReturnsService = require('../services/licences/view-licence-returns.service') +const ViewLicenceSummaryService = require('../services/licences/view-licence-summary.service') async function noReturnsRequired (request, h) { const { id } = request.params @@ -35,8 +36,20 @@ async function viewSummary (request, h) { }) } +async function viewReturns (request, h) { + const { params: { id }, auth, query: { page = 1 } } = request + + const data = await ViewLicenceReturnsService.go(id, auth, page) + + return h.view('licences/view.njk', { + activeNavBar: 'search', + ...data + }) +} + module.exports = { noReturnsRequired, returnsRequired, + viewReturns, viewSummary } diff --git a/app/presenters/licences/view-licence-returns.presenter.js b/app/presenters/licences/view-licence-returns.presenter.js new file mode 100644 index 0000000000..00468e7305 --- /dev/null +++ b/app/presenters/licences/view-licence-returns.presenter.js @@ -0,0 +1,58 @@ +'use strict' + +/** + * Formats common data for the `/licences/{id}/*` view licence pages + * @module ViewLicenceReturnsPresenter + */ + +const { formatLongDate } = require('../base.presenter') + +/** + * Formats common data for the `/licences/{id}/*` view licence pages + * + * @returns {Object} The data formatted for the view template + */ +function go (returnsData) { + const returns = _formatReturnToTableRow(returnsData.returns) + + return { + activeTab: 'returns', + returns + } +} + +function _formatPurpose (purpose) { + const [firstPurpose] = purpose + + return firstPurpose.alias ? firstPurpose.alias : firstPurpose.tertiary.description +} + +function _formatReturnToTableRow (returns) { + return returns.map((r) => { + return { + dates: `${formatLongDate(new Date(r.startDate))} to ${formatLongDate(new Date(r.endDate))}`, + description: r.metadata.description, + dueDate: formatLongDate(new Date(r.dueDate)), + id: r.id, + purpose: _formatPurpose(r.metadata.purposes), + reference: r.returnReference, + status: _formatStatus(r.status) + } + }) +} + +function _formatStatus (status) { + if (status === 'completed') { + return 'COMPLETE' + } + + if (status === 'due') { + return 'OVERDUE' + } + + return 'NO STATUS' +} + +module.exports = { + go +} diff --git a/app/presenters/licences/view-license-summary.presenter.js b/app/presenters/licences/view-licence-summary.presenter.js similarity index 100% rename from app/presenters/licences/view-license-summary.presenter.js rename to app/presenters/licences/view-licence-summary.presenter.js diff --git a/app/presenters/licences/view-licence.presenter.js b/app/presenters/licences/view-licence.presenter.js index 1343155bd5..0609378548 100644 --- a/app/presenters/licences/view-licence.presenter.js +++ b/app/presenters/licences/view-licence.presenter.js @@ -21,10 +21,12 @@ function go (licence, auth) { includeInSrocBilling, licenceName, licenceRef, - registeredTo + registeredTo, + id } = licence return { + licenceId: id, licenceName, licenceRef, notification: _determineNotificationBanner(includeInPresrocBilling, includeInSrocBilling), @@ -36,7 +38,7 @@ function go (licence, auth) { } function _determineNotificationBanner (includeInPresrocBilling, includeInSrocBilling) { - const baseMessage = 'This license has been marked for the next supplementary bill run' + const baseMessage = 'This licence has been marked for the next supplementary bill run' if (includeInPresrocBilling === 'yes' && includeInSrocBilling === true) { return baseMessage + 's for the current and old charge schemes.' diff --git a/app/routes/licence.routes.js b/app/routes/licence.routes.js index 52e81bd5b2..c71d066d8c 100644 --- a/app/routes/licence.routes.js +++ b/app/routes/licence.routes.js @@ -8,9 +8,18 @@ const routes = [ path: '/licences/{id}/summary', handler: LicencesController.viewSummary, options: { - description: 'View a licence page' + description: 'View a licence summary page' } - }, { + }, + { + method: 'GET', + path: '/licences/{id}/returns', + handler: LicencesController.viewReturns, + options: { + description: 'View a licence returns page' + } + }, + { method: 'GET', path: '/licences/{id}/no-returns-required', handler: LicencesController.noReturnsRequired, diff --git a/app/services/licences/fetch-licence-returns.service.js b/app/services/licences/fetch-licence-returns.service.js new file mode 100644 index 0000000000..a899f81c35 --- /dev/null +++ b/app/services/licences/fetch-licence-returns.service.js @@ -0,0 +1,46 @@ +'use strict' + +/** + * Fetches all return logs for a licence which is needed for the view '/licences/{id}/returns` page + * @module FetchLicenceReturnsService + */ + +const ReturnLogModel = require('../../models/return-log.model') + +const DatabaseConfig = require('../../../config/database.config') + +/** + * Fetches all return logs for a licence which is needed for the view '/licences/{id}/returns` page + * + * @param {string} licenceId - The UUID for the licence to fetch + * + * @returns {Promise} the data needed to populate the view licence page's returns tab + */ +async function go (licenceId, page) { + const { results, total } = await _fetch(licenceId, page) + + return { returns: results, pagination: { total } } +} + +async function _fetch (licenceId, page) { + return ReturnLogModel.query() + .select([ + 'returnLogs.id', + 'returnLogs.dueDate', + 'returnLogs.endDate', + 'returnLogs.metadata', + 'returnLogs.returnReference', + 'returnLogs.startDate', + 'returnLogs.status' + ]) + .innerJoinRelated('licence') + .where('licence.id', licenceId) + .orderBy([ + { column: 'dueDate', order: 'desc' } + ]) + .page(page - 1, DatabaseConfig.defaultPageSize) +} + +module.exports = { + go +} diff --git a/app/services/licences/fetch-license-summary.service.js b/app/services/licences/fetch-licence-summary.service.js similarity index 100% rename from app/services/licences/fetch-license-summary.service.js rename to app/services/licences/fetch-licence-summary.service.js diff --git a/app/services/licences/fetch-licence.service.js b/app/services/licences/fetch-licence.service.js index acfe726fc4..bcc06be487 100644 --- a/app/services/licences/fetch-licence.service.js +++ b/app/services/licences/fetch-licence.service.js @@ -39,6 +39,7 @@ async function _fetchLicence (id) { const result = await LicenceModel.query() .findById(id) .select([ + 'id', 'include_in_presroc_billing', 'include_in_sroc_billing', 'licenceRef', diff --git a/app/services/licences/view-licence-returns.service.js b/app/services/licences/view-licence-returns.service.js new file mode 100644 index 0000000000..fca6cc8e0f --- /dev/null +++ b/app/services/licences/view-licence-returns.service.js @@ -0,0 +1,37 @@ +'use strict' + +/** + * Orchestrates fetching and presenting the data needed for the licence summary page + * @module ViewLicenceSummaryService + */ + +const FetchLicenceReturnsService = require('./fetch-licence-returns.service') +const ViewLicenceService = require('./view-licence.service') +const ViewLicenceReturnsPresenter = require('../../presenters/licences/view-licence-returns.presenter') +const PaginatorPresenter = require('../../presenters/paginator.presenter') + +/** + * Orchestrates fetching and presenting the data needed for the licence summary page + * + * @param {string} licenceId - The UUID of the licence + * + * @returns {Promise} an object representing the `pageData` needed by the licence summary template. + */ +async function go (licenceId, auth, page) { + const commonData = await ViewLicenceService.go(licenceId, auth) + + const returnsData = await FetchLicenceReturnsService.go(licenceId, page) + const pageData = ViewLicenceReturnsPresenter.go(returnsData) + + const pagination = PaginatorPresenter.go(returnsData.pagination.total, Number(page), `/system/licences/${licenceId}/returns`) + + return { + ...pageData, + ...commonData, + pagination + } +} + +module.exports = { + go +} diff --git a/app/services/licences/view-license-summary.service.js b/app/services/licences/view-licence-summary.service.js similarity index 92% rename from app/services/licences/view-license-summary.service.js rename to app/services/licences/view-licence-summary.service.js index e714e28a1d..3913b1233a 100644 --- a/app/services/licences/view-license-summary.service.js +++ b/app/services/licences/view-licence-summary.service.js @@ -6,8 +6,8 @@ */ const FetchLicenceAbstractionConditionsService = require('./fetch-licence-abstraction-conditions.service.js') -const FetchLicenceSummaryService = require('./fetch-license-summary.service') -const ViewLicenceSummaryPresenter = require('../../presenters/licences/view-license-summary.presenter') +const FetchLicenceSummaryService = require('./fetch-licence-summary.service') +const ViewLicenceSummaryPresenter = require('../../presenters/licences/view-licence-summary.presenter') const ViewLicenceService = require('./view-licence.service') /** diff --git a/app/views/licences/tabs/returns.njk b/app/views/licences/tabs/returns.njk new file mode 100644 index 0000000000..51ac8cc585 --- /dev/null +++ b/app/views/licences/tabs/returns.njk @@ -0,0 +1,54 @@ +{% from "govuk/components/pagination/macro.njk" import govukPagination %} +{% from "govuk/components/table/macro.njk" import govukTable %} +{% from "govuk/components/tag/macro.njk" import govukTag %} + +{% macro formatStatus(status) %} + {% if status === 'COMPLETE' %} + {{ govukTag({ + text: status, + classes: "govuk-tag--green" + }) }} + + {% elseif status === 'OVERDUE' %} + {{ govukTag({ + text: status, + classes: "govuk-tag--red" + }) }} + {% else %} + {{ status }} + {% endif %} +{% endmacro %} + + +

Returns

+ {% if returns %} + + + + + + + + + + {% for return in returns %} + + + + + + + {% endfor %} + + {% else %} +

No returns found

+ {% endif %} +
Return reference and datesPurpose and descriptionDue dateStatus
+ {{ return.reference }} +

{{ return.dates }}

+
{{ return.purpose }}

{{ return.description }}

{{ return.dueDate }}{{ formatStatus(return.status) }}
+ +{% if returns and pagination.numberOfPages > 1 %} + {{ govukPagination(pagination.component) }} +{% endif %} + diff --git a/app/views/licences/view.njk b/app/views/licences/view.njk index 5a451d1fca..bd3f8c3f5e 100644 --- a/app/views/licences/view.njk +++ b/app/views/licences/view.njk @@ -79,6 +79,9 @@ {% if activeTab === 'summary' %} {% include "licences/tabs/summary.njk" %} {% endif %} + {% if activeTab === 'returns' %} + {% include "licences/tabs/returns.njk" %} + {% endif %} {% endblock %} diff --git a/test/controllers/licences.controller.test.js b/test/controllers/licences.controller.test.js index 1d1f2a3530..5025f42b60 100644 --- a/test/controllers/licences.controller.test.js +++ b/test/controllers/licences.controller.test.js @@ -13,7 +13,8 @@ const Boom = require('@hapi/boom') // Things we need to stub const InitiateReturnRequirementSessionService = require('../../app/services/return-requirements/initiate-return-requirement-session.service.js') -const ViewLicenceSummaryService = require('../../app/services/licences/view-license-summary.service') +const ViewLicenceSummaryService = require('../../app/services/licences/view-licence-summary.service') +const ViewLicenceReturnsService = require('../../app/services/licences/view-licence-returns.service') // For running our service const { init } = require('../../app/server.js') @@ -188,4 +189,42 @@ describe('Licences controller', () => { } } }) + + describe('GET /licences/{id}/returns', () => { + beforeEach(async () => { + options = { + method: 'GET', + url: '/licences/7861814c-ca19-43f2-be11-3c612f0d744b/returns', + auth: { + strategy: 'session', + credentials: { scope: ['billing'] } + } + } + }) + + describe('when a request is valid and has returns', () => { + beforeEach(async () => { + Sinon.stub(ViewLicenceReturnsService, 'go').resolves(_viewLicenceReturns()) + }) + + it('returns the page successfully', async () => { + const response = await server.inject(options) + + expect(response.statusCode).to.equal(200) + expect(response.payload).to.contain('Returns') + // Check the table titles + expect(response.payload).to.contain('Return reference and dates') + expect(response.payload).to.contain('Purpose and description') + expect(response.payload).to.contain('Due date') + expect(response.payload).to.contain('Status') + }) + }) + }) }) + +function _viewLicenceReturns () { + return { + activeTab: 'returns', + returns: [{}] + } +} diff --git a/test/presenters/bill-runs/view-bill-summaries.presenter.test.js b/test/presenters/bill-runs/view-bill-summaries.presenter.test.js index 9b4d167f8e..b904edc9a2 100644 --- a/test/presenters/bill-runs/view-bill-summaries.presenter.test.js +++ b/test/presenters/bill-runs/view-bill-summaries.presenter.test.js @@ -167,7 +167,7 @@ describe('View Bill Summaries presenter', () => { }) describe("the bill 'licences' property", () => { - it('splits the licenses provided by , and places the resulting references into an array', () => { + it('splits the licences provided by , and places the resulting references into an array', () => { const result = ViewBillSummariesPresenter.go(billSummaries) expect(result[0].bills[0].licences).to.equal(['17/53/001/A/101', '17/53/002/B/205', '17/53/002/C/308']) diff --git a/test/presenters/licences/view-licence-presenter.test.js b/test/presenters/licences/view-licence-presenter.test.js index dc57a01778..e90de00846 100644 --- a/test/presenters/licences/view-licence-presenter.test.js +++ b/test/presenters/licences/view-licence-presenter.test.js @@ -24,6 +24,7 @@ describe('View Licence presenter', () => { const result = ViewLicencePresenter.go(licence) expect(result).to.equal({ + licenceId: 'f1288f6c-8503-4dc1-b114-75c408a14bd0', licenceName: 'Unregistered licence', licenceRef: '01/123', notification: null, @@ -151,7 +152,7 @@ describe('View Licence presenter', () => { it('returns the notification for PRESROC', () => { const result = ViewLicencePresenter.go(licence) - expect(result.notification).to.equal('This license has been marked for the next supplementary bill run for the old charge scheme.') + expect(result.notification).to.equal('This licence has been marked for the next supplementary bill run for the old charge scheme.') }) }) @@ -163,7 +164,7 @@ describe('View Licence presenter', () => { it('returns the notification for SROC', () => { const result = ViewLicencePresenter.go(licence) - expect(result.notification).to.equal('This license has been marked for the next supplementary bill run.') + expect(result.notification).to.equal('This licence has been marked for the next supplementary bill run.') }) }) @@ -176,7 +177,7 @@ describe('View Licence presenter', () => { it('returns the notification for SROC & PRESROC)', () => { const result = ViewLicencePresenter.go(licence) - expect(result.notification).to.equal('This license has been marked for the next supplementary bill runs for the current and old charge schemes.') + expect(result.notification).to.equal('This licence has been marked for the next supplementary bill runs for the current and old charge schemes.') }) }) }) diff --git a/test/presenters/licences/view-licence-returns-presenter.test.js b/test/presenters/licences/view-licence-returns-presenter.test.js new file mode 100644 index 0000000000..c65c2135f7 --- /dev/null +++ b/test/presenters/licences/view-licence-returns-presenter.test.js @@ -0,0 +1,112 @@ +'use strict' + +// Test framework dependencies +const Lab = require('@hapi/lab') +const Code = require('@hapi/code') + +const { describe, it, beforeEach } = exports.lab = Lab.script() +const { expect } = Code + +// Thing under test +const ViewLicenceReturnsPresenter = require('../../../app/presenters/licences/view-licence-returns.presenter') + +describe('View Licence returns presenter', () => { + let returnData + + beforeEach(() => { + returnData = _returnData() + }) + + describe('when provided with a populated licence', () => { + it('correctly presents the data', () => { + const result = ViewLicenceReturnsPresenter.go(returnData) + + expect(result).to.equal({ + activeTab: 'returns', + returns: [ + { + id: 'mock-id-1', + reference: '1068', + purpose: 'SPRAY IRRIGATION', + dueDate: '28 November 2012', + status: 'COMPLETE', + dates: '2 January 2020 to 1 February 2020', + description: 'empty description' + }, + { + id: 'mock-id-2', + reference: '1069', + purpose: 'SPRAY IRRIGATION', + dueDate: '28 November 2019', + status: 'OVERDUE', + dates: '2 January 2020 to 1 February 2020', + description: 'empty description' + } + ] + }) + }) + }) +}) + +function _returnData () { + return { + returns: [ + { + id: 'mock-id-1', + dueDate: '2012-11-28T00:00:00.000Z', + status: 'completed', + startDate: '2020/01/02', + endDate: '2020/02/01', + metadata: { + purposes: [ + { + alias: 'SPRAY IRRIGATION', + primary: { + code: 'A', + description: 'Agriculture' + }, + tertiary: { + code: '400', + description: 'Spray Irrigation - Direct' + }, + secondary: { + code: 'AGR', + description: 'General Agriculture' + } + } + ], + description: 'empty description' + }, + returnReference: '1068' + }, + { + id: 'mock-id-2', + dueDate: '2019-11-28T00:00:00.000Z', + status: 'due', + startDate: '2020/01/02', + endDate: '2020/02/01', + metadata: { + description: 'empty description', + purposes: [ + { + alias: 'SPRAY IRRIGATION', + primary: { + code: 'A', + description: 'Agriculture' + }, + tertiary: { + code: '400', + description: 'Spray Irrigation - Direct' + }, + secondary: { + code: 'AGR', + description: 'General Agriculture' + } + } + ] + }, + returnReference: '1069' + } + ] + } +} diff --git a/test/presenters/licences/view-licence-summary.presenter.test.js b/test/presenters/licences/view-licence-summary.presenter.test.js index 50d6a13793..9c11fba334 100644 --- a/test/presenters/licences/view-licence-summary.presenter.test.js +++ b/test/presenters/licences/view-licence-summary.presenter.test.js @@ -8,7 +8,7 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Thing under test -const ViewLicenceSummaryPresenter = require('../../../app/presenters/licences/view-license-summary.presenter') +const ViewLicenceSummaryPresenter = require('../../../app/presenters/licences/view-licence-summary.presenter') describe('View Licence Summary presenter', () => { let licenceAbstractionConditions diff --git a/test/services/licences/fetch-licence-returns.service.test.js b/test/services/licences/fetch-licence-returns.service.test.js new file mode 100644 index 0000000000..38d0deb9a7 --- /dev/null +++ b/test/services/licences/fetch-licence-returns.service.test.js @@ -0,0 +1,90 @@ +'use strict' + +// Test framework dependencies +const Lab = require('@hapi/lab') +const Code = require('@hapi/code') + +const { describe, it, beforeEach } = exports.lab = Lab.script() +const { expect } = Code + +// Test helpers +const DatabaseSupport = require('../../support/database.js') +const LicenceHelper = require('../../support/helpers/licence.helper') +const ReturnLogHelper = require('../../support/helpers/return-log.helper.js') + +// Thing under test +const FetchLicenceReturnsService = require('../../../app/services/licences/fetch-licence-returns.service') + +describe('Fetch licence returns service', () => { + const licenceId = 'fef693fd-eb6f-478d-9f79-ab24749c5dc6' + + beforeEach(async () => { + await DatabaseSupport.clean() + }) + + describe('when the licence has return logs', () => { + const dueDate = new Date('2020-04-01') + const endDate = new Date('2020-06-01') + const startDate = new Date('2020-02-01') + const latestDueDate = new Date('2020-05-01') + const firstReturn = { + id: '5fef371e-d0b5-4fd5-a7ff-a67d04b3f451', + dueDate, + endDate, + metadata: '323', + returnReference: '32', + startDate, + status: '32' + } + + const latestReturn = { + ...firstReturn, + id: 'b80f87a3-a274-4232-b536-750670d79928', + returnReference: '123', + dueDate: latestDueDate + } + + beforeEach(async () => { + const license = await LicenceHelper.add({ + id: licenceId + }) + + firstReturn.licenceRef = license.licenceRef + latestReturn.licenceRef = license.licenceRef + + await ReturnLogHelper.add(firstReturn) + await ReturnLogHelper.add(latestReturn) + }) + + it('returns results', async () => { + const result = await FetchLicenceReturnsService.go(licenceId, 1) + + expect(result.pagination).to.equal({ + total: 2 + }) + // This should be ordered by due date + expect(result.returns).to.equal( + [ + { + dueDate: latestDueDate, + endDate, + id: latestReturn.id, + metadata: 323, + returnReference: '123', + startDate, + status: '32' + }, + { + dueDate, + endDate, + id: firstReturn.id, + metadata: 323, + returnReference: '32', + startDate, + status: '32' + } + ] + ) + }) + }) +}) diff --git a/test/services/licences/fetch-licence-summary.service.test.js b/test/services/licences/fetch-licence-summary.service.test.js index e82ad385c6..1ce9a90a9e 100644 --- a/test/services/licences/fetch-licence-summary.service.test.js +++ b/test/services/licences/fetch-licence-summary.service.test.js @@ -27,7 +27,7 @@ const PermitLicenceHelper = require('../../support/helpers/permit-licence.helper const RegionHelper = require('../../support/helpers/region.helper.js') // Thing under test -const FetchLicenceSummaryService = require('../../../app/services/licences/fetch-license-summary.service') +const FetchLicenceSummaryService = require('../../../app/services/licences/fetch-licence-summary.service') describe('Fetch licence summary service', () => { let licence diff --git a/test/services/licences/fetch-licence.service.test.js b/test/services/licences/fetch-licence.service.test.js index 1c3b61a854..283613e33c 100644 --- a/test/services/licences/fetch-licence.service.test.js +++ b/test/services/licences/fetch-licence.service.test.js @@ -28,6 +28,7 @@ describe('Fetch licence service', () => { describe('when there is no optional data in the model', () => { beforeEach(async () => { licence = await LicenceHelper.add({ + id: 'a8256ea1-4509-4992-b30f-d011509e5f62', expiredDate: null, include_in_presroc_billing: 'yes', include_in_sroc_billing: true, @@ -42,6 +43,7 @@ describe('Fetch licence service', () => { it('returns results', async () => { const result = await FetchLicenceService.go(licence.id) + expect(result.id).to.equal('a8256ea1-4509-4992-b30f-d011509e5f62') expect(result.ends).to.equal(null) expect(result.expiredDate).to.equal(null) expect(result.lapsedDate).to.equal(null) diff --git a/test/services/licences/view-licence-returns.service.test.js b/test/services/licences/view-licence-returns.service.test.js new file mode 100644 index 0000000000..8365c50c79 --- /dev/null +++ b/test/services/licences/view-licence-returns.service.test.js @@ -0,0 +1,69 @@ +'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 +const ViewLicenceService = require('../../../app/services/licences/view-licence.service') +const PaginatorPresenter = require('../../../app/presenters/paginator.presenter') +const ViewLicenceReturnsPresenter = require('../../../app/presenters/licences/view-licence-returns.presenter') +const FetchLicenceReturnsService = require('../../../app/services/licences/fetch-licence-returns.service') + +// Thing under test +const ViewLicenceReturnsService = require('../../../app/services/licences/view-licence-returns.service') + +describe('View Licence service returns', () => { + const testId = '2c80bd22-a005-4cf4-a2a2-73812a9861de' + const page = 1 + const auth = {} + const pagination = { page } + + beforeEach(() => { + Sinon.stub(FetchLicenceReturnsService, 'go').resolves(_returnsFetch()) + Sinon.stub(PaginatorPresenter, 'go').returns(pagination) + Sinon.stub(ViewLicenceReturnsPresenter, 'go').returns(_returnsPresenter()) + Sinon.stub(ViewLicenceService, 'go').resolves(_licence()) + }) + + afterEach(() => { + Sinon.restore() + }) + + describe('when a return', () => { + describe('and it has no optional fields', () => { + it('will return all the mandatory data and default values for use in the licence returns page', async () => { + const result = await ViewLicenceReturnsService.go(testId, auth, page) + + expect(result).to.equal({ + licenceName: 'fake licence', + returns: [], + activeTab: 'returns', + pagination: { page: 1 } + }) + }) + }) + }) +}) + +function _licence () { + return { licenceName: 'fake licence' } +} + +function _returnsFetch () { + return { + pagination: { total: 1 }, + returns: [] + } +} + +function _returnsPresenter () { + return { + returns: [], + activeTab: 'returns' + } +} diff --git a/test/services/licences/view-license-summary.service.test.js b/test/services/licences/view-licence-summary.service.test.js similarity index 96% rename from test/services/licences/view-license-summary.service.test.js rename to test/services/licences/view-licence-summary.service.test.js index d00c7c9e60..c466ea28ab 100644 --- a/test/services/licences/view-license-summary.service.test.js +++ b/test/services/licences/view-licence-summary.service.test.js @@ -13,10 +13,10 @@ const LicenceModel = require('../../../app/models/licence.model.js') // Things we need to stub const FetchLicenceAbstractionConditionsService = require('../../../app/services/licences/fetch-licence-abstraction-conditions.service.js') -const FetchLicenceSummaryService = require('../../../app/services/licences/fetch-license-summary.service') +const FetchLicenceSummaryService = require('../../../app/services/licences/fetch-licence-summary.service') const ViewLicenceService = require('../../../app/services/licences/view-licence.service') // Thing under test -const ViewLicenceSummaryService = require('../../../app/services/licences/view-license-summary.service') +const ViewLicenceSummaryService = require('../../../app/services/licences/view-licence-summary.service') describe('View Licence service summary', () => { const testId = '2c80bd22-a005-4cf4-a2a2-73812a9861de' @@ -29,7 +29,7 @@ describe('View Licence service summary', () => { purposeIds: [], numberOfConditions: 0 }) - Sinon.stub(ViewLicenceService, 'go').resolves({ licenceName: 'fake license' }) + Sinon.stub(ViewLicenceService, 'go').resolves({ licenceName: 'fake licence' }) }) afterEach(() => { @@ -64,7 +64,7 @@ describe('View Licence service summary', () => { endDate: null, id: '2c80bd22-a005-4cf4-a2a2-73812a9861de', licenceHolder: 'Unregistered licence', - licenceName: 'fake license', + licenceName: 'fake licence', monitoringStations: [], purposes: null, region: 'South West', diff --git a/test/services/licences/view-licence.service.test.js b/test/services/licences/view-licence.service.test.js index 70f58eb6ec..f296f033d2 100644 --- a/test/services/licences/view-licence.service.test.js +++ b/test/services/licences/view-licence.service.test.js @@ -46,6 +46,7 @@ describe('View Licence service', () => { const result = await ViewLicenceService.go(testId) expect(result).to.equal({ + licenceId: '2c80bd22-a005-4cf4-a2a2-73812a9861de', licenceName: 'Unregistered licence', licenceRef: '01/130/R01', notification: null,