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

Feat/implement testcontainers #235

Merged
merged 46 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7e40251
testcontainers in a helper
Ellenn-A Nov 11, 2024
bdd0998
Add after block for cleanp and use lts node instead of current
mattdean-digicatapult Nov 11, 2024
a51b1b7
bob and charlie
Ellenn-A Nov 11, 2024
ded2087
passing integr and e2e
Ellenn-A Nov 12, 2024
4a4ccbc
accidentaly removed, putting back
Ellenn-A Nov 12, 2024
0bc96e8
test workflow
Ellenn-A Nov 12, 2024
f655c48
testing test workflow
Ellenn-A Nov 12, 2024
142b238
checkout
Ellenn-A Nov 12, 2024
344c143
typo
Ellenn-A Nov 12, 2024
25293c8
install playwright
Ellenn-A Nov 12, 2024
2b0a838
saving playwright as a devDep
Ellenn-A Nov 12, 2024
f378fda
test workflow
Ellenn-A Nov 12, 2024
c3bccc2
no debug
Ellenn-A Nov 12, 2024
f157027
test
Ellenn-A Nov 12, 2024
86777d2
debug on
Ellenn-A Nov 12, 2024
1897f8c
playwright report path
Ellenn-A Nov 12, 2024
e7a3498
adding browsers
Ellenn-A Nov 12, 2024
a3a3caf
testing sht
Ellenn-A Nov 13, 2024
b35ec31
wrong envars
Ellenn-A Nov 13, 2024
a42fa99
chromium disabled
Ellenn-A Nov 13, 2024
3161382
testing sth
Ellenn-A Nov 13, 2024
0bd3d88
node versioin
Ellenn-A Nov 13, 2024
2436dca
sth
Ellenn-A Nov 13, 2024
84ac94e
trying node v 22 again
Ellenn-A Nov 13, 2024
561e0a3
Merge remote-tracking branch 'origin/main' into feat/implement-testco…
Ellenn-A Nov 13, 2024
36c7d62
revert test.yml
Ellenn-A Nov 13, 2024
c2b8fc6
bigger timeouts
Ellenn-A Nov 13, 2024
2b8792b
lint
Ellenn-A Nov 13, 2024
d7a22a9
depcheck
Ellenn-A Nov 13, 2024
9fcf51b
api key
Ellenn-A Nov 13, 2024
4bbc3e3
missing deps
Ellenn-A Nov 13, 2024
0df26c4
Updating version to 0.15.0
dc-autobot[bot] Nov 15, 2024
2ebad32
test workflow
Ellenn-A Nov 18, 2024
b9a1728
test
Ellenn-A Nov 18, 2024
017b66e
updated test
Ellenn-A Nov 18, 2024
1793574
wrong test cmd
Ellenn-A Nov 18, 2024
0405610
Merge remote-tracking branch 'origin/main' into feat/implement-testco…
Ellenn-A Nov 18, 2024
cb1df09
releae workflow
Ellenn-A Nov 18, 2024
a068f3c
Merge remote-tracking branch 'origin/main' into feat/implement-testco…
Ellenn-A Nov 18, 2024
b16cad0
Merge remote-tracking branch 'origin/main' into feat/implement-testco…
Ellenn-A Nov 19, 2024
b3d4f57
containers removed
Ellenn-A Nov 19, 2024
6ce4a5e
comments
Ellenn-A Nov 19, 2024
99f7e39
docs
Ellenn-A Nov 19, 2024
c861ea2
docs
Ellenn-A Nov 19, 2024
3fb559c
cleanup containers
Ellenn-A Nov 19, 2024
f65c724
test update
Ellenn-A Nov 19, 2024
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
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
tests-npm:
uses: digicatapult/shared-workflows/.github/workflows/tests-npm.yml@main
with:
docker_compose_file: ''
npm_build_command: 'npm run tsoa:build'
pre_test_command: 'npm run db:migrate'
docker_compose_file: docker-compose.yml
e2e-tests-npm:
uses: digicatapult/shared-workflows/.github/workflows/tests-e2e-npm.yml@main
with:
docker_compose_file: docker-compose.e2e.yml
test_command: 'docker compose -f docker-compose.e2e.yml up --exit-code-from e2e-tests --abort-on-container-exit --quiet-pull'
docker_compose_file: ''
pre_test_command: 'npm ci && npx playwright install-deps && npx playwright install'
test_command: 'npm run test:playwright || exit 1'
permissions:
contents: write
secrets: inherit
Expand All @@ -38,4 +38,4 @@ jobs:
uses: digicatapult/shared-workflows/.github/workflows/release-github.yml@main
permissions:
contents: write
secrets: inherit
secrets: inherit
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
tests-npm:
uses: digicatapult/shared-workflows/.github/workflows/tests-npm.yml@main
with:
docker_compose_file: ''
npm_build_command: 'npm run tsoa:build'
pre_test_command: 'npm run db:migrate'
docker_compose_file: docker-compose.yml
e2e-tests-npm:
uses: digicatapult/shared-workflows/.github/workflows/tests-e2e-npm.yml@main
with:
docker_compose_file: docker-compose.e2e.yml
test_command: 'docker compose -f docker-compose.e2e.yml up --exit-code-from e2e-tests --abort-on-container-exit --quiet-pull'
docker_compose_file: ''
pre_test_command: 'npm ci && npx playwright install-deps && npx playwright install'
test_command: 'npm run test:playwright || exit 1'
permissions:
contents: write
secrets: inherit
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ COPY . .
RUN npm run build

# Test stage
FROM node:current-bookworm-slim AS test
FROM node:lts-bookworm-slim AS test

WORKDIR /veritable-ui

Expand Down
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ npm run test:unit

Integration tests are placed at the root level of a repository and can be found at the root level `test/` folder along with mock services and helpers and a test environment variables that will be in `test/test.env`.

Integration tests can be run locally by executing the below command
Integration tests can be run locally by executing the below command (it is recommended to add debugging so you can follow the logs in the console, refer to [testcontainers section](#testcontainers))

```sh
npm run test:integration
Expand Down Expand Up @@ -196,6 +196,7 @@ Then run:
npm run test:e2e
```

(it is recommended to add debugging so you can follow the logs in the console, refer to [testcontainers section](#testcontainers))
A browser window will pop up where you can run tests and follow their progress. Alternatively you can run:

```sh
Expand All @@ -212,6 +213,36 @@ docker compose -f docker-compose.e2e.yml up

Then you'll find the test results in directory `playwright-report` at root level.

### Testcontainers

so see logs from a container e.g. if it is dying on startup add:

```
.withLogConsumer((stream) => {
stream.on('data', (line) => console.log(line))
stream.on('err', (line) => console.error(line))
stream.on('end', () => console.log('Stream closed'))
})
```

and run with

```
DEBUG=testcontainers* npm run test:integration
```

or

```
DEBUG=testcontainers* npm run test:e2e
```

Normally the containers are removed after a run, however you can keep them for further inspection by adding this:

```
await container.stop({ remove: false })
```

## Database

This service is dependant on postgreSQL which will sync up across all nodes and will update cloudagent when needed. We use `knex` wrapper for wrapping [create, read, write, update] database quries. We also have different models for inserting and returning data which gives us a control of sensitive data or data we do not want to get along the record. We also use **zod** for enchanted validation. It's currently used in `src/models/db/types.ts` file.
Expand Down
Loading