add channel tl test

This commit is contained in:
samunohito 2024-07-06 22:39:02 +09:00
parent b78aa56dcd
commit 915225538b
2 changed files with 187 additions and 2 deletions

View File

@ -109,7 +109,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
excludePureRenotes: false,
noteFilter: note => {
// 共通機能を使うと見ているチャンネルそのものもミュートしてしまうので閲覧中のチャンネル以外を除く形にする
if (note.channelId === channel.id) return true;
if (note.channelId === channel.id && (note.renoteChannelId === null || note.renoteChannelId === channel.id)) return true;
return !isChannelRelated(note, mutingChannelIds);
},
dbFallback: async (untilId, sinceId, limit) => {

View File

@ -85,7 +85,7 @@ describe('Timelines', () => {
// FTT無効の状態で見たいときはコメントアウトを外す
// await api('admin/update-meta', { enableFanoutTimeline: false }, root);
// await sleep(1000);
// await setTimeout(1000);
});
afterEach(async () => {
@ -2792,6 +2792,191 @@ describe('Timelines', () => {
});
});
describe('Channel TL', () => {
test('閲覧中チャンネルのノートが含まれる', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
const channel = await createChannel('channel', bob);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
await waitForPushToTl();
const res = await api('channels/timeline', { channelId: channel.id }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
test('閲覧中チャンネルとは別チャンネルのノートは含まれない', async() => {
const [alice, bob] = await Promise.all([signup(), signup()]);
const channel = await createChannel('channel', bob);
const channel2 = await createChannel('channel', bob);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'ok', channelId: channel2.id });
await waitForPushToTl();
const res = await api('channels/timeline', { channelId: channel.id }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
test('閲覧中チャンネルのノートにリノートが含まれる', async() => {
const [alice, bob] = await Promise.all([signup(), signup()]);
const channel = await createChannel('channel', bob);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
const bobRenote = await post(bob, { channelId: channel.id, renoteId: bobNote.id });
await waitForPushToTl();
const res = await api('channels/timeline', { channelId: channel.id }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
});
test('閲覧中チャンネルとは別チャンネルからのリノートが含まれる', async() => {
const [alice, bob] = await Promise.all([signup(), signup()]);
const channel = await createChannel('channel', bob);
const channel2 = await createChannel('channel', bob);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'ok', channelId: channel2.id });
const bobRenote = await post(bob, { channelId: channel.id, renoteId: bobNote.id });
await waitForPushToTl();
const res = await api('channels/timeline', { channelId: channel.id }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
});
test('閲覧中チャンネルに自分の他人への返信が含まれる', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
const channel = await createChannel('channel', bob);
const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
const aliceNote = await post(alice, { text: 'hi', replyId: bobNote.id, channelId: channel.id });
await waitForPushToTl();
const res = await api('channels/timeline', { channelId: channel.id }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true);
});
test('閲覧中チャンネルに他人の自分への返信が含まれる', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
const channel = await createChannel('channel', bob);
const aliceNote = await post(alice, { text: 'hi', channelId: channel.id });
const bobNote = await post(bob, { text: 'ok', replyId: aliceNote.id, channelId: channel.id });
await waitForPushToTl();
const res = await api('channels/timeline', { channelId: channel.id }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
test('閲覧中チャンネルにミュートしているユーザのノートは含まれない', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
await api('mute/create', { userId: bob.id }, alice);
const channel = await createChannel('channel', bob);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
await waitForPushToTl();
const res = await api('channels/timeline', { channelId: channel.id }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
test('閲覧中チャンネルにこちらをブロックしているユーザのノートは含まれない', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
await api('blocking/create', { userId: alice.id }, bob);
const channel = await createChannel('channel', bob);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
await waitForPushToTl();
const res = await api('channels/timeline', { channelId: channel.id }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
test('閲覧中チャンネルをミュートしていてもノートが含まれる', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
const channel = await createChannel('channel', bob);
await muteChannel(channel.id, alice);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
await waitForPushToTl();
const res = await api('channels/timeline', { channelId: channel.id }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
test('閲覧中チャンネルをミュートしていてもリノートが含まれる', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
const channel = await createChannel('channel', bob);
await muteChannel(channel.id, alice);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
const bobRenote = await post(bob, { channelId: channel.id, renoteId: bobNote.id });
await waitForPushToTl();
const res = await api('channels/timeline', { channelId: channel.id }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
});
test('閲覧中チャンネルとは別チャンネルをミュートしているとき、そのチャンネルからのリノートは含まれない', async() => {
const [alice, bob] = await Promise.all([signup(), signup()]);
const channel = await createChannel('channel', bob);
const channel2 = await createChannel('channel', bob);
await muteChannel(channel2.id, alice);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'ok', channelId: channel2.id });
const bobRenote = await post(bob, { channelId: channel.id, renoteId: bobNote.id });
await waitForPushToTl();
const res = await api('channels/timeline', { channelId: channel.id }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
});
});
// TODO: リノートミュート済みユーザーのテスト
// TODO: ページネーションのテスト
});