Merge tag '2023.10.1' into merge-upstream

This commit is contained in:
riku6460 2023-10-12 20:59:40 +09:00
commit 9c06284ed1
No known key found for this signature in database
GPG key ID: 27414FA27DB94CF6
15 changed files with 287 additions and 60 deletions

View file

@ -19,7 +19,7 @@ function genHost() {
}
function waitForPushToTl() {
return sleep(300);
return sleep(500);
}
let app: INestApplicationContext;
@ -41,7 +41,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true);
assert.strictEqual(res.body.find((note: any) => note.id === aliceNote.id).text, 'hi');
@ -57,7 +57,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
@ -73,7 +73,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
assert.strictEqual(res.body.find((note: any) => note.id === bobNote.id).text, 'hi');
@ -90,7 +90,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
@ -107,7 +107,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
@ -124,7 +124,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
@ -141,7 +141,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
@ -159,7 +159,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true);
@ -178,7 +178,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true);
@ -194,12 +194,28 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote1.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote2.id), true);
});
test.concurrent('withReplies: false でフォローしているユーザーからの自分への返信が含まれる', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
await api('/following/create', { userId: bob.id }, alice);
await sleep(1000);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
await waitForPushToTl();
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
test.concurrent('自分の他人への返信が含まれる', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
@ -208,7 +224,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true);
@ -224,7 +240,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
@ -275,7 +291,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
@ -291,7 +307,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
@ -309,7 +325,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
@ -324,7 +340,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
@ -338,7 +354,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
@ -359,7 +375,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', { withFiles: true }, alice);
const res = await api('/notes/timeline', { limit: 100, withFiles: true }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote1.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote2.id), true);
@ -377,7 +393,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
@ -389,7 +405,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true);
assert.strictEqual(res.body.find((note: any) => note.id === aliceNote.id).text, 'hi');
@ -404,7 +420,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
assert.strictEqual(res.body.find((note: any) => note.id === bobNote.id).text, 'hi');
@ -417,7 +433,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
@ -431,7 +447,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
@ -444,7 +460,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true);
assert.strictEqual(res.body.find((note: any) => note.id === aliceNote.id).text, 'ok');
@ -459,7 +475,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
assert.strictEqual(res.body.find((note: any) => note.id === bobNote.id).text, 'ok');
@ -475,7 +491,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/timeline', {}, alice);
const res = await api('/notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
@ -490,12 +506,26 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/local-timeline', {}, alice);
const res = await api('/notes/local-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
});
test.concurrent('他人の他人への返信が含まれない', async () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
const carolNote = await post(carol, { text: 'hi' });
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
await waitForPushToTl();
const res = await api('/notes/local-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true);
});
test.concurrent('チャンネル投稿が含まれない', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
@ -504,7 +534,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/local-timeline', {}, alice);
const res = await api('/notes/local-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
@ -516,7 +546,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/local-timeline', {}, alice);
const res = await api('/notes/local-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
@ -532,7 +562,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/local-timeline', {}, alice);
const res = await api('/notes/local-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
@ -548,7 +578,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/local-timeline', {}, alice);
const res = await api('/notes/local-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
@ -565,7 +595,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/local-timeline', {}, alice);
const res = await api('/notes/local-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
@ -583,12 +613,41 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/local-timeline', {}, alice);
const res = await api('/notes/local-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
});
test.concurrent('withReplies: false でフォローしているユーザーからの自分への返信が含まれる', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
await api('/following/create', { userId: bob.id }, alice);
await sleep(1000);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
await waitForPushToTl();
const res = await api('/notes/local-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
test.concurrent('[withReplies: true] 他人の他人への返信が含まれる', async () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
const carolNote = await post(carol, { text: 'hi' });
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
await waitForPushToTl();
const res = await api('/notes/local-timeline', { limit: 100, withReplies: true }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
test.concurrent('[withFiles: true] ファイル付きノートのみ含まれる', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
@ -598,7 +657,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/local-timeline', { withFiles: true }, alice);
const res = await api('/notes/local-timeline', { limit: 100, withFiles: true }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote1.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote2.id), true);
@ -613,7 +672,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/hybrid-timeline', {}, alice);
const res = await api('/notes/hybrid-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
@ -625,7 +684,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/hybrid-timeline', {}, alice);
const res = await api('/notes/hybrid-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
@ -639,11 +698,41 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/hybrid-timeline', {}, alice);
const res = await api('/notes/hybrid-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
test.concurrent('withReplies: false でフォローしているユーザーからの自分への返信が含まれる', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
await api('/following/create', { userId: bob.id }, alice);
await sleep(1000);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
await waitForPushToTl();
const res = await api('/notes/hybrid-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
test.concurrent('他人の他人への返信が含まれない', async () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
const carolNote = await post(carol, { text: 'hi' });
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
await waitForPushToTl();
const res = await api('/notes/hybrid-timeline', { }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true);
});
test.concurrent('リモートユーザーのノートが含まれない', async () => {
const [alice, bob] = await Promise.all([signup(), signup({ host: genHost() })]);
@ -651,7 +740,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/local-timeline', {}, alice);
const res = await api('/notes/local-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
@ -665,7 +754,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/hybrid-timeline', {}, alice);
const res = await api('/notes/hybrid-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
@ -679,7 +768,20 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/hybrid-timeline', {}, alice);
const res = await api('/notes/hybrid-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
test.concurrent('[withReplies: true] 他人の他人への返信が含まれる', async () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
const carolNote = await post(carol, { text: 'hi' });
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
await waitForPushToTl();
const res = await api('/notes/hybrid-timeline', { limit: 100, withReplies: true }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
@ -693,7 +795,7 @@ describe('Timelines', () => {
await waitForPushToTl();
const res = await api('/notes/hybrid-timeline', { withFiles: true }, alice);
const res = await api('/notes/hybrid-timeline', { limit: 100, withFiles: true }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote1.id), false);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote2.id), true);
@ -779,6 +881,22 @@ describe('Timelines', () => {
assert.strictEqual(res.body.some((note: any) => note.id === bobNote2.id), true);
});
test.concurrent('withReplies: false でリスインしているフォローしていないユーザーからの自分への返信が含まれる', async () => {
const [alice, bob] = await Promise.all([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 sleep(1000);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
await waitForPushToTl();
const res = await api('/notes/user-list-timeline', { listId: list.id, withReplies: false }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
test.concurrent('withReplies: true でリスインしているフォローしていないユーザーの他人への返信が含まれる', async () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
@ -1034,6 +1152,32 @@ describe('Timelines', () => {
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
test.concurrent('[withChannelNotes: true] 他人が取得した場合センシティブチャンネル投稿が含まれない', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]);
const channel = await api('/channels/create', { name: 'channel', isSensitive: true }, bob).then(x => x.body);
const bobNote = await post(bob, { text: 'hi', channelId: channel.id });
await waitForPushToTl();
const res = await api('/users/notes', { userId: bob.id, withChannelNotes: true }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
test.concurrent('[withChannelNotes: true] 自分が取得した場合センシティブチャンネル投稿が含まれる', async () => {
const [bob] = await Promise.all([signup()]);
const channel = await api('/channels/create', { name: 'channel', isSensitive: true }, bob).then(x => x.body);
const bobNote = await post(bob, { text: 'hi', channelId: channel.id });
await waitForPushToTl();
const res = await api('/users/notes', { userId: bob.id, withChannelNotes: true }, bob);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
});
test.concurrent('ミュートしているユーザーに関連する投稿が含まれない', async () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);