Skip to content

Commit 412e9f2

Browse files
authored
test(backend): enable typecheck by workflow (#13526)
1 parent 7ead98c commit 412e9f2

File tree

7 files changed

+37
-10
lines changed

7 files changed

+37
-10
lines changed

packages/backend/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"watch": "node watch.mjs",
2020
"restart": "pnpm build && pnpm start",
2121
"dev": "nodemon -w src -e ts,js,mjs,cjs,json --exec \"cross-env NODE_ENV=development pnpm run restart\"",
22-
"typecheck": "tsc --noEmit",
22+
"typecheck": "tsc --noEmit && tsc -p test --noEmit",
2323
"eslint": "eslint --quiet \"src/**/*.ts\"",
2424
"lint": "pnpm typecheck && pnpm eslint",
2525
"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",

packages/backend/test/e2e/note.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ describe('Note', () => {
472472
priority: 0,
473473
value: true,
474474
},
475-
},
475+
} as any,
476476
}, alice);
477477

478478
assert.strictEqual(res.status, 200);
@@ -784,7 +784,7 @@ describe('Note', () => {
784784
priority: 1,
785785
value: 0,
786786
},
787-
},
787+
} as any,
788788
}, alice);
789789

790790
assert.strictEqual(res.status, 200);
@@ -838,7 +838,7 @@ describe('Note', () => {
838838
priority: 1,
839839
value: 0,
840840
},
841-
},
841+
} as any,
842842
}, alice);
843843

844844
assert.strictEqual(res.status, 200);
@@ -894,7 +894,7 @@ describe('Note', () => {
894894
priority: 1,
895895
value: 1,
896896
},
897-
},
897+
} as any,
898898
}, alice);
899899

900900
assert.strictEqual(res.status, 200);

packages/backend/test/e2e/timelines.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -890,17 +890,35 @@ describe('Timelines', () => {
890890

891891
const list = await api('users/lists/create', { name: 'list' }, alice).then(res => res.body);
892892
await api('users/lists/push', { listId: list.id, userId: bob.id }, alice);
893+
await api('users/lists/update-membership', { listId: list.id, userId: bob.id, withReplies: false }, alice);
893894
await sleep(1000);
894895
const aliceNote = await post(alice, { text: 'hi' });
895896
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
896897

897898
await waitForPushToTl();
898899

899-
const res = await api('notes/user-list-timeline', { listId: list.id, withReplies: false }, alice);
900+
const res = await api('notes/user-list-timeline', { listId: list.id }, alice);
900901

901902
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
902903
});
903904

905+
test.concurrent('withReplies: false でリスインしているフォローしていないユーザーの他人への返信が含まれない', async () => {
906+
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
907+
908+
const list = await api('users/lists/create', { name: 'list' }, alice).then(res => res.body);
909+
await api('users/lists/push', { listId: list.id, userId: bob.id }, alice);
910+
await api('users/lists/update-membership', { listId: list.id, userId: bob.id, withReplies: false }, alice);
911+
await sleep(1000);
912+
const carolNote = await post(carol, { text: 'hi' });
913+
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
914+
915+
await waitForPushToTl();
916+
917+
const res = await api('notes/user-list-timeline', { listId: list.id }, alice);
918+
919+
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
920+
});
921+
904922
test.concurrent('withReplies: true でリスインしているフォローしていないユーザーの他人への返信が含まれる', async () => {
905923
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
906924

packages/backend/test/global.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* SPDX-FileCopyrightText: syuilo and misskey-project
3+
* SPDX-License-Identifier: AGPL-3.0-only
4+
*/
5+
6+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7+
type FIXME = any;

packages/backend/test/prelude/get-api-validator.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*/
55

66
import Ajv from 'ajv';
7-
import { Schema } from '@/misc/schema';
7+
import { Schema } from '@/misc/json-schema.js';
88

99
export const getValidator = (paramDef: Schema) => {
10-
const ajv = new Ajv({
10+
const ajv = new Ajv.default({
1111
useDefaults: true,
1212
});
1313
ajv.addFormat('misskey:id', /^[a-zA-Z0-9]+$/);

packages/backend/test/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"noImplicitAny": true,
66
"noImplicitReturns": true,
77
"noUnusedParameters": false,
8-
"noUnusedLocals": true,
8+
"noUnusedLocals": false,
99
"noFallthroughCasesInSwitch": true,
1010
"declaration": false,
1111
"sourceMap": true,
@@ -18,6 +18,7 @@
1818
"strict": true,
1919
"strictNullChecks": true,
2020
"strictPropertyInitialization": false,
21+
"skipLibCheck": true,
2122
"experimentalDecorators": true,
2223
"emitDecoratorMetadata": true,
2324
"resolveJsonModule": true,

packages/backend/test/unit/RelayService.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ describe('RelayService', () => {
9090

9191
expect(queueService.deliver).toHaveBeenCalled();
9292
expect(queueService.deliver.mock.lastCall![1]?.type).toBe('Undo');
93-
expect(queueService.deliver.mock.lastCall![1]?.object.type).toBe('Follow');
93+
expect(typeof queueService.deliver.mock.lastCall![1]?.object).toBe('object');
94+
expect((queueService.deliver.mock.lastCall![1]?.object as any).type).toBe('Follow');
9495
expect(queueService.deliver.mock.lastCall![2]).toBe('https://example.com');
9596
//expect(queueService.deliver.mock.lastCall![0].username).toBe('relay.actor');
9697

0 commit comments

Comments
 (0)