-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from digital-land/feat/orgFinder/routerAndCon…
…troller Ticket: https://github.com/orgs/digital-land/projects/7/views/12?pane=issue&itemId=71541701 this initially will be merged into staging. but we will merge into main once enough parts come together to deliver some value
- Loading branch information
Showing
9 changed files
with
124 additions
and
80 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
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
import express from 'express' | ||
import OrganisationsController from '../controllers/OrganisationsController.js' | ||
|
||
const router = express.Router() | ||
|
||
router.get('/', OrganisationsController.getOrganisations) | ||
|
||
router.get('/:lpa/overview', OrganisationsController.getOverview) | ||
|
||
export default router |
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,26 @@ | ||
{% extends "layouts/main.html" %} | ||
|
||
{% from "govuk/components/breadcrumbs/macro.njk" import govukBreadcrumbs %} | ||
{% from "govuk/components/tag/macro.njk" import govukTag %} | ||
|
||
{% block beforeContent %} | ||
{{ super() }} | ||
|
||
{% endblock %} | ||
|
||
{% block content %} | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
|
||
<h1 class="govuk-heading-xl"> | ||
{{ pageName }} | ||
</h1> | ||
</div> | ||
</div> | ||
|
||
<h1>Find page placeholder</h1> | ||
|
||
|
||
|
||
{% endblock %} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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,74 @@ | ||
import { describe, it, vi, expect, beforeEach } from 'vitest' | ||
import LpaOverviewController from '../../src/controllers/OrganisationsController.js' | ||
import performanceDbApi from '../../src/services/performanceDbApi.js' | ||
|
||
vi.mock('../../src/services/performanceDbApi.js') | ||
vi.mock('../../src/utils/utils.js', () => { | ||
return { | ||
dataSubjects: {} | ||
} | ||
}) | ||
|
||
describe('OrganisationsController.js', () => { | ||
beforeEach(() => { | ||
vi.resetAllMocks() | ||
}) | ||
|
||
describe('overview', () => { | ||
it('should render the overview page', async () => { | ||
const req = { params: { lpa: 'test-lpa' } } | ||
const res = { render: vi.fn() } | ||
const next = vi.fn() | ||
|
||
const expectedResponse = { | ||
name: 'Test LPA', | ||
datasets: { | ||
dataset1: { endpoint: 'https://example.com', issue: false, error: false }, | ||
dataset2: { endpoint: null, issue: true, error: false }, | ||
dataset3: { endpoint: 'https://example.com', issue: false, error: true } | ||
} | ||
} | ||
|
||
performanceDbApi.getLpaOverview = vi.fn().mockResolvedValue(expectedResponse) | ||
|
||
await LpaOverviewController.getOverview(req, res, next) | ||
|
||
expect(res.render).toHaveBeenCalledTimes(1) | ||
expect(res.render).toHaveBeenCalledWith('organisations/overview.html', expect.objectContaining({ | ||
organisation: { name: 'Test LPA' }, | ||
datasets: expect.arrayContaining([ | ||
{ endpoint: 'https://example.com', issue: false, error: false, slug: 'dataset1' }, | ||
{ endpoint: null, issue: true, error: false, slug: 'dataset2' }, | ||
{ endpoint: 'https://example.com', issue: false, error: true, slug: 'dataset3' } | ||
]), | ||
totalDatasets: 3, | ||
datasetsWithEndpoints: 2, | ||
datasetsWithIssues: 1, | ||
datasetsWithErrors: 1 | ||
})) | ||
}) | ||
|
||
it('should catch and pass errors to the next function', async () => { | ||
const req = { params: { lpa: 'test-lpa' } } | ||
const res = { } | ||
const next = vi.fn() | ||
|
||
const error = new Error('Test error') | ||
|
||
vi.mocked(performanceDbApi.getLpaOverview).mockRejectedValue(error) | ||
|
||
await LpaOverviewController.getOverview(req, res, next) | ||
|
||
expect(next).toHaveBeenCalledTimes(1) | ||
expect(next).toHaveBeenCalledWith(error) | ||
}) | ||
}) | ||
|
||
describe('find', () => { | ||
it.todo('should render the find page', () => { | ||
|
||
}) | ||
|
||
it.todo('should catch errors and pass them onto the next function') | ||
}) | ||
}) |