mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-13 09:10:47 +01:00
test(backend): enable typecheck by workflow (#13526)
This commit is contained in:
parent
7ead98cbe5
commit
412e9f284d
7 changed files with 37 additions and 10 deletions
|
@ -19,7 +19,7 @@
|
||||||
"watch": "node watch.mjs",
|
"watch": "node watch.mjs",
|
||||||
"restart": "pnpm build && pnpm start",
|
"restart": "pnpm build && pnpm start",
|
||||||
"dev": "nodemon -w src -e ts,js,mjs,cjs,json --exec \"cross-env NODE_ENV=development pnpm run restart\"",
|
"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\"",
|
"eslint": "eslint --quiet \"src/**/*.ts\"",
|
||||||
"lint": "pnpm typecheck && pnpm eslint",
|
"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",
|
"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",
|
||||||
|
|
|
@ -472,7 +472,7 @@ describe('Note', () => {
|
||||||
priority: 0,
|
priority: 0,
|
||||||
value: true,
|
value: true,
|
||||||
},
|
},
|
||||||
},
|
} as any,
|
||||||
}, alice);
|
}, alice);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
@ -784,7 +784,7 @@ describe('Note', () => {
|
||||||
priority: 1,
|
priority: 1,
|
||||||
value: 0,
|
value: 0,
|
||||||
},
|
},
|
||||||
},
|
} as any,
|
||||||
}, alice);
|
}, alice);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
@ -838,7 +838,7 @@ describe('Note', () => {
|
||||||
priority: 1,
|
priority: 1,
|
||||||
value: 0,
|
value: 0,
|
||||||
},
|
},
|
||||||
},
|
} as any,
|
||||||
}, alice);
|
}, alice);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
@ -894,7 +894,7 @@ describe('Note', () => {
|
||||||
priority: 1,
|
priority: 1,
|
||||||
value: 1,
|
value: 1,
|
||||||
},
|
},
|
||||||
},
|
} as any,
|
||||||
}, alice);
|
}, alice);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
|
|
@ -890,17 +890,35 @@ describe('Timelines', () => {
|
||||||
|
|
||||||
const list = await api('users/lists/create', { name: 'list' }, alice).then(res => res.body);
|
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/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);
|
await sleep(1000);
|
||||||
const aliceNote = await post(alice, { text: 'hi' });
|
const aliceNote = await post(alice, { text: 'hi' });
|
||||||
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
|
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
|
||||||
|
|
||||||
await waitForPushToTl();
|
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);
|
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 () => {
|
test.concurrent('withReplies: true でリスインしているフォローしていないユーザーの他人への返信が含まれる', async () => {
|
||||||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||||
|
|
||||||
|
|
7
packages/backend/test/global.d.ts
vendored
Normal file
7
packages/backend/test/global.d.ts
vendored
Normal file
|
@ -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;
|
|
@ -4,10 +4,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Ajv from 'ajv';
|
import Ajv from 'ajv';
|
||||||
import { Schema } from '@/misc/schema';
|
import { Schema } from '@/misc/json-schema.js';
|
||||||
|
|
||||||
export const getValidator = (paramDef: Schema) => {
|
export const getValidator = (paramDef: Schema) => {
|
||||||
const ajv = new Ajv({
|
const ajv = new Ajv.default({
|
||||||
useDefaults: true,
|
useDefaults: true,
|
||||||
});
|
});
|
||||||
ajv.addFormat('misskey:id', /^[a-zA-Z0-9]+$/);
|
ajv.addFormat('misskey:id', /^[a-zA-Z0-9]+$/);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"noImplicitReturns": true,
|
"noImplicitReturns": true,
|
||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": false,
|
||||||
"noFallthroughCasesInSwitch": true,
|
"noFallthroughCasesInSwitch": true,
|
||||||
"declaration": false,
|
"declaration": false,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"strictPropertyInitialization": false,
|
"strictPropertyInitialization": false,
|
||||||
|
"skipLibCheck": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
|
|
|
@ -90,7 +90,8 @@ describe('RelayService', () => {
|
||||||
|
|
||||||
expect(queueService.deliver).toHaveBeenCalled();
|
expect(queueService.deliver).toHaveBeenCalled();
|
||||||
expect(queueService.deliver.mock.lastCall![1]?.type).toBe('Undo');
|
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![2]).toBe('https://example.com');
|
||||||
//expect(queueService.deliver.mock.lastCall![0].username).toBe('relay.actor');
|
//expect(queueService.deliver.mock.lastCall![0].username).toBe('relay.actor');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue