2023-07-27 07:31:52 +02:00
|
|
|
|
/*
|
2024-02-13 16:59:27 +01:00
|
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 07:31:52 +02:00
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
2023-05-19 13:53:20 +02:00
|
|
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
|
|
|
|
|
|
import * as assert from 'assert';
|
|
|
|
|
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
|
|
|
|
|
import {
|
2024-01-08 09:43:52 +01:00
|
|
|
|
api,
|
|
|
|
|
failedApiCall,
|
2023-05-19 13:53:20 +02:00
|
|
|
|
post,
|
|
|
|
|
role,
|
2024-01-08 09:43:52 +01:00
|
|
|
|
signup,
|
2023-05-19 13:53:20 +02:00
|
|
|
|
successfulApiCall,
|
|
|
|
|
testPaginationConsistency,
|
2024-01-08 09:43:52 +01:00
|
|
|
|
uploadFile,
|
|
|
|
|
userList,
|
2023-05-19 13:53:20 +02:00
|
|
|
|
} from '../utils.js';
|
|
|
|
|
import type * as misskey from 'misskey-js';
|
|
|
|
|
|
|
|
|
|
const compareBy = <T extends { id: string }>(selector: (s: T) => string = (s: T): string => s.id) => (a: T, b: T): number => {
|
|
|
|
|
return selector(a).localeCompare(selector(b));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
describe('アンテナ', () => {
|
|
|
|
|
// エンティティとしてのアンテナを主眼においたテストを記述する
|
|
|
|
|
// (Antennaを返すエンドポイント、Antennaエンティティを書き換えるエンドポイント、Antennaからノートを取得するエンドポイントをテストする)
|
|
|
|
|
|
2024-03-03 12:15:35 +01:00
|
|
|
|
type Antenna = misskey.entities.Antenna;
|
2024-01-03 05:41:28 +01:00
|
|
|
|
type User = misskey.entities.SignupResponse;
|
2023-05-19 13:53:20 +02:00
|
|
|
|
type Note = misskey.entities.Note;
|
|
|
|
|
|
|
|
|
|
// アンテナを作成できる最小のパラメタ
|
|
|
|
|
const defaultParam = {
|
|
|
|
|
caseSensitive: false,
|
|
|
|
|
excludeKeywords: [['']],
|
|
|
|
|
keywords: [['keyword']],
|
|
|
|
|
name: 'test',
|
|
|
|
|
src: 'all' as const,
|
|
|
|
|
userListId: null,
|
|
|
|
|
users: [''],
|
|
|
|
|
withFile: false,
|
|
|
|
|
withReplies: false,
|
2024-03-20 23:51:01 +01:00
|
|
|
|
excludeBots: false,
|
2023-05-19 13:53:20 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let root: User;
|
|
|
|
|
let alice: User;
|
|
|
|
|
let bob: User;
|
|
|
|
|
let carol: User;
|
|
|
|
|
|
|
|
|
|
let alicePost: Note;
|
|
|
|
|
let aliceList: misskey.entities.UserList;
|
|
|
|
|
let bobFile: misskey.entities.DriveFile;
|
|
|
|
|
let bobList: misskey.entities.UserList;
|
|
|
|
|
|
|
|
|
|
let userNotExplorable: User;
|
|
|
|
|
let userLocking: User;
|
|
|
|
|
let userSilenced: User;
|
|
|
|
|
let userSuspended: User;
|
|
|
|
|
let userDeletedBySelf: User;
|
|
|
|
|
let userDeletedByAdmin: User;
|
|
|
|
|
let userFollowingAlice: User;
|
|
|
|
|
let userFollowedByAlice: User;
|
|
|
|
|
let userBlockingAlice: User;
|
|
|
|
|
let userBlockedByAlice: User;
|
|
|
|
|
let userMutingAlice: User;
|
|
|
|
|
let userMutedByAlice: User;
|
|
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
|
root = await signup({ username: 'root' });
|
|
|
|
|
alice = await signup({ username: 'alice' });
|
|
|
|
|
alicePost = await post(alice, { text: 'test' });
|
|
|
|
|
aliceList = await userList(alice, {});
|
|
|
|
|
bob = await signup({ username: 'bob' });
|
|
|
|
|
aliceList = await userList(alice, {});
|
2024-03-03 12:15:35 +01:00
|
|
|
|
bobFile = (await uploadFile(bob)).body!;
|
2023-05-19 13:53:20 +02:00
|
|
|
|
bobList = await userList(bob);
|
|
|
|
|
carol = await signup({ username: 'carol' });
|
|
|
|
|
await api('users/lists/push', { listId: aliceList.id, userId: bob.id }, alice);
|
|
|
|
|
await api('users/lists/push', { listId: aliceList.id, userId: carol.id }, alice);
|
|
|
|
|
|
|
|
|
|
userNotExplorable = await signup({ username: 'userNotExplorable' });
|
|
|
|
|
await post(userNotExplorable, { text: 'test' });
|
|
|
|
|
await api('i/update', { isExplorable: false }, userNotExplorable);
|
|
|
|
|
userLocking = await signup({ username: 'userLocking' });
|
|
|
|
|
await post(userLocking, { text: 'test' });
|
|
|
|
|
await api('i/update', { isLocked: true }, userLocking);
|
|
|
|
|
userSilenced = await signup({ username: 'userSilenced' });
|
|
|
|
|
await post(userSilenced, { text: 'test' });
|
|
|
|
|
const roleSilenced = await role(root, {}, { canPublicNote: { priority: 0, useDefault: false, value: false } });
|
|
|
|
|
await api('admin/roles/assign', { userId: userSilenced.id, roleId: roleSilenced.id }, root);
|
|
|
|
|
userSuspended = await signup({ username: 'userSuspended' });
|
|
|
|
|
await post(userSuspended, { text: 'test' });
|
|
|
|
|
await successfulApiCall({ endpoint: 'i/update', parameters: { description: '#user_testuserSuspended' }, user: userSuspended });
|
|
|
|
|
await api('admin/suspend-user', { userId: userSuspended.id }, root);
|
|
|
|
|
userDeletedBySelf = await signup({ username: 'userDeletedBySelf', password: 'userDeletedBySelf' });
|
|
|
|
|
await post(userDeletedBySelf, { text: 'test' });
|
|
|
|
|
await api('i/delete-account', { password: 'userDeletedBySelf' }, userDeletedBySelf);
|
|
|
|
|
userDeletedByAdmin = await signup({ username: 'userDeletedByAdmin' });
|
|
|
|
|
await post(userDeletedByAdmin, { text: 'test' });
|
|
|
|
|
await api('admin/delete-account', { userId: userDeletedByAdmin.id }, root);
|
|
|
|
|
userFollowedByAlice = await signup({ username: 'userFollowedByAlice' });
|
|
|
|
|
await post(userFollowedByAlice, { text: 'test' });
|
|
|
|
|
await api('following/create', { userId: userFollowedByAlice.id }, alice);
|
|
|
|
|
userFollowingAlice = await signup({ username: 'userFollowingAlice' });
|
|
|
|
|
await post(userFollowingAlice, { text: 'test' });
|
|
|
|
|
await api('following/create', { userId: alice.id }, userFollowingAlice);
|
|
|
|
|
userBlockingAlice = await signup({ username: 'userBlockingAlice' });
|
|
|
|
|
await post(userBlockingAlice, { text: 'test' });
|
|
|
|
|
await api('blocking/create', { userId: alice.id }, userBlockingAlice);
|
|
|
|
|
userBlockedByAlice = await signup({ username: 'userBlockedByAlice' });
|
|
|
|
|
await post(userBlockedByAlice, { text: 'test' });
|
|
|
|
|
await api('blocking/create', { userId: userBlockedByAlice.id }, alice);
|
|
|
|
|
userMutingAlice = await signup({ username: 'userMutingAlice' });
|
|
|
|
|
await post(userMutingAlice, { text: 'test' });
|
|
|
|
|
await api('mute/create', { userId: alice.id }, userMutingAlice);
|
|
|
|
|
userMutedByAlice = await signup({ username: 'userMutedByAlice' });
|
|
|
|
|
await post(userMutedByAlice, { text: 'test' });
|
|
|
|
|
await api('mute/create', { userId: userMutedByAlice.id }, alice);
|
|
|
|
|
}, 1000 * 60 * 10);
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
// テスト間で影響し合わないように毎回全部消す。
|
|
|
|
|
for (const user of [alice, bob]) {
|
2024-03-03 12:15:35 +01:00
|
|
|
|
const list = await api('antennas/list', {}, user);
|
2023-05-19 13:53:20 +02:00
|
|
|
|
for (const antenna of list.body) {
|
2024-03-03 12:15:35 +01:00
|
|
|
|
await api('antennas/delete', { antennaId: antenna.id }, user);
|
2023-05-19 13:53:20 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//#region 作成(antennas/create)
|
|
|
|
|
|
|
|
|
|
test('が作成できること、キーが過不足なく入っていること。', async () => {
|
|
|
|
|
const response = await successfulApiCall({
|
|
|
|
|
endpoint: 'antennas/create',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: defaultParam,
|
2023-05-19 13:53:20 +02:00
|
|
|
|
user: alice,
|
|
|
|
|
});
|
|
|
|
|
assert.match(response.id, /[0-9a-z]{10}/);
|
2024-03-03 12:15:35 +01:00
|
|
|
|
const expected: Antenna = {
|
2023-05-19 13:53:20 +02:00
|
|
|
|
id: response.id,
|
|
|
|
|
caseSensitive: false,
|
|
|
|
|
createdAt: new Date(response.createdAt).toISOString(),
|
|
|
|
|
excludeKeywords: [['']],
|
|
|
|
|
hasUnreadNote: false,
|
|
|
|
|
isActive: true,
|
|
|
|
|
keywords: [['keyword']],
|
|
|
|
|
name: 'test',
|
|
|
|
|
src: 'all',
|
|
|
|
|
userListId: null,
|
|
|
|
|
users: [''],
|
|
|
|
|
withFile: false,
|
|
|
|
|
withReplies: false,
|
2024-03-20 23:51:01 +01:00
|
|
|
|
excludeBots: false,
|
2023-10-16 10:42:33 +02:00
|
|
|
|
localOnly: false,
|
2024-05-31 06:28:11 +02:00
|
|
|
|
notify: false,
|
2024-03-03 12:15:35 +01:00
|
|
|
|
};
|
2023-05-19 13:53:20 +02:00
|
|
|
|
assert.deepStrictEqual(response, expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('が上限いっぱいまで作成できること', async () => {
|
2024-06-18 05:18:04 +02:00
|
|
|
|
const response = await Promise.all([...Array(DEFAULT_POLICIES.antennaLimit)].map(() => successfulApiCall({
|
2023-05-19 13:53:20 +02:00
|
|
|
|
endpoint: 'antennas/create',
|
|
|
|
|
parameters: { ...defaultParam },
|
|
|
|
|
user: alice,
|
|
|
|
|
})));
|
|
|
|
|
|
|
|
|
|
const expected = await successfulApiCall({ endpoint: 'antennas/list', parameters: {}, user: alice });
|
|
|
|
|
assert.deepStrictEqual(
|
|
|
|
|
response.sort(compareBy(s => s.id)),
|
|
|
|
|
expected.sort(compareBy(s => s.id)));
|
|
|
|
|
|
|
|
|
|
failedApiCall({
|
|
|
|
|
endpoint: 'antennas/create',
|
|
|
|
|
parameters: { ...defaultParam },
|
|
|
|
|
user: alice,
|
|
|
|
|
}, {
|
|
|
|
|
status: 400,
|
|
|
|
|
code: 'TOO_MANY_ANTENNAS',
|
|
|
|
|
id: 'faf47050-e8b5-438c-913c-db2b1576fde4',
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('を作成するとき他人のリストを指定したらエラーになる', async () => {
|
|
|
|
|
failedApiCall({
|
|
|
|
|
endpoint: 'antennas/create',
|
|
|
|
|
parameters: { ...defaultParam, src: 'list', userListId: bobList.id },
|
|
|
|
|
user: alice,
|
|
|
|
|
}, {
|
|
|
|
|
status: 400,
|
|
|
|
|
code: 'NO_SUCH_USER_LIST',
|
|
|
|
|
id: '95063e93-a283-4b8b-9aa5-bcdb8df69a7f',
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const antennaParamPattern = [
|
2024-03-03 12:15:35 +01:00
|
|
|
|
{ parameters: () => ({ name: 'x'.repeat(100) }) },
|
|
|
|
|
{ parameters: () => ({ name: 'x' }) },
|
|
|
|
|
{ parameters: () => ({ src: 'home' as const }) },
|
|
|
|
|
{ parameters: () => ({ src: 'all' as const }) },
|
|
|
|
|
{ parameters: () => ({ src: 'users' as const }) },
|
|
|
|
|
{ parameters: () => ({ src: 'list' as const }) },
|
|
|
|
|
{ parameters: () => ({ userListId: null }) },
|
|
|
|
|
{ parameters: () => ({ src: 'list' as const, userListId: aliceList.id }) },
|
|
|
|
|
{ parameters: () => ({ keywords: [['x']] }) },
|
|
|
|
|
{ parameters: () => ({ keywords: [['a', 'b', 'c'], ['x'], ['y'], ['z']] }) },
|
|
|
|
|
{ parameters: () => ({ excludeKeywords: [['a', 'b', 'c'], ['x'], ['y'], ['z']] }) },
|
|
|
|
|
{ parameters: () => ({ users: [alice.username] }) },
|
|
|
|
|
{ parameters: () => ({ users: [alice.username, bob.username, carol.username] }) },
|
|
|
|
|
{ parameters: () => ({ caseSensitive: false }) },
|
|
|
|
|
{ parameters: () => ({ caseSensitive: true }) },
|
|
|
|
|
{ parameters: () => ({ withReplies: false }) },
|
|
|
|
|
{ parameters: () => ({ withReplies: true }) },
|
|
|
|
|
{ parameters: () => ({ withFile: false }) },
|
|
|
|
|
{ parameters: () => ({ withFile: true }) },
|
2023-05-19 13:53:20 +02:00
|
|
|
|
];
|
|
|
|
|
test.each(antennaParamPattern)('を作成できること($#)', async ({ parameters }) => {
|
|
|
|
|
const response = await successfulApiCall({
|
|
|
|
|
endpoint: 'antennas/create',
|
|
|
|
|
parameters: { ...defaultParam, ...parameters() },
|
|
|
|
|
user: alice,
|
|
|
|
|
});
|
|
|
|
|
const expected = { ...response, ...parameters() };
|
|
|
|
|
assert.deepStrictEqual(response, expected);
|
|
|
|
|
});
|
|
|
|
|
|
2024-09-15 08:13:46 +02:00
|
|
|
|
test('を作成する時キーワードが指定されていないとエラーになる', async () => {
|
|
|
|
|
await failedApiCall({
|
|
|
|
|
endpoint: 'antennas/create',
|
|
|
|
|
parameters: { ...defaultParam, keywords: [[]], excludeKeywords: [[]] },
|
|
|
|
|
user: alice
|
|
|
|
|
}, {
|
|
|
|
|
status: 400,
|
|
|
|
|
code: 'EMPTY_KEYWORD',
|
|
|
|
|
id: '53ee222e-1ddd-4f9a-92e5-9fb82ddb463a'
|
|
|
|
|
})
|
|
|
|
|
});
|
2023-05-19 13:53:20 +02:00
|
|
|
|
//#endregion
|
|
|
|
|
//#region 更新(antennas/update)
|
|
|
|
|
|
|
|
|
|
test.each(antennaParamPattern)('を変更できること($#)', async ({ parameters }) => {
|
|
|
|
|
const antenna = await successfulApiCall({ endpoint: 'antennas/create', parameters: defaultParam, user: alice });
|
|
|
|
|
const response = await successfulApiCall({
|
|
|
|
|
endpoint: 'antennas/update',
|
|
|
|
|
parameters: { antennaId: antenna.id, ...defaultParam, ...parameters() },
|
|
|
|
|
user: alice,
|
|
|
|
|
});
|
|
|
|
|
const expected = { ...response, ...parameters() };
|
|
|
|
|
assert.deepStrictEqual(response, expected);
|
|
|
|
|
});
|
|
|
|
|
test.todo('は他人のものは変更できない');
|
|
|
|
|
|
|
|
|
|
test('を変更するとき他人のリストを指定したらエラーになる', async () => {
|
|
|
|
|
const antenna = await successfulApiCall({ endpoint: 'antennas/create', parameters: defaultParam, user: alice });
|
|
|
|
|
failedApiCall({
|
|
|
|
|
endpoint: 'antennas/update',
|
|
|
|
|
parameters: { antennaId: antenna.id, ...defaultParam, src: 'list', userListId: bobList.id },
|
|
|
|
|
user: alice,
|
|
|
|
|
}, {
|
|
|
|
|
status: 400,
|
|
|
|
|
code: 'NO_SUCH_USER_LIST',
|
|
|
|
|
id: '1c6b35c9-943e-48c2-81e4-2844989407f7',
|
|
|
|
|
});
|
|
|
|
|
});
|
2024-09-15 08:13:46 +02:00
|
|
|
|
test('を変更する時キーワードが指定されていないとエラーになる', async () => {
|
|
|
|
|
const antenna = await successfulApiCall({ endpoint: 'antennas/create', parameters: defaultParam, user: alice });
|
|
|
|
|
await failedApiCall({
|
|
|
|
|
endpoint: 'antennas/update',
|
|
|
|
|
parameters: { ...defaultParam, antennaId: antenna.id, keywords: [[]], excludeKeywords: [[]] },
|
|
|
|
|
user: alice
|
|
|
|
|
}, {
|
|
|
|
|
status: 400,
|
|
|
|
|
code: 'EMPTY_KEYWORD',
|
|
|
|
|
id: '721aaff6-4e1b-4d88-8de6-877fae9f68c4'
|
|
|
|
|
})
|
|
|
|
|
});
|
2023-05-19 13:53:20 +02:00
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
//#region 表示(antennas/show)
|
|
|
|
|
|
|
|
|
|
test('をID指定で表示できること。', async () => {
|
|
|
|
|
const antenna = await successfulApiCall({ endpoint: 'antennas/create', parameters: defaultParam, user: alice });
|
|
|
|
|
const response = await successfulApiCall({
|
|
|
|
|
endpoint: 'antennas/show',
|
|
|
|
|
parameters: { antennaId: antenna.id },
|
|
|
|
|
user: alice,
|
|
|
|
|
});
|
|
|
|
|
const expected = { ...antenna };
|
|
|
|
|
assert.deepStrictEqual(response, expected);
|
|
|
|
|
});
|
|
|
|
|
test.todo('は他人のものをID指定で表示できない');
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
//#region 一覧(antennas/list)
|
|
|
|
|
|
|
|
|
|
test('をリスト形式で取得できること。', async () => {
|
|
|
|
|
const antenna = await successfulApiCall({ endpoint: 'antennas/create', parameters: defaultParam, user: alice });
|
|
|
|
|
await successfulApiCall({ endpoint: 'antennas/create', parameters: defaultParam, user: bob });
|
|
|
|
|
const response = await successfulApiCall({
|
|
|
|
|
endpoint: 'antennas/list',
|
|
|
|
|
parameters: {},
|
|
|
|
|
user: alice,
|
|
|
|
|
});
|
|
|
|
|
const expected = [{ ...antenna }];
|
|
|
|
|
assert.deepStrictEqual(response, expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
//#region 削除(antennas/delete)
|
|
|
|
|
|
|
|
|
|
test('を削除できること。', async () => {
|
|
|
|
|
const antenna = await successfulApiCall({ endpoint: 'antennas/create', parameters: defaultParam, user: alice });
|
|
|
|
|
const response = await successfulApiCall({
|
|
|
|
|
endpoint: 'antennas/delete',
|
|
|
|
|
parameters: { antennaId: antenna.id },
|
|
|
|
|
user: alice,
|
|
|
|
|
});
|
|
|
|
|
assert.deepStrictEqual(response, null);
|
|
|
|
|
const list = await successfulApiCall({ endpoint: 'antennas/list', parameters: {}, user: alice });
|
|
|
|
|
assert.deepStrictEqual(list, []);
|
|
|
|
|
});
|
|
|
|
|
test.todo('は他人のものを削除できない');
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
describe('のノート', () => {
|
|
|
|
|
//#region アンテナのノート取得(antennas/notes)
|
|
|
|
|
|
|
|
|
|
test('を取得できること。', async () => {
|
|
|
|
|
const keyword = 'キーワード';
|
|
|
|
|
await post(bob, { text: `test ${keyword} beforehand` });
|
|
|
|
|
const antenna = await successfulApiCall({
|
|
|
|
|
endpoint: 'antennas/create',
|
|
|
|
|
parameters: { ...defaultParam, keywords: [[keyword]] },
|
|
|
|
|
user: alice,
|
|
|
|
|
});
|
|
|
|
|
const note = await post(bob, { text: `test ${keyword}` });
|
|
|
|
|
const response = await successfulApiCall({
|
|
|
|
|
endpoint: 'antennas/notes',
|
|
|
|
|
parameters: { antennaId: antenna.id },
|
|
|
|
|
user: alice,
|
|
|
|
|
});
|
|
|
|
|
const expected = [note];
|
|
|
|
|
assert.deepStrictEqual(response, expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const keyword = 'キーワード';
|
|
|
|
|
test.each([
|
|
|
|
|
{
|
|
|
|
|
label: '全体から',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ src: 'all' }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(alice, { text: `${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(carol, { text: `test ${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// BUG e4144a1 以降home指定は壊れている(allと同じ)
|
|
|
|
|
label: 'ホーム指定はallと同じ',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ src: 'home' }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(alice, { text: `${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(carol, { text: `test ${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// https://github.com/misskey-dev/misskey/issues/9025
|
|
|
|
|
label: 'ただし、フォロワー限定投稿とDM投稿を含まない。フォロワーであっても。',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({}),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'public' }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'home' }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'followers' }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'specified', visibleUserIds: [alice.id] }) },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'ブロックしているユーザーのノートは含む',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({}),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(userBlockedByAlice, { text: `${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'ブロックされているユーザーのノートは含まない',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({}),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(userBlockingAlice, { text: `${keyword}` }) },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'ミュートしているユーザーのノートは含まない',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({}),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(userMutedByAlice, { text: `${keyword}` }) },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'ミュートされているユーザーのノートは含む',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({}),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(userMutingAlice, { text: `${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '「見つけやすくする」がOFFのユーザーのノートも含まれる',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({}),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(userNotExplorable, { text: `${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '鍵付きユーザーのノートも含まれる',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({}),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(userLocking, { text: `${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'サイレンスのノートも含まれる',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({}),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(userSilenced, { text: `${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '削除ユーザーのノートも含まれる',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({}),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(userDeletedBySelf, { text: `${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(userDeletedByAdmin, { text: `${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'ユーザー指定で',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ src: 'users', users: [`@${bob.username}`, `@${carol.username}`] }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(alice, { text: `test ${keyword}` }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(carol, { text: `test ${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'リスト指定で',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ src: 'list', userListId: aliceList.id }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(alice, { text: `test ${keyword}` }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(carol, { text: `test ${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'CWにもマッチする',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ keywords: [[keyword]] }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test', cw: `cw ${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'キーワード1つ',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ keywords: [[keyword]] }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(alice, { text: 'test' }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(carol, { text: 'test' }) },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'キーワード3つ(AND)',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ keywords: [['A', 'B', 'C']] }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test A' }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test A B' }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test B C' }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test A B C' }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test C B A A B C' }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'キーワード3つ(OR)',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ keywords: [['A'], ['B'], ['C']] }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test' }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test A' }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test A B' }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test B C' }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test B C A' }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test C B' }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'test C' }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '除外ワード3つ(AND)',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ excludeKeywords: [['A', 'B', 'C']] }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword} A` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword} A B` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword} B C` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword} B C A` }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword} C B` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword} C` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '除外ワード3つ(OR)',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ excludeKeywords: [['A'], ['B'], ['C']] }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword} A` }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword} A B` }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword} B C` }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword} B C A` }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword} C B` }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `test ${keyword} C` }) },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'キーワード1つ(大文字小文字区別する)',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ keywords: [['KEYWORD']], caseSensitive: true }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'keyword' }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'kEyWoRd' }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'KEYWORD' }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'キーワード1つ(大文字小文字区別しない)',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ keywords: [['KEYWORD']], caseSensitive: false }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'keyword' }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'kEyWoRd' }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: 'KEYWORD' }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '除外ワード1つ(大文字小文字区別する)',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ excludeKeywords: [['KEYWORD']], caseSensitive: true }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword} keyword` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword} kEyWoRd` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword} KEYWORD` }) },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '除外ワード1つ(大文字小文字区別しない)',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ excludeKeywords: [['KEYWORD']], caseSensitive: false }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword}` }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword} keyword` }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword} kEyWoRd` }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword} KEYWORD` }) },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '添付ファイルを問わない',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ withFile: false }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword}`, fileIds: [bobFile.id] }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '添付ファイル付きのみ',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ withFile: true }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword}`, fileIds: [bobFile.id] }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword}` }) },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'リプライ以外',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ withReplies: false }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword}`, replyId: alicePost.id }) },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'リプライも含む',
|
2024-03-03 12:15:35 +01:00
|
|
|
|
parameters: () => ({ withReplies: true }),
|
2023-05-19 13:53:20 +02:00
|
|
|
|
posts: [
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword}`, replyId: alicePost.id }), included: true },
|
|
|
|
|
{ note: (): Promise<Note> => post(bob, { text: `${keyword}` }), included: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
])('が取得できること($label)', async ({ parameters, posts }) => {
|
|
|
|
|
const antenna = await successfulApiCall({
|
|
|
|
|
endpoint: 'antennas/create',
|
|
|
|
|
parameters: { ...defaultParam, keywords: [[keyword]], ...parameters() },
|
|
|
|
|
user: alice,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const notes = await posts.reduce(async (prev, current) => {
|
|
|
|
|
// includedに関わらずnote()は評価して投稿する。
|
|
|
|
|
const p = await prev;
|
|
|
|
|
const n = await current.note();
|
|
|
|
|
if (current.included) return p.concat(n);
|
|
|
|
|
return p;
|
|
|
|
|
}, Promise.resolve([] as Note[]));
|
|
|
|
|
|
|
|
|
|
// alice視点でNoteを取り直す
|
|
|
|
|
const expected = await Promise.all(notes.reverse().map(s => successfulApiCall({
|
|
|
|
|
endpoint: 'notes/show',
|
|
|
|
|
parameters: { noteId: s.id },
|
|
|
|
|
user: alice,
|
|
|
|
|
})));
|
|
|
|
|
|
|
|
|
|
const response = await successfulApiCall({
|
|
|
|
|
endpoint: 'antennas/notes',
|
|
|
|
|
parameters: { antennaId: antenna.id },
|
|
|
|
|
user: alice,
|
|
|
|
|
});
|
|
|
|
|
assert.deepStrictEqual(
|
|
|
|
|
response.map(({ userId, id, text }) => ({ userId, id, text })),
|
|
|
|
|
expected.map(({ userId, id, text }) => ({ userId, id, text })));
|
|
|
|
|
assert.deepStrictEqual(response, expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.skip('が取得でき、日付指定のPaginationに一貫性があること', async () => { });
|
|
|
|
|
test.each([
|
|
|
|
|
{ label: 'ID指定', offsetBy: 'id' },
|
|
|
|
|
|
|
|
|
|
// BUG sinceDate, untilDateはsinceIdや他のエンドポイントとは異なり、その時刻に一致するレコードを含んでしまう。
|
|
|
|
|
// { label: '日付指定', offsetBy: 'createdAt' },
|
|
|
|
|
] as const)('が取得でき、$labelのPaginationに一貫性があること', async ({ offsetBy }) => {
|
|
|
|
|
const antenna = await successfulApiCall({
|
|
|
|
|
endpoint: 'antennas/create',
|
|
|
|
|
parameters: { ...defaultParam, keywords: [[keyword]] },
|
|
|
|
|
user: alice,
|
|
|
|
|
});
|
|
|
|
|
const notes = await [...Array(30)].reduce(async (prev, current, index) => {
|
|
|
|
|
const p = await prev;
|
|
|
|
|
const n = await post(alice, { text: `${keyword} (${index})` });
|
|
|
|
|
return [n].concat(p);
|
|
|
|
|
}, Promise.resolve([] as Note[]));
|
|
|
|
|
|
|
|
|
|
// antennas/notesは降順のみで、昇順をサポートしない。
|
|
|
|
|
await testPaginationConsistency(notes, async (paginationParam) => {
|
|
|
|
|
return successfulApiCall({
|
|
|
|
|
endpoint: 'antennas/notes',
|
|
|
|
|
parameters: { antennaId: antenna.id, ...paginationParam },
|
|
|
|
|
user: alice,
|
2024-03-03 12:15:35 +01:00
|
|
|
|
});
|
2023-05-19 13:53:20 +02:00
|
|
|
|
}, offsetBy, 'desc');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// BUG 7日過ぎると作り直すしかない。 https://github.com/misskey-dev/misskey/issues/10476
|
|
|
|
|
test.todo('を取得したときActiveに戻る');
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
});
|
|
|
|
|
});
|