From 3f61f149c2998d69b6181ad580b40a27e5dfae85 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Mon, 30 Sep 2024 12:50:40 +0900 Subject: [PATCH 1/4] fix: removed duplicate error messages --- .github/workflows/worker-deploy.yml | 2 +- package.json | 2 +- src/handlers/shared/start.ts | 20 ++-- src/handlers/shared/stop.ts | 2 +- src/plugin.ts | 6 +- src/utils/issue.ts | 4 +- wrangler.toml | 3 + yarn.lock | 153 ++++++++++++++-------------- 8 files changed, 96 insertions(+), 96 deletions(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 659aaaa..98c33eb 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -35,7 +35,7 @@ jobs: id: wrangler_deploy uses: cloudflare/wrangler-action@v3 with: - wranglerVersion: "3.57.0" + wranglerVersion: "3.78" apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} secrets: | diff --git a/package.json b/package.json index 97c1e12..03675d0 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "tsx": "4.15.6", "typescript": "5.4.5", "typescript-eslint": "7.13.1", - "wrangler": "3.60.3" + "wrangler": "3.78.12" }, "lint-staged": { "*.ts": [ diff --git a/src/handlers/shared/start.ts b/src/handlers/shared/start.ts index d1e5a1c..8433e5b 100644 --- a/src/handlers/shared/start.ts +++ b/src/handlers/shared/start.ts @@ -18,7 +18,7 @@ export async function start( const { taskStaleTimeoutDuration } = config; if (!sender) { - throw new Error(logger.error(`Skipping '/start' since there is no sender in the context.`).logMessage.raw); + throw logger.error(`Skipping '/start' since there is no sender in the context.`); } // is it a child issue? @@ -27,7 +27,7 @@ export async function start( context, "```diff\n# Please select a child issue from the specification checklist to work on. The '/start' command is disabled on parent issues.\n```" ); - throw new Error(logger.error(`Skipping '/start' since the issue is a parent issue`).logMessage.raw); + throw logger.error(`Skipping '/start' since the issue is a parent issue`); } let commitHash: string | null = null; @@ -46,7 +46,7 @@ export async function start( // is it assignable? if (issue.state === ISSUE_TYPE.CLOSED) { - throw new Error(logger.error("This issue is closed, please choose another.", { issueNumber: issue.number }).logMessage.raw); + throw logger.error("This issue is closed, please choose another.", { issueNumber: issue.number }); } const assignees = issue?.assignees ?? []; @@ -54,11 +54,9 @@ export async function start( // find out if the issue is already assigned if (assignees.length !== 0) { const isCurrentUserAssigned = !!assignees.find((assignee) => assignee?.login === sender.login); - throw new Error( - logger.error( - isCurrentUserAssigned ? "You are already assigned to this task." : "This issue is already assigned. Please choose another unassigned task.", - { issueNumber: issue.number } - ).logMessage.raw + throw logger.error( + isCurrentUserAssigned ? "You are already assigned to this task." : "This issue is already assigned. Please choose another unassigned task.", + { issueNumber: issue.number } ); } @@ -81,7 +79,7 @@ export async function start( } if (error) { - throw new Error(logger.error(error, { issueNumber: issue.number }).logMessage.raw); + throw logger.error(error, { issueNumber: issue.number }); } // get labels @@ -89,7 +87,7 @@ export async function start( const priceLabel = labels.find((label: Label) => label.name.startsWith("Price: ")); if (!priceLabel) { - throw new Error(logger.error("No price label is set to calculate the duration", { issueNumber: issue.number }).logMessage.raw); + throw logger.error("No price label is set to calculate the duration", { issueNumber: issue.number }); } const deadline = getDeadline(labels); @@ -161,7 +159,7 @@ async function handleTaskLimitChecks(username: string, context: Context, logger: } if (await hasUserBeenUnassigned(context, username)) { - throw new Error(logger.error(`${username} you were previously unassigned from this task. You cannot be reassigned.`, { username }).logMessage.raw); + throw logger.error(`${username} you were previously unassigned from this task. You cannot be reassigned.`, { username }); } return true; diff --git a/src/handlers/shared/stop.ts b/src/handlers/shared/stop.ts index af41cf6..9bd57ff 100644 --- a/src/handlers/shared/stop.ts +++ b/src/handlers/shared/stop.ts @@ -17,7 +17,7 @@ export async function stop( const userToUnassign = assignees.find((assignee: Partial) => assignee?.login?.toLowerCase() === sender.login.toLowerCase()); if (!userToUnassign) { - throw new Error(logger.error("You are not assigned to this task", { issueNumber, user: sender.login })?.logMessage.raw as string); + throw logger.error("You are not assigned to this task", { issueNumber, user: sender.login }); } // close PR diff --git a/src/plugin.ts b/src/plugin.ts index e027d4f..8369351 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -43,12 +43,10 @@ export async function startStopTask(inputs: PluginInputs, env: Env) { let errorMessage; if (err instanceof LogReturn) { errorMessage = err; - } else if (err instanceof Error) { - errorMessage = context.logger.error(err.message, { error: err }); + await addCommentToIssue(context, `${errorMessage?.logMessage.diff}\n`); } else { - errorMessage = context.logger.error("An error occurred", { err }); + context.logger.error("An error occurred", { err }); } - await addCommentToIssue(context, `${errorMessage?.logMessage.diff}\n`); } } diff --git a/src/utils/issue.ts b/src/utils/issue.ts index 058e90e..30e58d3 100644 --- a/src/utils/issue.ts +++ b/src/utils/issue.ts @@ -141,9 +141,7 @@ async function confirmMultiAssignment(context: Context, issueNumber: number, use }); if (!assignees?.length) { - throw new Error( - logger.error("We detected that this task was not assigned to anyone. Please report this to the maintainers.", { issueNumber, usernames }).logMessage.raw - ); + throw logger.error("We detected that this task was not assigned to anyone. Please report this to the maintainers.", { issueNumber, usernames }); } if (isPrivate && assignees?.length <= 1) { diff --git a/wrangler.toml b/wrangler.toml index d67116d..0768f01 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -4,3 +4,6 @@ compatibility_date = "2024-05-23" node_compat = true [env.dev] [env.prod] + +[observability] +enabled = true \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 67e811d..608b771 100644 --- a/yarn.lock +++ b/yarn.lock @@ -443,50 +443,60 @@ __metadata: languageName: node linkType: hard -"@cloudflare/kv-asset-handler@npm:0.3.2": - version: 0.3.2 - resolution: "@cloudflare/kv-asset-handler@npm:0.3.2" +"@cloudflare/kv-asset-handler@npm:0.3.4": + version: 0.3.4 + resolution: "@cloudflare/kv-asset-handler@npm:0.3.4" dependencies: mime: "npm:^3.0.0" - checksum: 10c0/90e726d18e17335469d94425bae4ca40564fadd7f7888e7b28f6b44b33f86bc0a7044f70ee7b1b8add75fb05b20c38f33f83bb913fdae2f1985cdf55da810896 + checksum: 10c0/5895d28a4489f470acd217485e3ffbbe2e4a63b0772bb2925ee0f646b6ccce1fd224e07c4610cf514b5e7d0100053c81745a21c0af9a89a98fe16990a4e38ce7 languageName: node linkType: hard -"@cloudflare/workerd-darwin-64@npm:1.20240610.1": - version: 1.20240610.1 - resolution: "@cloudflare/workerd-darwin-64@npm:1.20240610.1" +"@cloudflare/workerd-darwin-64@npm:1.20240925.0": + version: 1.20240925.0 + resolution: "@cloudflare/workerd-darwin-64@npm:1.20240925.0" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@cloudflare/workerd-darwin-arm64@npm:1.20240610.1": - version: 1.20240610.1 - resolution: "@cloudflare/workerd-darwin-arm64@npm:1.20240610.1" +"@cloudflare/workerd-darwin-arm64@npm:1.20240925.0": + version: 1.20240925.0 + resolution: "@cloudflare/workerd-darwin-arm64@npm:1.20240925.0" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@cloudflare/workerd-linux-64@npm:1.20240610.1": - version: 1.20240610.1 - resolution: "@cloudflare/workerd-linux-64@npm:1.20240610.1" +"@cloudflare/workerd-linux-64@npm:1.20240925.0": + version: 1.20240925.0 + resolution: "@cloudflare/workerd-linux-64@npm:1.20240925.0" conditions: os=linux & cpu=x64 languageName: node linkType: hard -"@cloudflare/workerd-linux-arm64@npm:1.20240610.1": - version: 1.20240610.1 - resolution: "@cloudflare/workerd-linux-arm64@npm:1.20240610.1" +"@cloudflare/workerd-linux-arm64@npm:1.20240925.0": + version: 1.20240925.0 + resolution: "@cloudflare/workerd-linux-arm64@npm:1.20240925.0" conditions: os=linux & cpu=arm64 languageName: node linkType: hard -"@cloudflare/workerd-windows-64@npm:1.20240610.1": - version: 1.20240610.1 - resolution: "@cloudflare/workerd-windows-64@npm:1.20240610.1" +"@cloudflare/workerd-windows-64@npm:1.20240925.0": + version: 1.20240925.0 + resolution: "@cloudflare/workerd-windows-64@npm:1.20240925.0" conditions: os=win32 & cpu=x64 languageName: node linkType: hard +"@cloudflare/workers-shared@npm:0.5.4": + version: 0.5.4 + resolution: "@cloudflare/workers-shared@npm:0.5.4" + dependencies: + mime: "npm:^3.0.0" + zod: "npm:^3.22.3" + checksum: 10c0/bc439b5ad8264804b8e9a9c39636cadd35d23947d0dfff7daf405e74230ec4716a245771b940bc96c9e10c9cb91d4a487767b44fefccc6caeaa6829fdb19f68c + languageName: node + linkType: hard + "@commitlint/cli@npm:19.3.0": version: 19.3.0 resolution: "@commitlint/cli@npm:19.3.0" @@ -2842,7 +2852,7 @@ __metadata: typebox-validators: "npm:^0.3.5" typescript: "npm:5.4.5" typescript-eslint: "npm:7.13.1" - wrangler: "npm:3.60.3" + wrangler: "npm:3.78.12" languageName: unknown linkType: soft @@ -3665,13 +3675,6 @@ __metadata: languageName: node linkType: hard -"consola@npm:^3.2.3": - version: 3.2.3 - resolution: "consola@npm:3.2.3" - checksum: 10c0/c606220524ec88a05bb1baf557e9e0e04a0c08a9c35d7a08652d99de195c4ddcb6572040a7df57a18ff38bbc13ce9880ad032d56630cef27bef72768ef0ac078 - languageName: node - linkType: hard - "conventional-changelog-angular@npm:^7.0.0": version: 7.0.0 resolution: "conventional-changelog-angular@npm:7.0.0" @@ -6952,9 +6955,9 @@ __metadata: languageName: node linkType: hard -"miniflare@npm:3.20240610.0": - version: 3.20240610.0 - resolution: "miniflare@npm:3.20240610.0" +"miniflare@npm:3.20240925.0": + version: 3.20240925.0 + resolution: "miniflare@npm:3.20240925.0" dependencies: "@cspotcode/source-map-support": "npm:0.8.1" acorn: "npm:^8.8.0" @@ -6963,14 +6966,14 @@ __metadata: exit-hook: "npm:^2.2.1" glob-to-regexp: "npm:^0.4.1" stoppable: "npm:^1.1.0" - undici: "npm:^5.28.2" - workerd: "npm:1.20240610.1" - ws: "npm:^8.11.0" + undici: "npm:^5.28.4" + workerd: "npm:1.20240925.0" + ws: "npm:^8.17.1" youch: "npm:^3.2.2" - zod: "npm:^3.20.6" + zod: "npm:^3.22.3" bin: miniflare: bootstrap.js - checksum: 10c0/e5d66abd78c31a9185cc2018ad30af5ae50c2e4dd9a8e4ba3ed145e1484067fb4377b63c1d31ae7b87be3a9225fc4324141d6afebbcbf81ee38fc40949e126b7 + checksum: 10c0/79586babe0d0172bb0e08631dac0af11963ed0c35c80268d13fdb2eae317e8f8dcc2a5d7c91d9b33f6b7f1c754a75253f399b1d81a27c15ad568c0b89ae2a2a3 languageName: node linkType: hard @@ -7186,13 +7189,6 @@ __metadata: languageName: node linkType: hard -"node-fetch-native@npm:^1.6.4": - version: 1.6.4 - resolution: "node-fetch-native@npm:1.6.4" - checksum: 10c0/78334dc6def5d1d95cfe87b33ac76c4833592c5eb84779ad2b0c23c689f9dd5d1cfc827035ada72d6b8b218f717798968c5a99aeff0a1a8bf06657e80592f9c3 - languageName: node - linkType: hard - "node-forge@npm:^1": version: 1.3.1 resolution: "node-forge@npm:1.3.1" @@ -7343,6 +7339,13 @@ __metadata: languageName: node linkType: hard +"ohash@npm:^1.1.4": + version: 1.1.4 + resolution: "ohash@npm:1.1.4" + checksum: 10c0/73c3bcab2891ee2155ed62bb4c2906f622bf2204a3c9f4616ada8a6a76276bb6b4b4180eaf273b7c7d6232793e4d79d486aab436ebfc0d06d92a997f07122864 + languageName: node + linkType: hard + "once@npm:^1.3.0, once@npm:^1.3.1, once@npm:^1.4.0": version: 1.4.0 resolution: "once@npm:1.4.0" @@ -7590,7 +7593,7 @@ __metadata: languageName: node linkType: hard -"path-to-regexp@npm:^6.2.0": +"path-to-regexp@npm:^6.2.0, path-to-regexp@npm:^6.3.0": version: 6.3.0 resolution: "path-to-regexp@npm:6.3.0" checksum: 10c0/73b67f4638b41cde56254e6354e46ae3a2ebc08279583f6af3d96fe4664fc75788f74ed0d18ca44fa4a98491b69434f9eee73b97bb5314bd1b5adb700f5c18d6 @@ -8322,7 +8325,7 @@ __metadata: languageName: node linkType: hard -"source-map@npm:0.6.1, source-map@npm:^0.6.0, source-map@npm:^0.6.1": +"source-map@npm:^0.6.0, source-map@npm:^0.6.1": version: 0.6.1 resolution: "source-map@npm:0.6.1" checksum: 10c0/ab55398007c5e5532957cb0beee2368529618ac0ab372d789806f5718123cc4367d57de3904b4e6a4170eb5a0b0f41373066d02ca0735a0c4d75c7d328d3e011 @@ -8989,7 +8992,7 @@ __metadata: languageName: node linkType: hard -"ufo@npm:^1.5.3": +"ufo@npm:^1.5.4": version: 1.5.4 resolution: "ufo@npm:1.5.4" checksum: 10c0/b5dc4dc435c49c9ef8890f1b280a19ee4d0954d1d6f9ab66ce62ce64dd04c7be476781531f952a07c678d51638d02ad4b98e16237be29149295b0f7c09cda765 @@ -9022,7 +9025,7 @@ __metadata: languageName: node linkType: hard -"undici@npm:^5.28.2": +"undici@npm:^5.28.4": version: 5.28.4 resolution: "undici@npm:5.28.4" dependencies: @@ -9031,17 +9034,15 @@ __metadata: languageName: node linkType: hard -"unenv@npm:unenv-nightly@1.10.0-1717606461.a117952": - version: 1.10.0-1717606461.a117952 - resolution: "unenv-nightly@npm:1.10.0-1717606461.a117952" +"unenv@npm:unenv-nightly@2.0.0-20240919-125358-9a64854": + version: 2.0.0-20240919-125358-9a64854 + resolution: "unenv-nightly@npm:2.0.0-20240919-125358-9a64854" dependencies: - consola: "npm:^3.2.3" defu: "npm:^6.1.4" - mime: "npm:^3.0.0" - node-fetch-native: "npm:^1.6.4" + ohash: "npm:^1.1.4" pathe: "npm:^1.1.2" - ufo: "npm:^1.5.3" - checksum: 10c0/69c72d43a2b04358398e82ffd2e22f604ff37a737f5cd77d8a56c8f445de84af04b151f64c6467692a18308d6e50bab67b183f9dd20f5c58ab482e32df0189ba + ufo: "npm:^1.5.4" + checksum: 10c0/1f4bae2d616c75b219d35564e7e2de263de5dd16be32e8ee4ed503c388fc8dce5b28511a6f3db48b4bb3d376be0e920d82f8a628a18aad4ea9233b12db623771 languageName: node linkType: hard @@ -9285,15 +9286,15 @@ __metadata: languageName: node linkType: hard -"workerd@npm:1.20240610.1": - version: 1.20240610.1 - resolution: "workerd@npm:1.20240610.1" +"workerd@npm:1.20240925.0": + version: 1.20240925.0 + resolution: "workerd@npm:1.20240925.0" dependencies: - "@cloudflare/workerd-darwin-64": "npm:1.20240610.1" - "@cloudflare/workerd-darwin-arm64": "npm:1.20240610.1" - "@cloudflare/workerd-linux-64": "npm:1.20240610.1" - "@cloudflare/workerd-linux-arm64": "npm:1.20240610.1" - "@cloudflare/workerd-windows-64": "npm:1.20240610.1" + "@cloudflare/workerd-darwin-64": "npm:1.20240925.0" + "@cloudflare/workerd-darwin-arm64": "npm:1.20240925.0" + "@cloudflare/workerd-linux-64": "npm:1.20240925.0" + "@cloudflare/workerd-linux-arm64": "npm:1.20240925.0" + "@cloudflare/workerd-windows-64": "npm:1.20240925.0" dependenciesMeta: "@cloudflare/workerd-darwin-64": optional: true @@ -9307,32 +9308,34 @@ __metadata: optional: true bin: workerd: bin/workerd - checksum: 10c0/f9404b903b29b8c10b15772142f40972787ba22d1108233a481969b065a62af64a0d331e2863d5b36d376ab939ddce4fa5448c4c1b5c2236bcf0c4aeff8cdb9c + checksum: 10c0/24699f30a4cd3a2b6183e52bfb8d634610824e9f10f8ab991c0915d34fd015d04a00b3acd8d9f652f34c1e78f81079f1c591ee02881dd2b7b264c6b526101710 languageName: node linkType: hard -"wrangler@npm:3.60.3": - version: 3.60.3 - resolution: "wrangler@npm:3.60.3" +"wrangler@npm:3.78.12": + version: 3.78.12 + resolution: "wrangler@npm:3.78.12" dependencies: - "@cloudflare/kv-asset-handler": "npm:0.3.2" + "@cloudflare/kv-asset-handler": "npm:0.3.4" + "@cloudflare/workers-shared": "npm:0.5.4" "@esbuild-plugins/node-globals-polyfill": "npm:^0.2.3" "@esbuild-plugins/node-modules-polyfill": "npm:^0.2.2" blake3-wasm: "npm:^2.1.5" chokidar: "npm:^3.5.3" esbuild: "npm:0.17.19" fsevents: "npm:~2.3.2" - miniflare: "npm:3.20240610.0" + miniflare: "npm:3.20240925.0" nanoid: "npm:^3.3.3" - path-to-regexp: "npm:^6.2.0" + path-to-regexp: "npm:^6.3.0" resolve: "npm:^1.22.8" resolve.exports: "npm:^2.0.2" selfsigned: "npm:^2.0.1" - source-map: "npm:0.6.1" - unenv: "npm:unenv-nightly@1.10.0-1717606461.a117952" + source-map: "npm:^0.6.1" + unenv: "npm:unenv-nightly@2.0.0-20240919-125358-9a64854" + workerd: "npm:1.20240925.0" xxhash-wasm: "npm:^1.0.1" peerDependencies: - "@cloudflare/workers-types": ^4.20240605.0 + "@cloudflare/workers-types": ^4.20240925.0 dependenciesMeta: fsevents: optional: true @@ -9342,7 +9345,7 @@ __metadata: bin: wrangler: bin/wrangler.js wrangler2: bin/wrangler.js - checksum: 10c0/a28468e00707b222d47ed1cf82c0206939f22fe3023c4fca90e0244a18d8c9e943c9578641cc1bc5831d90a9f17ad9c57f1ed19b806654f668459bd82ab8fdc6 + checksum: 10c0/3999ae518d43cea6c00f2be806f934e20e79460a8ba01629250e85a48c0c281399be5782f0bdc94aa245295cb464e346f59edd601fee3f924e03acccbb96ffe9 languageName: node linkType: hard @@ -9407,7 +9410,7 @@ __metadata: languageName: node linkType: hard -"ws@npm:^8.11.0, ws@npm:^8.14.2": +"ws@npm:^8.14.2, ws@npm:^8.17.1": version: 8.18.0 resolution: "ws@npm:8.18.0" peerDependencies: @@ -9545,7 +9548,7 @@ __metadata: languageName: node linkType: hard -"zod@npm:^3.20.6, zod@npm:^3.22.4": +"zod@npm:^3.22.3, zod@npm:^3.22.4": version: 3.23.8 resolution: "zod@npm:3.23.8" checksum: 10c0/8f14c87d6b1b53c944c25ce7a28616896319d95bc46a9660fe441adc0ed0a81253b02b5abdaeffedbeb23bdd25a0bf1c29d2c12dd919aef6447652dd295e3e69 From a48f8a775113f32ce9e52f6c7d1cd14b6081525e Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Mon, 30 Sep 2024 12:52:44 +0900 Subject: [PATCH 2/4] chore: fix wrangler version --- .github/workflows/worker-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 98c33eb..51b341d 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -35,7 +35,7 @@ jobs: id: wrangler_deploy uses: cloudflare/wrangler-action@v3 with: - wranglerVersion: "3.78" + wranglerVersion: "3.78.12" apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} secrets: | From 3ece0fde53611d04e86587f82d6ce519bf7e8964 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 1 Oct 2024 02:10:38 +0900 Subject: [PATCH 3/4] chore: fixed tests --- tests/main.test.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/main.test.ts b/tests/main.test.ts index dec87fe..41e7e94 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -141,7 +141,7 @@ describe("User start/stop", () => { context.adapters = createAdapters(getSupabase(), context); - await expect(userStartStop(context)).rejects.toThrow("You are not assigned to this task"); + await expect(userStartStop(context)).rejects.toMatchObject({ logMessage: { raw: "You are not assigned to this task" } }); }); test("User can't stop an issue without assignees", async () => { @@ -151,7 +151,7 @@ describe("User start/stop", () => { const context = createContext(issue, sender, "/stop") as Context<"issue_comment.created">; context.adapters = createAdapters(getSupabase(), context as unknown as Context); - await expect(userStartStop(context)).rejects.toThrow("You are not assigned to this task"); + await expect(userStartStop(context)).rejects.toMatchObject({ logMessage: { raw: "You are not assigned to this task" } }); }); test("User can't start an issue that's already assigned", async () => { @@ -162,7 +162,9 @@ describe("User start/stop", () => { context.adapters = createAdapters(getSupabase(), context); - await expect(userStartStop(context)).rejects.toThrow("This issue is already assigned. Please choose another unassigned task."); + await expect(userStartStop(context)).rejects.toMatchObject({ + logMessage: { raw: "This issue is already assigned. Please choose another unassigned task." }, + }); }); test("User can't start an issue without a price label", async () => { @@ -173,7 +175,7 @@ describe("User start/stop", () => { context.adapters = createAdapters(getSupabase(), context); - await expect(userStartStop(context)).rejects.toThrow("No price label is set to calculate the duration"); + await expect(userStartStop(context)).rejects.toMatchObject({ logMessage: { raw: "No price label is set to calculate the duration" } }); }); test("User can't start an issue without a wallet address", async () => { @@ -194,7 +196,7 @@ describe("User start/stop", () => { context.adapters = createAdapters(getSupabase(), context as unknown as Context); - await expect(userStartStop(context)).rejects.toThrow("This issue is closed, please choose another."); + await expect(userStartStop(context)).rejects.toMatchObject({ logMessage: { raw: "This issue is closed, please choose another." } }); }); test("User can't start an issue that's a parent issue", async () => { @@ -205,7 +207,7 @@ describe("User start/stop", () => { context.adapters = createAdapters(getSupabase(), context); - await expect(userStartStop(context)).rejects.toThrow("Skipping '/start' since the issue is a parent issue"); + await expect(userStartStop(context)).rejects.toMatchObject({ logMessage: { raw: "Skipping '/start' since the issue is a parent issue" } }); }); test("should set maxLimits to 6 if the user is a member", async () => { @@ -218,7 +220,9 @@ describe("User start/stop", () => { const context = createContext(issue, sender) as unknown as Context; context.adapters = createAdapters(getSupabase(), context as unknown as Context); - await expect(userStartStop(context)).rejects.toThrow("You have reached your max task limit. Please close out some tasks before assigning new ones."); + await expect(userStartStop(context)).rejects.toMatchObject({ + logMessage: { raw: "You have reached your max task limit. Please close out some tasks before assigning new ones." }, + }); expect(memberLimit).toEqual(6); }); @@ -230,7 +234,9 @@ describe("User start/stop", () => { const context = createContext(issue, sender, "/start") as Context<"issue_comment.created">; context.adapters = createAdapters(getSupabase(), context); - await expect(userStartStop(context)).rejects.toThrow("user2 you were previously unassigned from this task. You cannot be reassigned."); + await expect(userStartStop(context)).rejects.toMatchObject({ + logMessage: { raw: "user2 you were previously unassigned from this task. You cannot be reassigned." }, + }); }); test("Should throw if no BOT_USER_ID is set", async () => { From be8146905bb4192898430c7941345a750e018ee3 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 2 Oct 2024 12:20:53 +0900 Subject: [PATCH 4/4] chore: fixed import --- src/utils/issue.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/issue.ts b/src/utils/issue.ts index f1859a6..65a094e 100644 --- a/src/utils/issue.ts +++ b/src/utils/issue.ts @@ -1,4 +1,4 @@ -import type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types"; +import { RestEndpointMethodTypes } from "@octokit/rest"; import ms from "ms"; import { Context } from "../types/context"; import { GitHubIssueSearch, Review } from "../types/payload";