summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzyoshoka <107108195+zyoshoka@users.noreply.github.com>2024-03-07 09:51:57 +0900
committerGitHub <noreply@github.com>2024-03-07 09:51:57 +0900
commit412e9f284dce4167304a57c905f3cd8e9438b128 (patch)
tree6357365b4a17d3c2be111a3cf14e1debea8d8993
parentenhance(frontend): リアクションの総数を表示するように (#13532) (diff)
downloadmisskey-412e9f284dce4167304a57c905f3cd8e9438b128.tar.gz
misskey-412e9f284dce4167304a57c905f3cd8e9438b128.tar.bz2
misskey-412e9f284dce4167304a57c905f3cd8e9438b128.zip
test(backend): enable typecheck by workflow (#13526)
-rw-r--r--packages/backend/package.json2
-rw-r--r--packages/backend/test/e2e/note.ts8
-rw-r--r--packages/backend/test/e2e/timelines.ts20
-rw-r--r--packages/backend/test/global.d.ts7
-rw-r--r--packages/backend/test/prelude/get-api-validator.ts4
-rw-r--r--packages/backend/test/tsconfig.json3
-rw-r--r--packages/backend/test/unit/RelayService.ts3
7 files changed, 37 insertions, 10 deletions
diff --git a/packages/backend/package.json b/packages/backend/package.json
index 8680610441..eaad96d5f6 100644
--- a/packages/backend/package.json
+++ b/packages/backend/package.json
@@ -19,7 +19,7 @@
"watch": "node watch.mjs",
"restart": "pnpm build && pnpm start",
"dev": "nodemon -w src -e ts,js,mjs,cjs,json --exec \"cross-env NODE_ENV=development pnpm run restart\"",
- "typecheck": "tsc --noEmit",
+ "typecheck": "tsc --noEmit && tsc -p test --noEmit",
"eslint": "eslint --quiet \"src/**/*.ts\"",
"lint": "pnpm typecheck && pnpm eslint",
"jest": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --config jest.config.unit.cjs",
diff --git a/packages/backend/test/e2e/note.ts b/packages/backend/test/e2e/note.ts
index 973bcbd750..11016f58ae 100644
--- a/packages/backend/test/e2e/note.ts
+++ b/packages/backend/test/e2e/note.ts
@@ -472,7 +472,7 @@ describe('Note', () => {
priority: 0,
value: true,
},
- },
+ } as any,
}, alice);
assert.strictEqual(res.status, 200);
@@ -784,7 +784,7 @@ describe('Note', () => {
priority: 1,
value: 0,
},
- },
+ } as any,
}, alice);
assert.strictEqual(res.status, 200);
@@ -838,7 +838,7 @@ describe('Note', () => {
priority: 1,
value: 0,
},
- },
+ } as any,
}, alice);
assert.strictEqual(res.status, 200);
@@ -894,7 +894,7 @@ describe('Note', () => {
priority: 1,
value: 1,
},
- },
+ } as any,
}, alice);
assert.strictEqual(res.status, 200);
diff --git a/packages/backend/test/e2e/timelines.ts b/packages/backend/test/e2e/timelines.ts
index d413703ede..5487292afc 100644
--- a/packages/backend/test/e2e/timelines.ts
+++ b/packages/backend/test/e2e/timelines.ts
@@ -890,17 +890,35 @@ describe('Timelines', () => {
const list = await api('users/lists/create', { name: 'list' }, alice).then(res => res.body);
await api('users/lists/push', { listId: list.id, userId: bob.id }, alice);
+ await api('users/lists/update-membership', { listId: list.id, userId: bob.id, withReplies: false }, alice);
await sleep(1000);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
await waitForPushToTl();
- const res = await api('notes/user-list-timeline', { listId: list.id, withReplies: false }, alice);
+ const res = await api('notes/user-list-timeline', { listId: list.id }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
+ test.concurrent('withReplies: false でリスインしているフォローしていないユーザーの他人への返信が含まれない', async () => {
+ const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
+
+ const list = await api('users/lists/create', { name: 'list' }, alice).then(res => res.body);
+ await api('users/lists/push', { listId: list.id, userId: bob.id }, alice);
+ await api('users/lists/update-membership', { listId: list.id, userId: bob.id, withReplies: false }, alice);
+ await sleep(1000);
+ const carolNote = await post(carol, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
test.concurrent('withReplies: true でリスインしているフォローしていないユーザーの他人への返信が含まれる', async () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
diff --git a/packages/backend/test/global.d.ts b/packages/backend/test/global.d.ts
new file mode 100644
index 0000000000..0363073356
--- /dev/null
+++ b/packages/backend/test/global.d.ts
@@ -0,0 +1,7 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+type FIXME = any;
diff --git a/packages/backend/test/prelude/get-api-validator.ts b/packages/backend/test/prelude/get-api-validator.ts
index b86a7a978d..7aa7a92702 100644
--- a/packages/backend/test/prelude/get-api-validator.ts
+++ b/packages/backend/test/prelude/get-api-validator.ts
@@ -4,10 +4,10 @@
*/
import Ajv from 'ajv';
-import { Schema } from '@/misc/schema';
+import { Schema } from '@/misc/json-schema.js';
export const getValidator = (paramDef: Schema) => {
- const ajv = new Ajv({
+ const ajv = new Ajv.default({
useDefaults: true,
});
ajv.addFormat('misskey:id', /^[a-zA-Z0-9]+$/);
diff --git a/packages/backend/test/tsconfig.json b/packages/backend/test/tsconfig.json
index 4597ff8780..2b562acda8 100644
--- a/packages/backend/test/tsconfig.json
+++ b/packages/backend/test/tsconfig.json
@@ -5,7 +5,7 @@
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedParameters": false,
- "noUnusedLocals": true,
+ "noUnusedLocals": false,
"noFallthroughCasesInSwitch": true,
"declaration": false,
"sourceMap": true,
@@ -18,6 +18,7 @@
"strict": true,
"strictNullChecks": true,
"strictPropertyInitialization": false,
+ "skipLibCheck": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"resolveJsonModule": true,
diff --git a/packages/backend/test/unit/RelayService.ts b/packages/backend/test/unit/RelayService.ts
index f2a67dba46..9676abf07b 100644
--- a/packages/backend/test/unit/RelayService.ts
+++ b/packages/backend/test/unit/RelayService.ts
@@ -90,7 +90,8 @@ describe('RelayService', () => {
expect(queueService.deliver).toHaveBeenCalled();
expect(queueService.deliver.mock.lastCall![1]?.type).toBe('Undo');
- expect(queueService.deliver.mock.lastCall![1]?.object.type).toBe('Follow');
+ expect(typeof queueService.deliver.mock.lastCall![1]?.object).toBe('object');
+ expect((queueService.deliver.mock.lastCall![1]?.object as any).type).toBe('Follow');
expect(queueService.deliver.mock.lastCall![2]).toBe('https://example.com');
//expect(queueService.deliver.mock.lastCall![0].username).toBe('relay.actor');