From 610b68c8ffa554aa7f18acf94e9f9e9bc4c8941c Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 4 Oct 2023 11:32:33 +0900 Subject: [PATCH] tweak --- .../src/server/api/endpoints/users/notes.ts | 2 -- packages/backend/test/e2e/timelines.ts | 26 +++++++++++-------- packages/backend/test/utils.ts | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index 4613bfcf2a..6be391be4e 100644 --- a/packages/backend/src/server/api/endpoints/users/notes.ts +++ b/packages/backend/src/server/api/endpoints/users/notes.ts @@ -18,8 +18,6 @@ import { ApiError } from '../../error.js'; export const meta = { tags: ['users', 'notes'], - description: 'Show all notes that this user created.', - res: { type: 'array', optional: false, nullable: false, diff --git a/packages/backend/test/e2e/timelines.ts b/packages/backend/test/e2e/timelines.ts index 03311ac833..b1e84a821c 100644 --- a/packages/backend/test/e2e/timelines.ts +++ b/packages/backend/test/e2e/timelines.ts @@ -7,10 +7,14 @@ process.env.NODE_ENV = 'test'; process.env.FORCE_FOLLOW_REMOTE_USER_FOR_TESTING = 'true'; import * as assert from 'assert'; -import { signup, api, post, react, startServer, waitFire, sleep, uploadUrl } from '../utils.js'; +import { signup, api, post, react, startServer, waitFire, sleep, uploadUrl, randomString } from '../utils.js'; import type { INestApplicationContext } from '@nestjs/common'; import type * as misskey from 'misskey-js'; +function genHost() { + return randomString() + '.example.com'; +} + let app: INestApplicationContext; beforeAll(async () => { @@ -290,7 +294,7 @@ describe('Timelines', () => { }); test.concurrent('フォローしているリモートユーザーのノートが含まれる', async () => { - const [alice, bob] = await Promise.all([signup(), signup({ host: 'example.com' })]); + const [alice, bob] = await Promise.all([signup(), signup({ host: genHost() })]); await api('/following/create', { userId: bob.id }, alice); const bobNote = await post(bob, { text: 'hi' }); @@ -303,7 +307,7 @@ describe('Timelines', () => { }); test.concurrent('フォローしているリモートユーザーの visibility: home なノートが含まれる', async () => { - const [alice, bob] = await Promise.all([signup(), signup({ host: 'example.com' })]); + const [alice, bob] = await Promise.all([signup(), signup({ host: genHost() })]); await api('/following/create', { userId: bob.id }, alice); const bobNote = await post(bob, { text: 'hi', visibility: 'home' }); @@ -355,7 +359,7 @@ describe('Timelines', () => { }); test.concurrent('リモートユーザーのノートが含まれない', async () => { - const [alice, bob] = await Promise.all([signup(), signup({ host: 'example.com' })]); + const [alice, bob] = await Promise.all([signup(), signup({ host: genHost() })]); const bobNote = await post(bob, { text: 'hi' }); @@ -487,7 +491,7 @@ describe('Timelines', () => { }); test.concurrent('リモートユーザーのノートが含まれない', async () => { - const [alice, bob] = await Promise.all([signup(), signup({ host: 'example.com' })]); + const [alice, bob] = await Promise.all([signup(), signup({ host: genHost() })]); const bobNote = await post(bob, { text: 'hi' }); @@ -499,7 +503,7 @@ describe('Timelines', () => { }); test.concurrent('フォローしているリモートユーザーのノートが含まれる', async () => { - const [alice, bob] = await Promise.all([signup(), signup({ host: 'example.com' })]); + const [alice, bob] = await Promise.all([signup(), signup({ host: genHost() })]); await api('/following/create', { userId: bob.id }, alice); const bobNote = await post(bob, { text: 'hi' }); @@ -512,7 +516,7 @@ describe('Timelines', () => { }); test.concurrent('フォローしているリモートユーザーの visibility: home なノートが含まれる', async () => { - const [alice, bob] = await Promise.all([signup(), signup({ host: 'example.com' })]); + const [alice, bob] = await Promise.all([signup(), signup({ host: genHost() })]); await api('/following/create', { userId: bob.id }, alice); const bobNote = await post(bob, { text: 'hi', visibility: 'home' }); @@ -704,7 +708,7 @@ describe('Timelines', () => { await sleep(100); // redisに追加されるのを待つ - const res = await api('/users/notes', {}, alice); + const res = await api('/users/notes', { userId: bob.id }, alice); assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false); }); @@ -717,7 +721,7 @@ describe('Timelines', () => { await sleep(100); // redisに追加されるのを待つ - const res = await api('/users/notes', {}, alice); + const res = await api('/users/notes', { userId: bob.id }, 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'); @@ -732,7 +736,7 @@ describe('Timelines', () => { await sleep(100); // redisに追加されるのを待つ - const res = await api('/users/notes', {}, alice); + const res = await api('/users/notes', { userId: bob.id }, alice); assert.strictEqual(res.body.some((note: any) => note.id === bobNote1.id), true); assert.strictEqual(res.body.some((note: any) => note.id === bobNote2.id), false); @@ -747,7 +751,7 @@ describe('Timelines', () => { await sleep(100); // redisに追加されるのを待つ - const res = await api('/users/notes', { withReplies: true }, alice); + const res = await api('/users/notes', { userId: bob.id, withReplies: true }, 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); diff --git a/packages/backend/test/utils.ts b/packages/backend/test/utils.ts index fae9018422..121c4711d3 100644 --- a/packages/backend/test/utils.ts +++ b/packages/backend/test/utils.ts @@ -99,7 +99,7 @@ export const relativeFetch = async (path: string, init?: RequestInit | undefined return await fetch(new URL(path, `http://127.0.0.1:${port}/`).toString(), init); }; -function randomString(chars = 'abcdefghijklmnopqrstuvwxyz0123456789', length = 16) { +export function randomString(chars = 'abcdefghijklmnopqrstuvwxyz0123456789', length = 16) { let randomString = ''; for (let i = 0; i < length; i++) { randomString += chars[Math.floor(Math.random() * chars.length)];