Merge branch 'refs/heads/develop' into feature/channel_muting
# Conflicts: # packages/backend/test/e2e/timelines.ts
This commit is contained in:
commit
81d883c45f
75 changed files with 5692 additions and 4609 deletions
|
|
@ -1,11 +0,0 @@
|
|||
module.exports = {
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: ['./tsconfig.json'],
|
||||
},
|
||||
extends: ['../.eslintrc.cjs'],
|
||||
env: {
|
||||
node: true,
|
||||
jest: true,
|
||||
},
|
||||
};
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
redistest:
|
||||
image: redis:7
|
||||
|
|
@ -23,7 +23,7 @@ describe('Drive', () => {
|
|||
|
||||
const marker = Math.random().toString();
|
||||
|
||||
const url = 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/Lenna.jpg';
|
||||
const url = 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/192.jpg';
|
||||
|
||||
const catcher = makeStreamCatcher(
|
||||
alice,
|
||||
|
|
@ -41,14 +41,14 @@ describe('Drive', () => {
|
|||
const file = await catcher;
|
||||
|
||||
assert.strictEqual(res.status, 204);
|
||||
assert.strictEqual(file.name, 'Lenna.jpg');
|
||||
assert.strictEqual(file.name, '192.jpg');
|
||||
assert.strictEqual(file.type, 'image/jpeg');
|
||||
});
|
||||
|
||||
test('ローカルからアップロードできる', async () => {
|
||||
// APIレスポンスを直接使用するので utils.js uploadFile が通過することで成功とする
|
||||
|
||||
const res = await uploadFile(alice, { path: 'Lenna.jpg', name: 'テスト画像' });
|
||||
const res = await uploadFile(alice, { path: '192.jpg', name: 'テスト画像' });
|
||||
|
||||
assert.strictEqual(res.body?.name, 'テスト画像.jpg');
|
||||
assert.strictEqual(res.body.type, 'image/jpeg');
|
||||
|
|
|
|||
|
|
@ -584,7 +584,7 @@ describe('Endpoints', () => {
|
|||
|
||||
assert.strictEqual(res.status, 200);
|
||||
assert.strictEqual(typeof res.body === 'object' && !Array.isArray(res.body), true);
|
||||
assert.strictEqual(res.body!.name, 'Lenna.jpg');
|
||||
assert.strictEqual(res.body!.name, '192.jpg');
|
||||
});
|
||||
|
||||
test('ファイルに名前を付けられる', async () => {
|
||||
|
|
|
|||
|
|
@ -7,12 +7,13 @@ import { INestApplicationContext } from '@nestjs/common';
|
|||
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
import { setTimeout } from 'node:timers/promises';
|
||||
import * as assert from 'assert';
|
||||
import { loadConfig } from '@/config.js';
|
||||
import { MiRepository, MiUser, UsersRepository, miRepository } from '@/models/_.js';
|
||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||
import { jobQueue } from '@/boot/common.js';
|
||||
import { api, initTestDb, signup, sleep, successfulApiCall, uploadFile } from '../utils.js';
|
||||
import { api, initTestDb, signup, successfulApiCall, uploadFile } from '../utils.js';
|
||||
import type * as misskey from 'misskey-js';
|
||||
|
||||
describe('Account Move', () => {
|
||||
|
|
@ -271,7 +272,7 @@ describe('Account Move', () => {
|
|||
|
||||
assert.strictEqual(move.status, 200);
|
||||
|
||||
await sleep(1000 * 3); // wait for jobs to finish
|
||||
await setTimeout(1000 * 3); // wait for jobs to finish
|
||||
|
||||
// Unfollow delayed?
|
||||
const aliceFollowings = await api('users/following', {
|
||||
|
|
@ -330,7 +331,7 @@ describe('Account Move', () => {
|
|||
});
|
||||
|
||||
test('Unfollowed after 10 sec (24 hours in production).', async () => {
|
||||
await sleep(1000 * 8);
|
||||
await setTimeout(1000 * 8);
|
||||
|
||||
const following = await api('users/following', {
|
||||
userId: alice.id,
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ describe('Note', () => {
|
|||
});
|
||||
|
||||
test('ファイルを添付できる', async () => {
|
||||
const file = await uploadUrl(alice, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/Lenna.jpg');
|
||||
const file = await uploadUrl(alice, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/192.jpg');
|
||||
|
||||
const res = await api('notes/create', {
|
||||
fileIds: [file.id],
|
||||
|
|
@ -53,7 +53,7 @@ describe('Note', () => {
|
|||
}, 1000 * 10);
|
||||
|
||||
test('他人のファイルで怒られる', async () => {
|
||||
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/Lenna.jpg');
|
||||
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/192.jpg');
|
||||
|
||||
const res = await api('notes/create', {
|
||||
text: 'test',
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
process.env.NODE_ENV = 'test';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { api, post, signup, sleep, waitFire } from '../utils.js';
|
||||
import { setTimeout } from 'node:timers/promises';
|
||||
import { api, post, signup, waitFire } from '../utils.js';
|
||||
import type * as misskey from 'misskey-js';
|
||||
|
||||
describe('Renote Mute', () => {
|
||||
|
|
@ -35,7 +36,7 @@ describe('Renote Mute', () => {
|
|||
const carolNote = await post(carol, { text: 'hi' });
|
||||
|
||||
// redisに追加されるのを待つ
|
||||
await sleep(100);
|
||||
await setTimeout(100);
|
||||
|
||||
const res = await api('notes/local-timeline', {}, alice);
|
||||
|
||||
|
|
@ -52,7 +53,7 @@ describe('Renote Mute', () => {
|
|||
const carolNote = await post(carol, { text: 'hi' });
|
||||
|
||||
// redisに追加されるのを待つ
|
||||
await sleep(100);
|
||||
await setTimeout(100);
|
||||
|
||||
const res = await api('notes/local-timeline', {}, alice);
|
||||
|
||||
|
|
@ -69,7 +70,7 @@ describe('Renote Mute', () => {
|
|||
const bobRenote = await post(bob, { renoteId: carolNote.id });
|
||||
|
||||
// redisに追加されるのを待つ
|
||||
await sleep(100);
|
||||
await setTimeout(100);
|
||||
|
||||
const res = await api('notes/local-timeline', {}, alice);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// pnpm jest -- e2e/timelines.ts
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { setTimeout } from 'node:timers/promises';
|
||||
import { entities } from 'misskey-js';
|
||||
import { Redis } from 'ioredis';
|
||||
import { afterEach, beforeAll } from '@jest/globals';
|
||||
|
|
@ -20,7 +21,6 @@ import {
|
|||
randomString,
|
||||
sendEnvUpdateRequest,
|
||||
signup,
|
||||
sleep,
|
||||
uploadUrl,
|
||||
UserToken,
|
||||
} from '../utils.js';
|
||||
|
|
@ -30,7 +30,7 @@ function genHost() {
|
|||
}
|
||||
|
||||
function waitForPushToTl() {
|
||||
return sleep(500);
|
||||
return setTimeout(500);
|
||||
}
|
||||
|
||||
let redisForTimelines: Redis;
|
||||
|
|
@ -123,7 +123,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi' });
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
|
||||
|
|
@ -139,7 +139,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', visibility: 'followers' });
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ describe('Timelines', () => {
|
|||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await api('following/update', { userId: bob.id, withReplies: true }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ describe('Timelines', () => {
|
|||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await api('following/update', { userId: bob.id, withReplies: true }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, {
|
||||
text: 'hi',
|
||||
|
|
@ -212,7 +212,7 @@ describe('Timelines', () => {
|
|||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await api('following/update', { userId: bob.id, withReplies: true }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi', visibility: 'followers' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ describe('Timelines', () => {
|
|||
await api('following/create', { userId: carol.id }, alice);
|
||||
await api('following/create', { userId: carol.id }, bob);
|
||||
await api('following/update', { userId: bob.id, withReplies: true }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi', visibility: 'followers' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ describe('Timelines', () => {
|
|||
await api('following/create', { userId: bob.id }, alice);
|
||||
await api('following/create', { userId: carol.id }, alice);
|
||||
await api('following/update', { userId: bob.id, withReplies: true }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, {
|
||||
text: 'hi',
|
||||
|
|
@ -271,7 +271,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const bobNote1 = await post(bob, { text: 'hi' });
|
||||
const bobNote2 = await post(bob, { text: 'hi', replyId: bobNote1.id });
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const aliceNote = await post(alice, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { renoteId: carolNote.id });
|
||||
|
||||
|
|
@ -333,7 +333,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { renoteId: carolNote.id });
|
||||
|
||||
|
|
@ -351,7 +351,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', renoteId: carolNote.id });
|
||||
|
||||
|
|
@ -369,7 +369,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', visibility: 'specified', visibleUserIds: [carol.id] });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -384,7 +384,7 @@ describe('Timelines', () => {
|
|||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await api('mute/create', { userId: carol.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', renoteId: carolNote.id });
|
||||
|
||||
|
|
@ -402,7 +402,7 @@ describe('Timelines', () => {
|
|||
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);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
||||
|
||||
|
|
@ -448,7 +448,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const [bobFile, carolFile] = await Promise.all([
|
||||
uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/assets/main/public/icon.png'),
|
||||
uploadUrl(carol, 'https://raw.githubusercontent.com/misskey-dev/assets/main/public/icon.png'),
|
||||
|
|
@ -473,7 +473,7 @@ describe('Timelines', () => {
|
|||
|
||||
const channel = await api('channels/create', { name: 'channel' }, bob).then(x => x.body);
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', channelId: channel.id });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -500,7 +500,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', visibility: 'specified', visibleUserIds: [alice.id] });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -527,7 +527,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', visibility: 'specified', visibleUserIds: [carol.id] });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -939,7 +939,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: carol.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi', visibility: 'home' });
|
||||
const bobNote = await post(bob, { text: 'hi' });
|
||||
|
||||
|
|
@ -955,7 +955,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
await api('mute/create', { userId: carol.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi' });
|
||||
|
||||
|
|
@ -972,7 +972,7 @@ describe('Timelines', () => {
|
|||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await api('mute/create', { userId: carol.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', renoteId: carolNote.id });
|
||||
|
||||
|
|
@ -990,7 +990,7 @@ describe('Timelines', () => {
|
|||
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);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
||||
|
||||
|
|
@ -1006,7 +1006,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const aliceNote = await post(alice, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
|
||||
|
||||
|
|
@ -1350,7 +1350,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', visibility: 'home' });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -1364,7 +1364,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const aliceNote = await post(alice, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
|
||||
|
||||
|
|
@ -1741,7 +1741,7 @@ describe('Timelines', () => {
|
|||
|
||||
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);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi' });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -1756,7 +1756,7 @@ describe('Timelines', () => {
|
|||
|
||||
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);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', visibility: 'home' });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -1771,7 +1771,7 @@ describe('Timelines', () => {
|
|||
|
||||
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);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', visibility: 'followers' });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -1786,7 +1786,7 @@ describe('Timelines', () => {
|
|||
|
||||
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);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
||||
|
||||
|
|
@ -1802,7 +1802,7 @@ describe('Timelines', () => {
|
|||
|
||||
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);
|
||||
await setTimeout(1000);
|
||||
const bobNote1 = await post(bob, { text: 'hi' });
|
||||
const bobNote2 = await post(bob, { text: 'hi', replyId: bobNote1.id });
|
||||
|
||||
|
|
@ -1820,7 +1820,7 @@ describe('Timelines', () => {
|
|||
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 api('users/lists/update-membership', { listId: list.id, userId: bob.id, withReplies: false }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const aliceNote = await post(alice, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
|
||||
|
||||
|
|
@ -1837,7 +1837,7 @@ describe('Timelines', () => {
|
|||
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 api('users/lists/update-membership', { listId: list.id, userId: bob.id, withReplies: false }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
||||
|
||||
|
|
@ -1854,7 +1854,7 @@ describe('Timelines', () => {
|
|||
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 api('users/lists/update-membership', { listId: list.id, userId: bob.id, withReplies: true }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
||||
|
||||
|
|
@ -1871,7 +1871,7 @@ describe('Timelines', () => {
|
|||
await api('following/create', { userId: bob.id }, alice);
|
||||
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);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', visibility: 'home' });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -1887,7 +1887,7 @@ describe('Timelines', () => {
|
|||
await api('following/create', { userId: bob.id }, alice);
|
||||
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);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', visibility: 'followers' });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -1903,7 +1903,7 @@ describe('Timelines', () => {
|
|||
|
||||
const list = await api('users/lists/create', { name: 'list' }, alice).then(res => res.body);
|
||||
await api('users/lists/push', { listId: list.id, userId: alice.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const aliceNote = await post(alice, { text: 'hi', visibility: 'followers' });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -1920,7 +1920,7 @@ describe('Timelines', () => {
|
|||
const channel = await api('channels/create', { name: 'channel' }, bob).then(x => x.body);
|
||||
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);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', channelId: channel.id });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -1952,7 +1952,7 @@ describe('Timelines', () => {
|
|||
|
||||
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);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', visibility: 'specified', visibleUserIds: [alice.id] });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -1969,7 +1969,7 @@ describe('Timelines', () => {
|
|||
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 api('users/lists/push', { listId: list.id, userId: carol.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', visibility: 'specified', visibleUserIds: [carol.id] });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -2315,7 +2315,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||
|
||||
await api('following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const bobNote = await post(bob, { text: 'hi', visibility: 'followers' });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
|
@ -2455,7 +2455,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
await api('mute/create', { userId: carol.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', renoteId: carolNote.id });
|
||||
|
||||
|
|
@ -2470,7 +2470,7 @@ describe('Timelines', () => {
|
|||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||
|
||||
await api('mute/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
await setTimeout(1000);
|
||||
const bobNote1 = await post(bob, { text: 'hi' });
|
||||
const bobNote2 = await post(bob, { text: 'hi', replyId: bobNote1.id });
|
||||
const bobNote3 = await post(bob, { text: 'hi', renoteId: bobNote1.id });
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ describe('users/notes', () => {
|
|||
|
||||
beforeAll(async () => {
|
||||
alice = await signup({ username: 'alice' });
|
||||
const jpg = await uploadUrl(alice, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/Lenna.jpg');
|
||||
const png = await uploadUrl(alice, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/Lenna.png');
|
||||
const jpg = await uploadUrl(alice, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/192.jpg');
|
||||
const png = await uploadUrl(alice, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/192.png');
|
||||
jpgNote = await post(alice, {
|
||||
fileIds: [jpg.id],
|
||||
});
|
||||
|
|
|
|||
22
packages/backend/test/eslint.config.js
Normal file
22
packages/backend/test/eslint.config.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import globals from 'globals';
|
||||
import tsParser from '@typescript-eslint/parser';
|
||||
import sharedConfig from '../../shared/eslint.config.js';
|
||||
|
||||
export default [
|
||||
...sharedConfig,
|
||||
{
|
||||
files: ['**/*.ts', '**/*.tsx'],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.jest,
|
||||
},
|
||||
parserOptions: {
|
||||
parser: tsParser,
|
||||
project: ['./tsconfig.json'],
|
||||
sourceType: 'module',
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
BIN
packages/backend/test/resources/192.jpg
Normal file
BIN
packages/backend/test/resources/192.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5 KiB |
BIN
packages/backend/test/resources/192.png
Normal file
BIN
packages/backend/test/resources/192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 463 KiB |
|
|
@ -83,21 +83,21 @@ describe('FileInfoService', () => {
|
|||
|
||||
describe('IMAGE', () => {
|
||||
test('Generic JPEG', async () => {
|
||||
const path = `${resources}/Lenna.jpg`;
|
||||
const path = `${resources}/192.jpg`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
delete info.porn;
|
||||
assert.deepStrictEqual(info, {
|
||||
size: 25360,
|
||||
md5: '091b3f259662aa31e2ffef4519951168',
|
||||
size: 5131,
|
||||
md5: '8c9ed0677dd2b8f9f7472c3af247e5e3',
|
||||
type: {
|
||||
mime: 'image/jpeg',
|
||||
ext: 'jpg',
|
||||
},
|
||||
width: 512,
|
||||
height: 512,
|
||||
width: 192,
|
||||
height: 192,
|
||||
orientation: undefined,
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
import { setTimeout } from 'node:timers/promises';
|
||||
import { jest } from '@jest/globals';
|
||||
import { ModuleMocker } from 'jest-mock';
|
||||
import { Test } from '@nestjs/testing';
|
||||
|
|
@ -29,7 +30,6 @@ import { secureRndstr } from '@/misc/secure-rndstr.js';
|
|||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { RoleCondFormulaValue } from '@/models/Role.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { sleep } from '../utils.js';
|
||||
import type { TestingModule } from '@nestjs/testing';
|
||||
import type { MockFunctionMetadata } from 'jest-mock';
|
||||
|
||||
|
|
@ -278,7 +278,7 @@ describe('RoleService', () => {
|
|||
|
||||
// ストリーミング経由で反映されるまでちょっと待つ
|
||||
clock.uninstall();
|
||||
await sleep(100);
|
||||
await setTimeout(100);
|
||||
|
||||
const resultAfter25hAgain = await roleService.getUserPolicies(user.id);
|
||||
expect(resultAfter25hAgain.canManageCustomEmojis).toBe(true);
|
||||
|
|
@ -807,7 +807,7 @@ describe('RoleService', () => {
|
|||
await roleService.assign(user.id, role.id);
|
||||
|
||||
clock.uninstall();
|
||||
await sleep(100);
|
||||
await setTimeout(100);
|
||||
|
||||
const assignments = await roleAssignmentsRepository.find({
|
||||
where: {
|
||||
|
|
@ -835,7 +835,7 @@ describe('RoleService', () => {
|
|||
await roleService.assign(user.id, role.id);
|
||||
|
||||
clock.uninstall();
|
||||
await sleep(100);
|
||||
await setTimeout(100);
|
||||
|
||||
const assignments = await roleAssignmentsRepository.find({
|
||||
where: {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { setTimeout } from 'node:timers/promises';
|
||||
import { afterEach, beforeEach, describe, expect, jest } from '@jest/globals';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { MiUser } from '@/models/User.js';
|
||||
|
|
@ -16,7 +17,7 @@ import { DI } from '@/di-symbols.js';
|
|||
import { QueueService } from '@/core/QueueService.js';
|
||||
import { LoggerService } from '@/core/LoggerService.js';
|
||||
import { SystemWebhookService } from '@/core/SystemWebhookService.js';
|
||||
import { randomString, sleep } from '../utils.js';
|
||||
import { randomString } from '../utils.js';
|
||||
|
||||
describe('SystemWebhookService', () => {
|
||||
let app: TestingModule;
|
||||
|
|
@ -358,7 +359,7 @@ describe('SystemWebhookService', () => {
|
|||
);
|
||||
|
||||
// redisでの配信経由で更新されるのでちょっと待つ
|
||||
await sleep(500);
|
||||
await setTimeout(500);
|
||||
|
||||
const fetchedWebhooks = await service.fetchActiveSystemWebhooks();
|
||||
expect(fetchedWebhooks).toEqual([webhook]);
|
||||
|
|
@ -377,7 +378,7 @@ describe('SystemWebhookService', () => {
|
|||
);
|
||||
|
||||
// redisでの配信経由で更新されるのでちょっと待つ
|
||||
await sleep(500);
|
||||
await setTimeout(500);
|
||||
|
||||
const fetchedWebhooks = await service.fetchActiveSystemWebhooks();
|
||||
expect(fetchedWebhooks).toEqual([]);
|
||||
|
|
@ -407,7 +408,7 @@ describe('SystemWebhookService', () => {
|
|||
);
|
||||
|
||||
// redisでの配信経由で更新されるのでちょっと待つ
|
||||
await sleep(500);
|
||||
await setTimeout(500);
|
||||
|
||||
const fetchedWebhooks = await service.fetchActiveSystemWebhooks();
|
||||
expect(fetchedWebhooks).toEqual([webhook2]);
|
||||
|
|
@ -434,7 +435,7 @@ describe('SystemWebhookService', () => {
|
|||
);
|
||||
|
||||
// redisでの配信経由で更新されるのでちょっと待つ
|
||||
await sleep(500);
|
||||
await setTimeout(500);
|
||||
|
||||
const fetchedWebhooks = await service.fetchActiveSystemWebhooks();
|
||||
expect(fetchedWebhooks.length).toEqual(0);
|
||||
|
|
@ -457,7 +458,7 @@ describe('SystemWebhookService', () => {
|
|||
);
|
||||
|
||||
// redisでの配信経由で更新されるのでちょっと待つ
|
||||
await sleep(500);
|
||||
await setTimeout(500);
|
||||
|
||||
const fetchedWebhooks = await service.fetchActiveSystemWebhooks();
|
||||
expect(fetchedWebhooks).toEqual([webhook2]);
|
||||
|
|
@ -481,7 +482,7 @@ describe('SystemWebhookService', () => {
|
|||
);
|
||||
|
||||
// redisでの配信経由で更新されるのでちょっと待つ
|
||||
await sleep(500);
|
||||
await setTimeout(500);
|
||||
|
||||
const fetchedWebhooks = await service.fetchActiveSystemWebhooks();
|
||||
expect(fetchedWebhooks.length).toEqual(0);
|
||||
|
|
@ -504,7 +505,7 @@ describe('SystemWebhookService', () => {
|
|||
);
|
||||
|
||||
// redisでの配信経由で更新されるのでちょっと待つ
|
||||
await sleep(500);
|
||||
await setTimeout(500);
|
||||
|
||||
const fetchedWebhooks = await service.fetchActiveSystemWebhooks();
|
||||
expect(fetchedWebhooks.length).toEqual(0);
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ export const uploadFile = async (user?: UserToken, { path, name, blob }: UploadO
|
|||
body: misskey.entities.DriveFile | null
|
||||
}> => {
|
||||
const absPath = path == null
|
||||
? new URL('resources/Lenna.jpg', import.meta.url)
|
||||
? new URL('resources/192.jpg', import.meta.url)
|
||||
: isAbsolute(path.toString())
|
||||
? new URL(path)
|
||||
: new URL(path, new URL('resources/', import.meta.url));
|
||||
|
|
@ -605,14 +605,6 @@ export async function initTestDb(justBorrow = false, initEntities?: any[]) {
|
|||
return db;
|
||||
}
|
||||
|
||||
export function sleep(msec: number) {
|
||||
return new Promise<void>(res => {
|
||||
setTimeout(() => {
|
||||
res();
|
||||
}, msec);
|
||||
});
|
||||
}
|
||||
|
||||
export async function sendEnvUpdateRequest(params: { key: string, value?: string }) {
|
||||
const res = await fetch(
|
||||
`http://localhost:${port + 1000}/env`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue