Skip to content

Commit

Permalink
🩹 Fix unconditional creation of default user (#295)
Browse files Browse the repository at this point in the history
* 🧪 Add failing test to reproduce issue 273

* 🚇 Add CI job to test migrations

* 🩹 Fix unconditional creation of default user

* 🧹 Run format command

* 🧰 Add format check
  • Loading branch information
s-weigand authored Jul 24, 2024
1 parent 20ec8cd commit 37f4371
Show file tree
Hide file tree
Showing 17 changed files with 7,255 additions and 338 deletions.
27 changes: 25 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18'

Expand All @@ -21,6 +21,9 @@ jobs:
- name: Static analysis
run: npm run lint

- name: Check formatting
run: npm run format:check

- name: Unit tests
run: npm run test:cov

Expand All @@ -42,3 +45,23 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}

test-migrations:
# See: https://github.com/Visual-Regression-Tracker/backend/issues/273
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install npm dependencies
working-directory: prisma
run: npm ci

- name: Static analysis
working-directory: prisma
run: npm run test
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"prisma/**/*.ts\"",
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\" \"prisma/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
"lint": "eslint \"{src,apps,libs,test,prisma}/**/*.ts\"",
"test": "jest --projects src",
"test:watch": "jest --projects src --watch",
"test:cov": "jest --projects src --coverage",
Expand Down
7 changes: 7 additions & 0 deletions prisma/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient({
// 'info' | 'query' | 'warn' | 'error'
log: ['query'],
});
export default prisma;
6 changes: 6 additions & 0 deletions prisma/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
clearMocks: true,
preset: 'ts-jest',
testEnvironment: 'node',
setupFilesAfterEnv: ['<rootDir>/test/client.mock.ts'],
};
Loading

0 comments on commit 37f4371

Please sign in to comment.