Skip to content

Commit 8382868

Browse files
authored
[FE] - 단위테스트 추가
[FE] - 단위테스트
2 parents a841312 + 09a7594 commit 8382868

File tree

72 files changed

+2887
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2887
-243
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이
2424
## ✅ PR Checklist
2525
PR이 다음 요구 사항을 충족하는지 확인하세요.
2626

27-
[ ] 커밋 메시지 컨벤션에 맞게 작성했습니다.
28-
[ ] 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).
27+
- [ ] 커밋 메시지 컨벤션에 맞게 작성했습니다.
28+
- [ ] 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).
2929

3030
<br/>
3131
Closes 이슈키-이슈번호
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Code Analyze Pull Request
2+
3+
run-name: Run code analyze triggered with pull request by ${{github.actor}}
4+
5+
on:
6+
pull_request:
7+
types: [opened, reopened, synchronize]
8+
branches:
9+
- main
10+
- develop
11+
env:
12+
NODE_VERSION: 18.12.0
13+
14+
jobs:
15+
code_analysis:
16+
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: 'Checkout repository on branch: ${{ github.REF }}'
21+
uses: actions/checkout@v3
22+
with:
23+
ref: ${{ github.HEAD_REF }}
24+
25+
- name: Retrieve entire repository history
26+
run: |
27+
git fetch --prune --unshallow
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v3
31+
with:
32+
node-version: ${{ env.NODE_VERSION }}
33+
34+
- name: Cache node modules
35+
uses: actions/cache@v3
36+
id: npm-cache
37+
with:
38+
path: '**/node_modules'
39+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
40+
restore-keys: |
41+
${{ runner.os }}-node-
42+
43+
- name: Install Dependencies
44+
if: steps.npm-cache.outputs.cache-hit != 'true'
45+
run: npm install
46+
47+
- name: Coverage Test
48+
continue-on-error: true
49+
run: npm run coverage
50+
51+
- name: Run an analysis of the ${{ github.REF }} branch ${{ github.BASE_REF }} base
52+
uses: sonarsource/sonarqube-scan-action@master
53+
env:
54+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
55+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Code Analyze branch
2+
3+
run-name: Run code analyze triggered with push by ${{github.actor}}
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
- develop
10+
11+
jobs:
12+
code_analysis:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: 'Checkout repository on branch: ${{ github.REF }}'
17+
uses: actions/checkout@v3
18+
with:
19+
ref: ${{ github.REF }}
20+
fetch-depth: 0
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: ${{ env.NODE_VERSION }}
26+
27+
- name: Cache node modules
28+
uses: actions/cache@v3
29+
id: npm-cache
30+
with:
31+
path: '**/node_modules'
32+
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-node-
35+
36+
- name: Install Dependencies
37+
if: steps.npm-cache.outputs.cache-hit != 'true'
38+
run: yarn install
39+
40+
- name: Coverage Test
41+
continue-on-error: true
42+
run: yarn run coverage
43+
44+
- name: 'Run an analysis of the ${{ github.REF }} branch'
45+
uses: sonarsource/sonarqube-scan-action@master
46+
env:
47+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
48+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

.github/workflows/deploy.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Deploy remix app
22

3-
run-name: Deploy remix app to docker hub by ${{github.actor}}
3+
run-name: Deploy remix app to docker hub and start services by ${{github.actor}}
44

55
on:
66
push:
@@ -19,6 +19,8 @@ jobs:
1919
echo "VITE_OAUTH_URL=${{ secrets.VITE_OAUTH_URL }}" > .env
2020
echo "VITE_API_URL=${{ secrets.VITE_API_URL }}" >> .env
2121
echo "VITE_STOMP_URL=${{ secrets.VITE_STOMP_URL }}" >> .env
22+
echo "VITE_AI_URL=${{ secrets.VITE_AI_URL }}" >> .env
23+
2224
- name: Build image
2325
run: |
2426
docker build -t ${{secrets.DOCKER_USERNAME}}/if-fe:latest .

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ dist-ssr
2727
/.react-router/
2828
/build/
2929

30+
coverage
3031
.env

biome.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"options": {
4848
"strictCase": false,
4949
"requireAscii": true,
50-
"filenameCases": ["camelCase", "export"]
50+
"filenameCases": ["PascalCase", "camelCase", "export"]
5151
}
5252
}
5353
},
@@ -60,8 +60,8 @@
6060
{
6161
"include": [
6262
"test/**/*",
63-
"*.test.{ts,tsx,js,jsx}",
64-
"*.spec.{ts,tsx,js,jsx}",
63+
"**/*.test.{ts,tsx,js,jsx}",
64+
"**/*.spec.{ts,tsx,js,jsx}",
6565
"src/app/routes/*"
6666
],
6767
"linter": {

package.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"build": "react-router build",
99
"start": "react-router-serve ./build/server/index.js",
1010
"typecheck": "react-router typegen && tsc",
11-
"lint": "biome check --write --unsafe .",
11+
"test": "vitest",
12+
"coverage": "vitest run --coverage",
13+
"lint": "biome check --write .",
1214
"postinstall": "husky"
1315
},
1416
"lint-staged": {
@@ -38,23 +40,28 @@
3840
"@react-router/dev": "^7.5.3",
3941
"@svgr/rollup": "^8.1.0",
4042
"@tailwindcss/vite": "^4.1.5",
43+
"@testing-library/dom": "^10.4.0",
44+
"@testing-library/jest-dom": "^6.6.3",
45+
"@testing-library/react": "^16.3.0",
46+
"@testing-library/user-event": "^14.6.1",
4147
"@types/node": "^22.15.3",
4248
"@types/react": "^19.1.2",
4349
"@types/react-dom": "^19.1.3",
50+
"@vitest/coverage-v8": "^3.1.4",
4451
"globals": "^16.0.0",
4552
"husky": "^9.1.7",
53+
"jsdom": "^26.1.0",
4654
"lint-staged": "^15.5.1",
4755
"msw": "^2.8.2",
4856
"tailwindcss": "^4.1.5",
4957
"typescript": "~5.7.2",
5058
"vite": "^6.3.1",
5159
"vite-plugin-svgr": "^4.3.0",
52-
"vite-tsconfig-paths": "^5.1.4"
60+
"vite-tsconfig-paths": "^5.1.4",
61+
"vitest": "^3.1.4"
5362
},
5463
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
5564
"msw": {
56-
"workerDirectory": [
57-
"public"
58-
]
65+
"workerDirectory": ["public"]
5966
}
6067
}

setupTests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@testing-library/jest-dom';

sonar-project.properties

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# 프로젝트 식별자
2+
sonar.projectKey=CleanEngine_cleanengine-fe_c6875537-ed9d-4dfe-b79c-ea5cb6d2a0e3
3+
4+
# 프로젝트 이름
5+
sonar.projectName=CleanEngine Frontend
6+
7+
# 소스 코드 위치
8+
sonar.sources=src
9+
10+
# 테스트 파일 위치 및 패턴
11+
sonar.tests=src
12+
sonar.test.inclusions=**/*.test.tsx,**/*.test.ts,**/*.spec.tsx,**/*.spec.ts
13+
14+
# TypeScript/JavaScript 설정
15+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
16+
sonar.typescript.tsconfigPath=tsconfig.json
17+
18+
# 분석에서 제외할 파일/디렉토리
19+
sonar.exclusions=node_modules/**,build/**,dist/**,coverage/**,public/**,**/*.test.tsx,**/*.test.ts,**/*.spec.tsx,**/*.spec.ts
20+
21+
# 코드 중복 검사 제외
22+
sonar.cpd.exclusions=**/*.test.tsx,**/*.test.ts
23+
24+
# 언어 설정
25+
sonar.language=ts
26+
sonar.typescript.file.suffixes=.ts,.tsx
27+
sonar.javascript.file.suffixes=.js,.jsx
28+
29+
# 커버리지 파일 위치
30+
sonar.javascript.lcov.reportPaths=./coverage/lcov.info

src/app/entry.client.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import { StrictMode, startTransition } from 'react';
23
import { hydrateRoot } from 'react-dom/client';
34
import { HydratedRouter } from 'react-router/dom';
@@ -21,3 +22,5 @@ prepareApp().then(() => {
2122
);
2223
});
2324
});
25+
26+
/* v8 ignore end */

0 commit comments

Comments
 (0)