Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
…/public-browse into feature/12938-investigate-how-to-write-integration-tests
  • Loading branch information
Nicholas Newlands authored and Nicholas Newlands committed Mar 29, 2021
2 parents 94f5219 + f02f0e1 commit e9b2157
Show file tree
Hide file tree
Showing 33 changed files with 7,929 additions and 2,656 deletions.
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
FROM node:14
FROM node:14-slim as builder

# Create app directory
WORKDIR /usr/src

COPY package*.json ./

RUN npm install
RUN npm install npm@latest -g && npm install

COPY . .

ENV NODE_ENV=production

# Converts Sass into CSS, tranpsiles the app and webpacks browser scripts
# Converts Sass into CSS, transpiles the app and webpacks browser scripts
RUN npm run build:docker

# Install prod dependencies inside the dist directory
RUN cp package.json dist && cd dist && npm install --only=prod

# Remove all files apart from the dist sub-directory
RUN find ./ -mindepth 1 ! -regex '^./dist\(/.*\)?' -delete
FROM builder as production

COPY . .

EXPOSE 3000

Expand Down
2 changes: 2 additions & 0 deletions app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,6 @@ module.exports = {

// The password to connect to redis
redisPass: process.env.REDIS_PASS,

showDfocvc: process.env.SHOW_DFOCVC || 'true',
};
18 changes: 12 additions & 6 deletions app/endpoints.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { buyingCatalogueApiHost, documentApiHost, identityServerUrl } from './config';

const getSolutionListDataEndpoint = (apiHostUrl, filterType) => {
if (filterType === 'all') {
return `${apiHostUrl}/api/v1/Solutions`;
}
if (filterType === 'foundation') {
return `${apiHostUrl}/api/v1/Solutions/Foundation`;
const defaultUrl = `${apiHostUrl}/api/v1/Solutions`;

switch (filterType.toLowerCase()) {
case 'all':
return defaultUrl;
case 'foundation':
return `${defaultUrl}/Foundation`;
case 'nhsdgp001':
case 'dfocvc001':
return `${defaultUrl}?frameworkId=${filterType}`;
default:
return undefined;
}
return undefined;
};

const endpoints = {
Expand Down
48 changes: 48 additions & 0 deletions app/endpoints.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { getEndpoint } from './endpoints';

describe('Endpoints', () => {
describe('getSolutionListDataEndpoint', () => {
it('should return "/api/v1/Solutions/Foundation" when filterType is "all"', () => {
const result = getEndpoint({
endpointLocator: 'getSolutionListData',
options: { filterType: 'all' },
});

expect(result).toBe('http://localhost:5100/api/v1/Solutions');
});

it('should return "/api/v1/Solutions/Foundation" when filterType is "foundation"', () => {
const result = getEndpoint({
endpointLocator: 'getSolutionListData',
options: { filterType: 'foundation' },
});

expect(result).toBe('http://localhost:5100/api/v1/Solutions/Foundation');
});

it('should return undefined when filterType is not valid', () => {
const result = getEndpoint({
endpointLocator: 'getSolutionListData',
options: { filterType: 'i do not exist' },
});

expect(result).toBe(undefined);
});

describe('solutions?frameworkId', () => {
test.each`
key | expected
${'NHSDGP001'} | ${'http://localhost:5100/api/v1/Solutions?frameworkId=NHSDGP001'}
${'DFOCVC001'} | ${'http://localhost:5100/api/v1/Solutions?frameworkId=DFOCVC001'}
`('should return "$expected" when filterType is "$key"', ({ key, expected }) => {
const result = getEndpoint({
endpointLocator: 'getSolutionListData',
options: { filterType: key },
});

expect(result).toBe(expected);
});
});
});
});
4 changes: 2 additions & 2 deletions app/includes/__snapshots__/footer.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`footer should render the footer 1`] = `
<div class=\\"nhsuk-footer\\" id=\\"nhsuk-footer\\">
<div class=\\"nhsuk-width-container\\">
<h2 class=\\"nhsuk-u-visually-hidden\\">Support links</h2>
<ul class=\\"nhsuk-footer__list nhsuk-footer__list--three-columns\\">
<ul class=\\"nhsuk-footer__list\\">
<li class=\\"nhsuk-footer__list-item\\"><a class=\\"nhsuk-footer__list-item-link\\" href=\\"/guide\\">Buyer's Guide</a></li>
<li class=\\"nhsuk-footer__list-item\\"><a class=\\"nhsuk-footer__list-item-link\\" href=\\"/guide#contact-us\\">NHS Digital Helpdesk</a></li>
<li class=\\"nhsuk-footer__list-item\\"><a class=\\"nhsuk-footer__list-item-link\\" href=\\"https://digital.nhs.uk/\\">NHS Digital</a></li>
Expand All @@ -26,7 +26,7 @@ exports[`footer should render the footer 1`] = `
<ul data-test-id=\\"legal-panel\\" class=\\"bc-lh-r bc-body-r bc-list-none nhsuk-u-padding-0 nhsuk-u-padding-bottom-3 nhsuk-width-container\\">
<li class=\\"bc-u-display-inline nhsuk-u-margin-0 nhsuk-u-margin-right-2\\">Legal</li>
<li class=\\"bc-u-display-inline nhsuk-u-margin-0 nhsuk-u-margin-right-2\\"><a href=\\"https://digital.nhs.uk/about-nhs-digital/privacy-and-cookies\\">Privacy and Cookies</a></li>
<li class=\\"bc-u-display-inline nhsuk-u-margin-0 nhsuk-u-margin-right-2\\"><a href=\\"/document/terms-of-use.pdf\\">Terms and Conditions</a></li>
<li class=\\"bc-u-display-inline nhsuk-u-margin-0 nhsuk-u-margin-right-2\\"><a href=\\"https://buyingcatalogue.digital.nhs.uk/document/terms-of-use.pdf\\">Terms and Conditions</a></li>
</ul>
</div>"
Expand Down
20 changes: 12 additions & 8 deletions app/includes/__snapshots__/header.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ exports[`header should render the header 1`] = `
</header>
<section class=\\"bc-c-global-alert\\" data-test-id=\\"covid19-global-alert\\" aria-labelledby=\\"covid-alert-heading\\" role=\\"banner\\">
<div class=\\"nhsuk-width-container\\">
<h2 id=\\"covid-alert-heading\\">Coronavirus (COVID-19)</h2>
<p>View Catalogue Solutions that help with coronavirus by <a data-test-id=\\"vaccinations\\" href=\\"/solutions/vaccinations\\">organising vaccinations </a>or <a data-test-id=\\"covid19\\" href=\\"/solutions/covid19\\">reducing visits to GP practices</a>.</p>
</div>
</section>
<section class=\\"bc-c-global-alert\\" data-test-id=\\"covid19-global-alert\\" aria-labelledby=\\"covid-alert-heading\\" role=\\"banner\\">
<div class=\\"nhsuk-width-container\\">
<h2 id=\\"covid-alert-heading\\">Coronavirus (COVID-19)</h2>
<p>View Catalogue Solutions that help with coronavirus by <a data-test-id=\\"vaccinations\\" href=\\"/solutions/vaccinations\\">organising vaccinations</a>.</p>
</div>
</section>
</div>"
`;
23 changes: 14 additions & 9 deletions app/includes/header.njk
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@
termsHref: config.feedbackLinkUrl
}) }}

{% if config.showCovid19 %}
<section class="bc-c-global-alert" data-test-id="covid19-global-alert" aria-labelledby="covid-alert-heading" role="banner">
<div class="nhsuk-width-container">
<h2 id="covid-alert-heading">Coronavirus (COVID-19)</h2>
<p>View Catalogue Solutions that help with coronavirus by <a data-test-id="vaccinations" href="{{ solutionsVacination }}">organising vaccinations </a>or <a data-test-id="covid19" href="{{ solutionsCovid }}">reducing visits to GP practices</a>.</p>
</div>
</section>
{% endif %}
</div>
{% if config.showCovid19 === 'true' %}
<section class="bc-c-global-alert" data-test-id="covid19-global-alert" aria-labelledby="covid-alert-heading" role="banner">
<div class="nhsuk-width-container">
<h2 id="covid-alert-heading">Coronavirus (COVID-19)</h2>

{% if ( config.showDfocvc === 'true')%}
<p>View Catalogue Solutions that help with coronavirus by <a data-test-id="vaccinations" href="{{ '/solutions/vaccinations' }}">organising vaccinations</a>.</p>
{% else %}
<p>View Catalogue Solutions that help with coronavirus by <a data-test-id="vaccinations" href="{{ '/solutions/vaccinations' }}">organising vaccinations</a> or <a data-test-id="covid19" href="{{ '/solutions/covid19' }}">reducing visits to GP practices</a>.</p>
{% endif %}

</div>
</section>
{% endif %}
23 changes: 22 additions & 1 deletion app/includes/header.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('header', () => {
it('should render the covid19 global warning if feature flag set', componentTester(setup, (harness) => {
const context = {
config: {
showCovid19: true,
showCovid19: 'true',
},
};

Expand All @@ -41,6 +41,27 @@ describe('header', () => {
expect(globalAlert.length).toEqual(0);
});
}));

it('should render the covid19 global warning without "coronavirus by organising..." text if showDfocvc flag is set to true', componentTester(setup, (harness) => {
const context = {
config: {
showCovid19: 'true',
showDfocvc: 'true',
},
};

harness.request(context, ($) => {
const globalAlert = $('[data-test-id="covid19-global-alert"]');
const title = globalAlert.find('div').find('h2');
const paragraph = globalAlert.find('div').find('p');
const vaccinationsLink = paragraph.find('[data-test-id="vaccinations"]');

expect(globalAlert.hasClass('bc-c-global-alert')).toEqual(true);
expect(title.text().trim()).toEqual('Coronavirus (COVID-19)');
expect(paragraph.text().trim()).toEqual('View Catalogue Solutions that help with coronavirus by organising vaccinations.');
expect(vaccinationsLink.attr('href')).toEqual('/solutions/vaccinations');
});
}));
});

describe('login/logout component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ exports[`capabilities-selector page should render the content 1`] = `
<svg class=\\"nhsuk-icon nhsuk-icon__chevron-left\\" xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\">
<path d=\\"M8.5 12c0-.3.1-.5.3-.7l5-5c.4-.4 1-.4 1.4 0s.4 1 0 1.4L10.9 12l4.3 4.3c.4.4.4 1 0 1.4s-1 .4-1.4 0l-5-5c-.2-.2-.3-.4-.3-.7z\\"></path>
</svg>
Go back to previous page</a>
Go back</a>
</div>
</div>
<h1 class=\\"nhsuk-u-margin-top-6 nhsuk-u-margin-bottom-4\\" data-test-id=\\"capabilities-selector-page-title\\">Catalogue Solutions Capabilities selector</h1>
<h1 class=\\"nhsuk-u-margin-top-6 nhsuk-u-margin-bottom-4\\" data-test-id=\\"capabilities-selector-page-title\\">Catalogue Solutions on the GP IT Futures framework Capability selector</h1>
<form method=\\"post\\">
<input type=\\"hidden\\" name=\\"_csrf\\" value=\\"\\">
<div class=\\"nhsuk-grid-row\\">
Expand Down
2 changes: 1 addition & 1 deletion app/pages/capabilities-selector/manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"title": "Catalogue Solutions – Capabilities selector",
"title": "Catalogue Solutions on the GP IT Futures framework – Capability selector",
"description": "Select the Capabilities that match the needs of your organisation. Any Catalogue Solutions found will have proven they can address these needs and, in some cases, will do even more."
}
2 changes: 1 addition & 1 deletion app/pages/capabilities-selector/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="nhsuk-u-padding-top-5" data-test-id="go-back-link">
{{ backLink({
"href": "./",
"text": "Go back to previous page"
"text": "Go back"
}) }}
</div>
<h1 class="nhsuk-u-margin-top-6 nhsuk-u-margin-bottom-4" data-test-id="capabilities-selector-page-title">{{ title }}</h1>
Expand Down
4 changes: 2 additions & 2 deletions app/pages/compare/__snapshots__/template.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ exports[`compare page should render the content 1`] = `
</div>
</div>
<h1 class=\\"nhsuk-u-margin-top-6 nhsuk-u-margin-bottom-4\\" data-test-id=\\"compare-page-title\\">Compare all Catalogue Solutions</h1>
<p class=\\"nhsuk-heading-l nhsuk-u-font-size-22 nhsuk-u-padding-bottom-5\\" data-test-id=\\"compare-page-description\\">Use our compare document to help find what you’re looking for. It gives an overview of all the Catalogue Solutions available and lets you filter them by the Capabilities they offer.</p>
<h1 class=\\"nhsuk-u-margin-top-6 nhsuk-u-margin-bottom-4\\" data-test-id=\\"compare-page-title\\">Compare all Catalogue Solutions on the GP IT Futures framework</h1>
<p class=\\"nhsuk-heading-l nhsuk-u-font-size-22 nhsuk-u-padding-bottom-5\\" data-test-id=\\"compare-page-description\\">Use our compare document to help find what you’re looking for. It gives an overview of all the Catalogue Solutions available on the GP IT Futures framework and lets you filter them by the Capabilities they offer.</p>
<div data-test-id=\\"compare-button\\">
Expand Down
4 changes: 2 additions & 2 deletions app/pages/compare/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "Compare all Catalogue Solutions",
"description": "Use our compare document to help find what you’re looking for. It gives an overview of all the Catalogue Solutions available and lets you filter them by the Capabilities they offer.",
"title": "Compare all Catalogue Solutions on the GP IT Futures framework",
"description": "Use our compare document to help find what you’re looking for. It gives an overview of all the Catalogue Solutions available on the GP IT Futures framework and lets you filter them by the Capabilities they offer.",
"compareButtonText": "Compare Solutions (.xlsx)",
"backLinkText": "Back"
}
33 changes: 25 additions & 8 deletions app/pages/homepage/__snapshots__/template.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,35 @@ exports[`home page should render the content 1`] = `
<div data-test-id=\\"homepage-promo-group\\" class=\\"nhsuk-width-container nhsuk-u-padding-top-5\\">
<ul class=\\"nhsuk-grid-row nhsuk-card-group nhsuk-u-margin-top-5\\">
<li class=\\"nhsuk-grid-column-one-half nhsuk-card-group__item\\" data-test-id=\\"vaccinations-promo\\">
<li class=\\"nhsuk-grid-column-one-half nhsuk-card-group__item\\" data-test-id=\\"browse-promo\\">
<div class=\\"nhsuk-card nhsuk-card--clickable\\">
<div class=\\"nhsuk-card__content\\">
<h3 class=\\"nhsuk-card__heading\\">
<a class=\\"nhsuk-card__link\\" href=\\"/solutions/vaccinations\\">Coronavirus vaccinations</a>
<a class=\\"nhsuk-card__link\\" href=\\"/solutions\\">GP IT Futures framework</a>
</h3>
<p class=\\"nhsuk-card__description\\">Find Catalogue Solutions that help organise coronavirus vaccinations</p>
<p class=\\"nhsuk-card__description\\">Find and compare Catalogue Solutions available on the GP IT Futures framework</p>
</div>
</div>
</li>
<li class=\\"nhsuk-grid-column-one-half nhsuk-card-group__item\\" data-test-id=\\"dfocvc-card\\">
<div class=\\"nhsuk-card nhsuk-card--clickable\\">
<div class=\\"nhsuk-card__content\\">
<h3 class=\\"nhsuk-card__heading\\">
<a class=\\"nhsuk-card__link\\" href=\\"/solutions/dfocvc001\\">DFOCVC framework</a>
</h3>
<p class=\\"nhsuk-card__description\\">Find online and video consultation Catalogue Solutions on the DFOCVC framework</p>
</div>
</div>
</li>
<li class=\\"nhsuk-grid-column-one-half nhsuk-card-group__item\\" data-test-id=\\"covid19-promo\\">
<div class=\\"nhsuk-card nhsuk-card--clickable\\">
Expand All @@ -45,18 +60,20 @@ exports[`home page should render the content 1`] = `
</li>
<li class=\\"nhsuk-grid-column-one-half nhsuk-card-group__item\\" data-test-id=\\"browse-promo\\">
<li class=\\"nhsuk-grid-column-one-half nhsuk-card-group__item\\" data-test-id=\\"vaccinations-promo\\">
<div class=\\"nhsuk-card nhsuk-card--clickable\\">
<div class=\\"nhsuk-card__content\\">
<h3 class=\\"nhsuk-card__heading\\">
<a class=\\"nhsuk-card__link\\" href=\\"/solutions\\">GP IT Futures framework</a>
<a class=\\"nhsuk-card__link\\" href=\\"/solutions/vaccinations\\">Coronavirus vaccinations</a>
</h3>
<p class=\\"nhsuk-card__description\\">Find and compare Catalogue solutions available on the GP IT Futures framework</p>
<p class=\\"nhsuk-card__description\\">Find Catalogue Solutions that help organise coronavirus vaccinations</p>
</div>
</div>
</li>
</li>
<li class=\\"nhsuk-grid-column-one-half nhsuk-card-group__item\\" data-test-id=\\"guidance-promo\\">
Expand Down
4 changes: 3 additions & 1 deletion app/pages/homepage/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
"vaccinationsPromoHeading": "Coronavirus vaccinations",
"vaccinationsPromoDescription": "Find Catalogue Solutions that help organise coronavirus vaccinations",
"viewSolutionsPromoHeading": "GP IT Futures framework",
"viewSolutionsPromoDescription": "Find and compare Catalogue solutions available on the GP IT Futures framework"
"viewSolutionsPromoDescription": "Find and compare Catalogue Solutions available on the GP IT Futures framework",
"dfocvcHeading": "DFOCVC framework",
"dfocvcDescription": "Find online and video consultation Catalogue Solutions on the DFOCVC framework"
}
Loading

0 comments on commit e9b2157

Please sign in to comment.