2023-07-27 07:31:52 +02:00
|
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
2021-08-17 14:48:59 +02:00
|
|
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
|
|
|
|
|
|
import * as assert from 'assert';
|
2023-03-03 03:13:12 +01:00
|
|
|
|
import { signup, api, post, startServer } from '../utils.js';
|
|
|
|
|
import type { INestApplicationContext } from '@nestjs/common';
|
2023-06-25 01:34:18 +02:00
|
|
|
|
import type * as misskey from 'misskey-js';
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
|
|
|
|
describe('Block', () => {
|
2023-03-12 12:57:01 +01:00
|
|
|
|
let app: INestApplicationContext;
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
|
|
|
|
// alice blocks bob
|
2023-06-25 01:34:18 +02:00
|
|
|
|
let alice: misskey.entities.MeSignup;
|
|
|
|
|
let bob: misskey.entities.MeSignup;
|
|
|
|
|
let carol: misskey.entities.MeSignup;
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
2022-09-17 20:27:08 +02:00
|
|
|
|
beforeAll(async () => {
|
2023-03-12 12:57:01 +01:00
|
|
|
|
app = await startServer();
|
2021-08-17 14:48:59 +02:00
|
|
|
|
alice = await signup({ username: 'alice' });
|
|
|
|
|
bob = await signup({ username: 'bob' });
|
|
|
|
|
carol = await signup({ username: 'carol' });
|
2023-03-03 03:13:12 +01:00
|
|
|
|
}, 1000 * 60 * 2);
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
2022-09-17 20:27:08 +02:00
|
|
|
|
afterAll(async () => {
|
2023-03-12 12:57:01 +01:00
|
|
|
|
await app.close();
|
2021-08-17 14:48:59 +02:00
|
|
|
|
});
|
|
|
|
|
|
2023-02-02 10:18:25 +01:00
|
|
|
|
test('Block作成', async () => {
|
2023-03-03 03:13:12 +01:00
|
|
|
|
const res = await api('/blocking/create', {
|
2022-05-21 15:21:41 +02:00
|
|
|
|
userId: bob.id,
|
2021-08-17 14:48:59 +02:00
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
|
|
assert.strictEqual(res.status, 200);
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
2023-02-02 10:18:25 +01:00
|
|
|
|
test('ブロックされているユーザーをフォローできない', async () => {
|
2023-03-03 03:13:12 +01:00
|
|
|
|
const res = await api('/following/create', { userId: alice.id }, bob);
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
|
|
|
|
assert.strictEqual(res.status, 400);
|
|
|
|
|
assert.strictEqual(res.body.error.id, 'c4ab57cc-4e41-45e9-bfd9-584f61e35ce0');
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
2023-02-02 10:18:25 +01:00
|
|
|
|
test('ブロックされているユーザーにリアクションできない', async () => {
|
2021-08-17 14:48:59 +02:00
|
|
|
|
const note = await post(alice, { text: 'hello' });
|
|
|
|
|
|
2023-03-03 03:13:12 +01:00
|
|
|
|
const res = await api('/notes/reactions/create', { noteId: note.id, reaction: '👍' }, bob);
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
|
|
|
|
assert.strictEqual(res.status, 400);
|
|
|
|
|
assert.strictEqual(res.body.error.id, '20ef5475-9f38-4e4c-bd33-de6d979498ec');
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
2023-02-02 10:18:25 +01:00
|
|
|
|
test('ブロックされているユーザーに返信できない', async () => {
|
2021-08-17 14:48:59 +02:00
|
|
|
|
const note = await post(alice, { text: 'hello' });
|
|
|
|
|
|
2023-03-03 03:13:12 +01:00
|
|
|
|
const res = await api('/notes/create', { replyId: note.id, text: 'yo' }, bob);
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
|
|
|
|
assert.strictEqual(res.status, 400);
|
|
|
|
|
assert.strictEqual(res.body.error.id, 'b390d7e1-8a5e-46ed-b625-06271cafd3d3');
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
2023-02-02 10:18:25 +01:00
|
|
|
|
test('ブロックされているユーザーのノートをRenoteできない', async () => {
|
2021-08-17 14:48:59 +02:00
|
|
|
|
const note = await post(alice, { text: 'hello' });
|
|
|
|
|
|
2023-03-03 03:13:12 +01:00
|
|
|
|
const res = await api('/notes/create', { renoteId: note.id, text: 'yo' }, bob);
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
|
|
|
|
assert.strictEqual(res.status, 400);
|
|
|
|
|
assert.strictEqual(res.body.error.id, 'b390d7e1-8a5e-46ed-b625-06271cafd3d3');
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
|
|
|
|
// TODO: ユーザーリストに入れられないテスト
|
|
|
|
|
|
|
|
|
|
// TODO: ユーザーリストから除外されるテスト
|
|
|
|
|
|
2023-02-02 10:18:25 +01:00
|
|
|
|
test('タイムライン(LTL)にブロックされているユーザーの投稿が含まれない', async () => {
|
2023-03-08 00:56:09 +01:00
|
|
|
|
const aliceNote = await post(alice, { text: 'hi' });
|
|
|
|
|
const bobNote = await post(bob, { text: 'hi' });
|
|
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
2023-03-03 03:13:12 +01:00
|
|
|
|
const res = await api('/notes/local-timeline', {}, bob);
|
2021-08-17 14:48:59 +02:00
|
|
|
|
|
|
|
|
|
assert.strictEqual(res.status, 200);
|
|
|
|
|
assert.strictEqual(Array.isArray(res.body), true);
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), false);
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true);
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2021-08-17 14:48:59 +02:00
|
|
|
|
});
|