From c6bafb4c681f271f0f98673c59dca8b1f1b67261 Mon Sep 17 00:00:00 2001 From: Mark Fee Date: Fri, 24 Jan 2025 13:00:46 +0000 Subject: [PATCH 1/3] FCRM-5547 workflows/docker.yml now pushes to flood_map_planning/app --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index cecb5440..9137cd78 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: env: - REPOSITORY: flood_map_planning/app-internal + REPOSITORY: flood_map_planning/app jobs: build: From 0fc8ee387ecece93c69d89b0d34789b1a8d211ca Mon Sep 17 00:00:00 2001 From: Mark Fee Date: Fri, 24 Jan 2025 13:59:45 +0000 Subject: [PATCH 2/3] FCRM-5547 added appType to the about page --- server/routes/about.js | 4 +++- server/views/about.html | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server/routes/about.js b/server/routes/about.js index 99b4f675..edc11015 100644 --- a/server/routes/about.js +++ b/server/routes/about.js @@ -1,3 +1,4 @@ +const { config } = require('../../config') const { version, revision } = require('../../version') const externalHealthCheck = require('../services/external-health-check') @@ -14,7 +15,8 @@ module.exports = { const data = { fmpApp: { version: version.substring(0, version.lastIndexOf('-')), - revision: revision.substring(0, GIT_REVISION_LENGTH) + revision: revision.substring(0, GIT_REVISION_LENGTH), + appType: config.appType }, fmpApi } diff --git a/server/views/about.html b/server/views/about.html index c3d0df4a..193ae3ea 100644 --- a/server/views/about.html +++ b/server/views/about.html @@ -13,6 +13,7 @@

Flood map for planning

  • Application
  • Version: {{fmpApp.version}}
  • Revision: {{fmpApp.revision}}
  • +
  • Type: {{fmpApp.appType}}
  • API
  • Version: {{fmpApi.version}}
  • Revision: {{fmpApi.revision}}
  • From d1f339fa30e53e30c63058dc8236625b5ae2bae3 Mon Sep 17 00:00:00 2001 From: Mark Fee Date: Mon, 27 Jan 2025 10:24:21 +0000 Subject: [PATCH 3/3] FCRM-5547 added unit tests for about.js --- server/routes/__tests__/about.spec.js | 15 +++++++ .../__mocks__/external-health-check.js | 3 ++ test/routes/about.js | 45 ------------------- 3 files changed, 18 insertions(+), 45 deletions(-) create mode 100644 server/routes/__tests__/about.spec.js create mode 100644 server/services/__mocks__/external-health-check.js delete mode 100644 test/routes/about.js diff --git a/server/routes/__tests__/about.spec.js b/server/routes/__tests__/about.spec.js new file mode 100644 index 00000000..202f1eb8 --- /dev/null +++ b/server/routes/__tests__/about.spec.js @@ -0,0 +1,15 @@ +jest.mock('../../services/external-health-check') +const { submitGetRequest } = require('../../__test-helpers__/server') +const { assertCopy } = require('../../__test-helpers__/copy') +const url = '/about' + +describe('About Page', () => { + it('/about page should contain version numbers as expected', async () => { + await submitGetRequest({ url }, 'Flood map for planning') + assertCopy('#fmp-app-version', 'Version: v3.0.0-1') + assertCopy('#fmp-app-revision', 'Revision: 9256171') + assertCopy('#fmp-app-type', 'internal') + assertCopy('#fmp-api-version', 'Version: v8.8.8') + assertCopy('#fmp-api-revision', 'Revision: 9988776') + }) +}) diff --git a/server/services/__mocks__/external-health-check.js b/server/services/__mocks__/external-health-check.js new file mode 100644 index 00000000..0571cedd --- /dev/null +++ b/server/services/__mocks__/external-health-check.js @@ -0,0 +1,3 @@ +const getFmpApiVersion = async () => ({ version: 'v8.8.8', revision: '998877665544332211' }) + +module.exports = { getFmpApiVersion } diff --git a/test/routes/about.js b/test/routes/about.js deleted file mode 100644 index 5bb06c38..00000000 --- a/test/routes/about.js +++ /dev/null @@ -1,45 +0,0 @@ -require('dotenv').config({ path: 'config/.env-example' }) -const Lab = require('@hapi/lab') -const Code = require('@hapi/code') -const lab = (exports.lab = Lab.script()) -const createServer = require('../../server') -const { JSDOM } = require('jsdom') -const externalHealthCheck = require('../../server/services/external-health-check') - -lab.experiment('About Page', () => { - const options = { method: 'GET', url: '/about' } - let server - let restoreGetFmpApiVersion - - lab.before(async () => { - restoreGetFmpApiVersion = externalHealthCheck.getFmpApiVersion - - externalHealthCheck.getFmpApiVersion = () => ({ version: 'v8.8.8', revision: '998877665544332211' }) - server = await createServer() - await server.initialize() - }) - - lab.after(async () => { - externalHealthCheck.getFmpApiVersion = restoreGetFmpApiVersion - await server.stop() - }) - - lab.test('/about page should exist', async () => { - const response = await server.inject(options) - Code.expect(response.statusCode).to.equal(200) - }) - - lab.test('/about page should contain version numbers as expected', async () => { - const { payload } = await server.inject(options) - const { window: { document: doc } } = await new JSDOM(payload) - const fmpAppVersion = doc.querySelectorAll('#fmp-app-version') - const fmpAppRevision = doc.querySelectorAll('#fmp-app-revision') - const fmpApiVersion = doc.querySelectorAll('#fmp-api-version') - const fmpApiRevision = doc.querySelectorAll('#fmp-api-revision') - - Code.expect(fmpAppVersion[0].textContent).to.contain('Version: v3.0.0-1') - Code.expect(fmpAppRevision[0].textContent).to.contain('Revision: 9256171') - Code.expect(fmpApiVersion[0].textContent).to.contain('Version: v8.8.8') - Code.expect(fmpApiRevision[0].textContent).to.contain('Revision: 9988776') - }) -})