Skip to content

Commit fdaadb6

Browse files
committed
fix(backend): adapt test hooks for vitest 4.1.x fixture access change
vitest 4.1.x no longer provides built-in task context (id) in beforeAll/afterAll hooks. The id property was an internal vitest task identifier, not a user-defined fixture via test.extend(). Replace { id: taskId } destructuring with crypto.randomUUID(). Ref: vitest-dev/vitest#9786 Ref: https://vitest.dev/blog/vitest-4-1
1 parent d799b4d commit fdaadb6

14 files changed

Lines changed: 30 additions & 16 deletions

apps/backend/src/routes/api/v1/entity/router.entity.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ describe("エンティティの取得", () => {
1414
// テスト実施ユーザー
1515
let testExecutionUser: TestExecutionUser
1616

17-
beforeAll(async ({ id: taskId }) => {
17+
beforeAll(async () => {
18+
const taskId = crypto.randomUUID()
1819
const { user } = await setup(taskId)
1920
testExecutionUser = user
2021
})

apps/backend/src/routes/api/v1/entity/router.item.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ describe("エンティティ項目の取得", () => {
217217
// テスト実施ユーザー
218218
let testExecutionUser: TestExecutionUser
219219

220-
beforeAll(async ({ id: taskId }) => {
220+
beforeAll(async () => {
221+
const taskId = crypto.randomUUID()
221222
const { user } = await setup(taskId)
222223
testExecutionUser = user
223224
})

apps/backend/src/routes/api/v1/file/router.get.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ describe("GET /api/v1/files/:id - ファイル取得", () => {
1313
// テスト実施ユーザー
1414
let testExecutionUser: TestExecutionUser
1515

16-
beforeAll(async ({ id: taskId }) => {
16+
beforeAll(async () => {
17+
const taskId = crypto.randomUUID()
1718
const { user } = await setup(taskId)
1819
testExecutionUser = user
1920
})

apps/backend/src/routes/api/v1/file/router.post.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ describe("POST /api/v1/files - ファイル作成", () => {
1313
// テスト実施ユーザー
1414
let testExecutionUser: TestExecutionUser
1515

16-
beforeAll(async ({ id: taskId }) => {
16+
beforeAll(async () => {
17+
const taskId = crypto.randomUUID()
1718
const { user } = await setup(taskId)
1819
testExecutionUser = user
1920
})

apps/backend/src/routes/api/v1/record/router.delete.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ describe("DELETE /records/:entity_name/:id - レコード削除", () => {
1919
// テスト実施ユーザー
2020
let testExecutionUser: TestExecutionUser
2121

22-
beforeAll(async ({ id: taskId }) => {
22+
beforeAll(async () => {
23+
const taskId = crypto.randomUUID()
2324
const { user } = await setup(taskId)
2425
testExecutionUser = user
2526
})

apps/backend/src/routes/api/v1/record/router.get.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ describe("GET /records/:entity_name - レコード一覧取得(検索)", ()
2020
// テスト実施ユーザー
2121
let testExecutionUser: TestExecutionUser
2222

23-
beforeAll(async ({ id: taskId }) => {
23+
beforeAll(async () => {
24+
const taskId = crypto.randomUUID()
2425
const { user } = await setup(taskId)
2526
testExecutionUser = user
2627
})

apps/backend/src/routes/api/v1/record/router.patch.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,22 @@ type RecordReference = {
2525
}
2626

2727
describe("PATCH /records/:entity_name/:id - レコード更新", () => {
28+
const taskId = crypto.randomUUID()
2829
// テスト実施ユーザー
2930
let testExecutionUser: TestExecutionUser
3031

3132
// テストデータ(参照先用)
3233
let accountRecordReference: RecordReference
3334
let leadRecordReference: RecordReference
3435

35-
beforeAll(async ({ id: taskId }) => {
36+
beforeAll(async () => {
3637
const { user, account, lead } = await setup(taskId)
3738
testExecutionUser = user
3839
accountRecordReference = { entity_name: "account", id: account.id }
3940
leadRecordReference = { entity_name: "lead", id: lead.id }
4041
})
4142

42-
afterAll(async ({ id: taskId }) => {
43+
afterAll(async () => {
4344
await cleanup(taskId)
4445
})
4546

apps/backend/src/routes/api/v1/record/router.post.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,22 @@ type RecordReference = {
2424
}
2525

2626
describe("POST /records/:entity_name - レコード作成", () => {
27+
const taskId = crypto.randomUUID()
2728
// テスト実施ユーザー
2829
let testExecutionUser: TestExecutionUser
2930

3031
// テストデータ(参照先用)
3132
let accountRecordReference: RecordReference
3233
let leadRecordReference: RecordReference
3334

34-
beforeAll(async ({ id: taskId }) => {
35+
beforeAll(async () => {
3536
const { user, account, lead } = await setup(taskId)
3637
testExecutionUser = user
3738
accountRecordReference = { entity_name: "account", id: account.id }
3839
leadRecordReference = { entity_name: "lead", id: lead.id }
3940
})
4041

41-
afterAll(async ({ id: taskId }) => {
42+
afterAll(async () => {
4243
await cleanup(taskId)
4344
})
4445

apps/backend/src/routes/api/v1/system-user/router.get.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ describe("GET /api/v1/system-users - システムユーザー一覧取得", () =
1717
// テスト実施ユーザー
1818
let testExecutionUser: TestExecutionUser
1919

20-
beforeAll(async ({ id: taskId }) => {
20+
beforeAll(async () => {
21+
const taskId = crypto.randomUUID()
2122
const { user } = await setup(taskId)
2223
testExecutionUser = user
2324
})

apps/backend/src/routes/internal-auth/router.authorize.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ describe("POST /auth/authorize - 認可エンドポイント", () => {
5555
// テスト実施ユーザー
5656
let testExecutionUser: TestExecutionUser
5757

58-
beforeAll(async ({ id: taskId }) => {
58+
beforeAll(async () => {
59+
const taskId = crypto.randomUUID()
5960
const { user } = await setup(taskId)
6061
testExecutionUser = user
6162
})

0 commit comments

Comments
 (0)