Skip to content

Commit 4096401

Browse files
chore: merge branch 'dev' into feat/styled-avatar
2 parents 4a3a629 + 52b7dfc commit 4096401

15 files changed

Lines changed: 723 additions & 22 deletions

File tree

.github/workflows/code-quality-workflow.yaml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ on:
55
types: [opened, synchronize, reopened]
66

77
permissions:
8-
contents: read
9-
pull-requests: write
10-
issues: write
8+
contents: read
9+
pull-requests: write
10+
issues: write
1111

1212
jobs:
1313
style-quality:
@@ -16,15 +16,21 @@ jobs:
1616

1717
steps:
1818
- uses: actions/checkout@v4
19+
20+
- name: Set up Corepack
21+
run: corepack enable
22+
23+
- name: Set up pnpm
24+
run: corepack prepare pnpm@latest --activate
25+
1926
- uses: actions/setup-node@v4
2027
with:
2128
node-version: 22
22-
23-
- run: corepack enable
24-
- run: corepack prepare pnpm@latest --activate
29+
cache: 'pnpm'
30+
cache-dependency-path: '**/pnpm-lock.yaml'
2531

2632
- name: Install dependencies
27-
run: pnpm install
33+
run: pnpm install --frozen-lockfile
2834

2935
- name: Run Formatter
3036
run: pnpm run format:check
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script setup lang="ts">
2+
const { data } = useFetch('/api/user/ravenbot');
3+
</script>
4+
5+
<template>
6+
<div>
7+
<h1 class="p-4 text-2xl">
8+
{{ $t('testing.welcome') }}
9+
</h1>
10+
<div v-if="data" class="px-4">
11+
<h1 class="text-lg font-semibold">{{ data.name }}</h1>
12+
<p class="text-muted-foreground text-sm">{{ '@' + data.username }}</p>
13+
</div>
14+
</div>
15+
</template>

app/plugins/msw.client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default defineNuxtPlugin(async () => {
2+
if (import.meta.dev) {
3+
const { worker } = await import('../../mocks/browser');
4+
await worker.start({
5+
onUnhandledRequest: 'bypass',
6+
});
7+
console.warn('Mock Service Worker (client) started');
8+
}
9+
});

mocks/browser.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { setupWorker } from 'msw/browser';
2+
import { handlers } from './handler';
3+
4+
export const worker = setupWorker(...handlers);

mocks/handler.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { handlers as userHandlers } from './handlers/user';
2+
// Import more handlers as needed
3+
4+
export const handlers = [
5+
...userHandlers,
6+
// Add More handlers here
7+
];

mocks/handlers/user.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { http, HttpResponse } from 'msw';
2+
3+
const mockUsers = {
4+
johndoe: { id: 'abc-123', name: 'John Doe', username: 'johndoe' },
5+
janedoe: { id: 'xyz-456', name: 'Jane Doe', username: 'janedoe' },
6+
ravenbot: { id: 'bot-001', name: 'Raven Bot', username: 'ravenbot' },
7+
};
8+
9+
const API_URL = process.env.BACKEND_URL;
10+
11+
export const handlers = [
12+
http.get(`${API_URL}/user/:username`, ({ params }) => {
13+
const { username } = params;
14+
15+
const user = mockUsers[username as keyof typeof mockUsers];
16+
17+
if (!user) {
18+
return HttpResponse.json({ message: `User "${username}" not found` }, { status: 404 });
19+
}
20+
21+
return HttpResponse.json(user, { status: 200 });
22+
}),
23+
];

mocks/node.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { setupServer } from 'msw/node';
2+
import { handlers } from './handler';
3+
4+
export const server = setupServer(...handlers);

nuxt.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ export default defineNuxtConfig({
1010
enabled: true,
1111
},
1212
},
13-
imports: { autoImport: false },
14-
components: false,
1513
modules: [
1614
'@nuxt/eslint',
1715
'@nuxt/fonts',

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"happy-dom": "^19.0.2",
4949
"husky": "^9.1.7",
5050
"lint-staged": "^16.2.3",
51+
"msw": "^2.11.5",
5152
"playwright-core": "^1.55.1",
5253
"prettier": "^3.6.2",
5354
"prettier-plugin-tailwindcss": "^0.6.14",
@@ -65,5 +66,10 @@
6566
},
6667
"engines": {
6768
"node": ">=22.0.0"
69+
},
70+
"msw": {
71+
"workerDirectory": [
72+
"public"
73+
]
6874
}
6975
}

0 commit comments

Comments
 (0)