From 58d2512d0e02a1780e8a6e6d67f3d74b31b367c5 Mon Sep 17 00:00:00 2001
From: syuilo <Syuilotan@yahoo.co.jp>
Date: Tue, 3 Oct 2023 09:28:37 +0900
Subject: [PATCH] Update timeline.ts

---
 packages/backend/test/e2e/timeline.ts | 54 ++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)

diff --git a/packages/backend/test/e2e/timeline.ts b/packages/backend/test/e2e/timeline.ts
index b73e5ad083..7f7367eae4 100644
--- a/packages/backend/test/e2e/timeline.ts
+++ b/packages/backend/test/e2e/timeline.ts
@@ -10,7 +10,7 @@ import { signup, api, post, react, startServer, waitFire, sleep } from '../utils
 import type { INestApplicationContext } from '@nestjs/common';
 import type * as misskey from 'misskey-js';
 
-describe('Renote Mute', () => {
+describe('Timelines', () => {
 	let app: INestApplicationContext;
 
 	beforeAll(async () => {
@@ -271,6 +271,58 @@ describe('Renote Mute', () => {
 		assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
 	});
 
+	test('タイムラインにフォローしているユーザーが行ったミュートしているユーザーのリノートが含まれない', async () => {
+		const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
+
+		await api('/following/create', {
+			userId: bob.id,
+		}, alice);
+		await api('/mute/create', {
+			userId: carol.id,
+		}, alice);
+		const carolNote = await post(carol, { text: 'hi' });
+		const bobNote = await post(bob, { text: 'hi', renoteId: carolNote.id });
+
+		// redisに追加されるのを待つ
+		await sleep(100);
+
+		const res = await api('/notes/timeline', {
+			withRenotes: false,
+		}, alice);
+
+		assert.strictEqual(res.status, 200);
+		assert.strictEqual(Array.isArray(res.body), true);
+		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('タイムラインに withReplies: true でフォローしているユーザーが行ったミュートしているユーザーの投稿への返信が含まれない', async () => {
+		const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
+
+		await api('/following/create', {
+			userId: bob.id,
+		}, alice);
+		await api('/following/update', {
+			userId: bob.id,
+			withReplies: true,
+		}, alice);
+		await api('/mute/create', {
+			userId: carol.id,
+		}, alice);
+		const carolNote = await post(carol, { text: 'hi' });
+		const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
+
+		// redisに追加されるのを待つ
+		await sleep(100);
+
+		const res = await api('/notes/timeline', {}, alice);
+
+		assert.strictEqual(res.status, 200);
+		assert.strictEqual(Array.isArray(res.body), true);
+		assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+		assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
+	});
+
 	// TODO: ミュート済みユーザーのテスト
 	// TODO: リノートミュート済みユーザーのテスト
 	// TODO: withFilesのテスト