Skip to content

Commit 2df475c

Browse files
authored
🩹 Fix unconditional creation of default user (#295) (#296)
* 🧪 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 Authored-by: Sebastian Weigand <[email protected]>
1 parent 20ec8cd commit 2df475c

17 files changed

+7255
-338
lines changed

‎.github/workflows/workflow.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
runs-on: ubuntu-22.04
99

1010
steps:
11-
- uses: actions/checkout@v3
11+
- uses: actions/checkout@v4
1212

1313
- name: Setup Node.js environment
14-
uses: actions/setup-node@v3
14+
uses: actions/setup-node@v4
1515
with:
1616
node-version: '18'
1717

@@ -21,6 +21,9 @@ jobs:
2121
- name: Static analysis
2222
run: npm run lint
2323

24+
- name: Check formatting
25+
run: npm run format:check
26+
2427
- name: Unit tests
2528
run: npm run test:cov
2629

@@ -42,3 +45,23 @@ jobs:
4245
env:
4346
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4447
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
48+
49+
test-migrations:
50+
# See: https://github.com/Visual-Regression-Tracker/backend/issues/273
51+
runs-on: ubuntu-22.04
52+
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Setup Node.js environment
57+
uses: actions/setup-node@v4
58+
with:
59+
node-version: '18'
60+
61+
- name: Install npm dependencies
62+
working-directory: prisma
63+
run: npm ci
64+
65+
- name: Static analysis
66+
working-directory: prisma
67+
run: npm run test

‎package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
"scripts": {
99
"prebuild": "rimraf dist",
1010
"build": "nest build",
11-
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
11+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"prisma/**/*.ts\"",
12+
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\" \"prisma/**/*.ts\"",
1213
"start": "nest start",
1314
"start:dev": "nest start --watch",
1415
"start:debug": "nest start --debug --watch",
1516
"start:prod": "node dist/main",
16-
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
17+
"lint": "eslint \"{src,apps,libs,test,prisma}/**/*.ts\"",
1718
"test": "jest --projects src",
1819
"test:watch": "jest --projects src --watch",
1920
"test:cov": "jest --projects src --coverage",

‎prisma/client.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { PrismaClient } from '@prisma/client';
2+
3+
const prisma = new PrismaClient({
4+
// 'info' | 'query' | 'warn' | 'error'
5+
log: ['query'],
6+
});
7+
export default prisma;

‎prisma/jest.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
clearMocks: true,
3+
preset: 'ts-jest',
4+
testEnvironment: 'node',
5+
setupFilesAfterEnv: ['<rootDir>/test/client.mock.ts'],
6+
};

0 commit comments

Comments
 (0)