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

Run backend tests in pipeline #6350

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,6 @@ docker/*.sql
# Gource
lib/
*.ppm

# puppeteer cache
frontend/.cache
120 changes: 0 additions & 120 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@
"opener": "^1.5.2",
"prettier": "2.5.1",
"protractor": "^7.0.0",
"puppeteer": "^22.15.0",
"require-dir": "^1.2.0",
"rimraf": "^3.0.2",
"sandboxed-module": "^2.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ describe('/server/routes/establishment/uploadFiles.js', () => {
sinon.restore();
});

beforeEach(() => {
sinon.stub(S3.s3, 'putObject').returns({
promise: async () => {
return {};
},
});
});

describe('uploadedPut', () => {
const TrainingFile = 'LOCALESTID,UNIQUEWORKERID,CATEGORY,DESCRIPTION,DATECOMPLETED,EXPIRYDATE,ACCREDITED,NOTES';
const EstablishmentFile =
Expand All @@ -19,12 +27,6 @@ describe('/server/routes/establishment/uploadFiles.js', () => {
'LOCALESTID,UNIQUEWORKERID,STATUS,DISPLAYID,NINUMBER,POSTCODE,DOB,GENDER,ETHNICITY,NATIONALITY,BRITISHCITIZENSHIP,COUNTRYOFBIRTH,YEAROFENTRY,DISABLED,CARECERT,L2CARECERT,RECSOURCE,HANDCVISA,INOUTUK,STARTDATE,STARTINSECT,APPRENTICE,EMPLSTATUS,ZEROHRCONT,DAYSSICK,SALARYINT,SALARY,HOURLYRATE,MAINJOBROLE,MAINJRDESC,CONTHOURS,AVGHOURS,NMCREG,NURSESPEC,AMHP,SCQUAL,NONSCQUAL,QUALACH01,QUALACH01NOTES,QUALACH02,QUALACH02NOTES,QUALACH03,QUALACH03NOTES';
const OtherFile = 'Test,This,is,NOT,A,BULK,UPLOAD,FILE';

sinon.stub(S3.s3, 'putObject').returns({
promise: async () => {
return {};
},
});

it('Identifies establishment files', async () => {
sinon.stub(S3.s3, 'listObjects').returns({
promise: async () => {
Expand Down
18 changes: 18 additions & 0 deletions buildspec/build/build-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 0.2

env:
variables:
NODE_OPTIONS: "--max_old_space_size=8192"

phases:
install:
runtime-versions:
nodejs: 18
build:
commands:
- echo $CODEBUILD_RESOLVED_SOURCE_VERSION > commit_hash.txt
- cd backend && npm ci

artifacts:
files:
- '**/*'
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ phases:
- echo $CODEBUILD_RESOLVED_SOURCE_VERSION > commit_hash.txt
- cd frontend && npm ci
- npm run build:test
- cd ../backend && npm ci

artifacts:
files:
Expand Down
7 changes: 5 additions & 2 deletions buildspec/build/test-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ phases:
install:
runtime-versions:
nodejs: 18
pre_build:
commands:
- cd lambdas/bulkUpload && npm ci
- cd ../../backend && npm ci
build:
commands:
- cd backend && npm ci
- npm run server:lambda:cover:unit:ci; EXITCODE=$?
- npm run server:test:unit
1 change: 1 addition & 0 deletions buildspec/build/test-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ phases:
build:
commands:
- cd frontend
- npm ci
- npm run test-headless


3 changes: 2 additions & 1 deletion buildspec/build/test-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ phases:
- apt-get -y install google-chrome-stable
build:
commands:
- cd frontend
- cd frontend
- npm ci
- npm install -g @lhci/[email protected]
- npm run build
- lhci autorun
9 changes: 9 additions & 0 deletions frontend/.puppeteerrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { join } = require('path');

/**
* @type {import("puppeteer").Configuration}
*/
module.exports = {
// Changes the cache location for Puppeteer.
cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
};
Loading