mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-07-25 09:45:04 +02:00
fix(backend/test): e2e testの固定待ち時間をポーリングに変更 (#17654)
* test(backend): timelines.ts の固定250ms待ちをポーリング化する (tiramiss-community/endolphin#47) Co-authored-by: おさむのひと <46447427+samunohito@users.noreply.github.com> * test(backend): move.ts のflaky/低速sleepをポーリング化する (tiramiss-community/endolphin#49) Co-authored-by: おさむのひと <46447427+samunohito@users.noreply.github.com> --------- Co-authored-by: おさむのひと <46447427+samunohito@users.noreply.github.com>
This commit is contained in:
@@ -7,9 +7,8 @@ import { INestApplicationContext } from '@nestjs/common';
|
||||
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
import { setTimeout } from 'node:timers/promises';
|
||||
import * as assert from 'assert';
|
||||
import { afterAll, beforeAll, afterEach, describe, test } from 'vitest';
|
||||
import { afterAll, beforeAll, afterEach, describe, test, vi } from 'vitest';
|
||||
import { loadConfig } from '@/config.js';
|
||||
import { MiRepository, MiUser, UsersRepository, miRepository } from '@/models/_.js';
|
||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||
@@ -17,6 +16,11 @@ import { jobQueue } from '@/boot/common.js';
|
||||
import { api, castAsError, initTestDb, signup, successfulApiCall, uploadFile } from '../utils.js';
|
||||
import type * as misskey from 'misskey-js';
|
||||
|
||||
// i/move 呼び出しで大部分が同期的に完了する後続ジョブ (フォロー解除/ブロック・ミュート引き継ぎ/リスト更新等) を待つ
|
||||
const waitForMoveJobOptions = { timeout: 5000, interval: 50 };
|
||||
// AccountMoveService がテスト環境向けに 10000ms に短縮している遅延アンフォロージョブを待つ (安全マージンを載せた上限)
|
||||
const waitForDelayedUnfollowJobOptions = { timeout: 15000, interval: 100 };
|
||||
|
||||
describe('Account Move', () => {
|
||||
let jq: INestApplicationContext;
|
||||
let url: URL;
|
||||
@@ -273,53 +277,63 @@ describe('Account Move', () => {
|
||||
|
||||
assert.strictEqual(move.status, 200);
|
||||
|
||||
await setTimeout(1000 * 3); // wait for jobs to finish
|
||||
|
||||
// Unfollow delayed?
|
||||
const aliceFollowings = await api('users/following', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(aliceFollowings.status, 200);
|
||||
assert.ok(aliceFollowings);
|
||||
assert.strictEqual(aliceFollowings.body.length, 3);
|
||||
await vi.waitFor(async () => {
|
||||
const aliceFollowings = await api('users/following', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(aliceFollowings.status, 200);
|
||||
assert.ok(aliceFollowings);
|
||||
assert.strictEqual(aliceFollowings.body.length, 3);
|
||||
}, waitForMoveJobOptions);
|
||||
|
||||
const carolFollowings = await api('users/following', {
|
||||
userId: carol.id,
|
||||
}, carol);
|
||||
assert.strictEqual(carolFollowings.status, 200);
|
||||
assert.ok(carolFollowings);
|
||||
assert.strictEqual(carolFollowings.body.length, 2);
|
||||
assert.strictEqual(carolFollowings.body[0].followeeId, bob.id);
|
||||
assert.strictEqual(carolFollowings.body[1].followeeId, alice.id);
|
||||
await vi.waitFor(async () => {
|
||||
const carolFollowings = await api('users/following', {
|
||||
userId: carol.id,
|
||||
}, carol);
|
||||
assert.strictEqual(carolFollowings.status, 200);
|
||||
assert.ok(carolFollowings);
|
||||
assert.strictEqual(carolFollowings.body.length, 2);
|
||||
assert.strictEqual(carolFollowings.body[0].followeeId, bob.id);
|
||||
assert.strictEqual(carolFollowings.body[1].followeeId, alice.id);
|
||||
}, waitForMoveJobOptions);
|
||||
|
||||
const blockings = await api('blocking/list', {}, dave);
|
||||
assert.strictEqual(blockings.status, 200);
|
||||
assert.ok(blockings);
|
||||
assert.strictEqual(blockings.body.length, 2);
|
||||
assert.strictEqual(blockings.body[0].blockeeId, bob.id);
|
||||
assert.strictEqual(blockings.body[1].blockeeId, alice.id);
|
||||
await vi.waitFor(async () => {
|
||||
const blockings = await api('blocking/list', {}, dave);
|
||||
assert.strictEqual(blockings.status, 200);
|
||||
assert.ok(blockings);
|
||||
assert.strictEqual(blockings.body.length, 2);
|
||||
assert.strictEqual(blockings.body[0].blockeeId, bob.id);
|
||||
assert.strictEqual(blockings.body[1].blockeeId, alice.id);
|
||||
}, waitForMoveJobOptions);
|
||||
|
||||
const mutings = await api('mute/list', {}, dave);
|
||||
assert.strictEqual(mutings.status, 200);
|
||||
assert.ok(mutings);
|
||||
assert.strictEqual(mutings.body.length, 2);
|
||||
assert.strictEqual(mutings.body[0].muteeId, bob.id);
|
||||
assert.strictEqual(mutings.body[1].muteeId, alice.id);
|
||||
await vi.waitFor(async () => {
|
||||
const mutings = await api('mute/list', {}, dave);
|
||||
assert.strictEqual(mutings.status, 200);
|
||||
assert.ok(mutings);
|
||||
assert.strictEqual(mutings.body.length, 2);
|
||||
assert.strictEqual(mutings.body[0].muteeId, bob.id);
|
||||
assert.strictEqual(mutings.body[1].muteeId, alice.id);
|
||||
}, waitForMoveJobOptions);
|
||||
|
||||
const rootLists = await api('users/lists/list', {}, root);
|
||||
assert.strictEqual(rootLists.status, 200);
|
||||
assert.ok(rootLists);
|
||||
assert.ok(rootLists.body[0].userIds);
|
||||
assert.strictEqual(rootLists.body[0].userIds.length, 2);
|
||||
assert.ok(rootLists.body[0].userIds.find((id: string) => id === bob.id));
|
||||
assert.ok(rootLists.body[0].userIds.find((id: string) => id === alice.id));
|
||||
await vi.waitFor(async () => {
|
||||
const rootLists = await api('users/lists/list', {}, root);
|
||||
assert.strictEqual(rootLists.status, 200);
|
||||
assert.ok(rootLists);
|
||||
assert.ok(rootLists.body[0].userIds);
|
||||
assert.strictEqual(rootLists.body[0].userIds.length, 2);
|
||||
assert.ok(rootLists.body[0].userIds.find((id: string) => id === bob.id));
|
||||
assert.ok(rootLists.body[0].userIds.find((id: string) => id === alice.id));
|
||||
}, waitForMoveJobOptions);
|
||||
|
||||
const eveLists = await api('users/lists/list', {}, eve);
|
||||
assert.strictEqual(eveLists.status, 200);
|
||||
assert.ok(eveLists);
|
||||
assert.ok(eveLists.body[0].userIds);
|
||||
assert.strictEqual(eveLists.body[0].userIds.length, 1);
|
||||
assert.ok(eveLists.body[0].userIds.find((id: string) => id === bob.id));
|
||||
await vi.waitFor(async () => {
|
||||
const eveLists = await api('users/lists/list', {}, eve);
|
||||
assert.strictEqual(eveLists.status, 200);
|
||||
assert.ok(eveLists);
|
||||
assert.ok(eveLists.body[0].userIds);
|
||||
assert.strictEqual(eveLists.body[0].userIds.length, 1);
|
||||
assert.ok(eveLists.body[0].userIds.find((id: string) => id === bob.id));
|
||||
}, waitForMoveJobOptions);
|
||||
});
|
||||
|
||||
test('A locked account automatically accept the follow request if it had already accepted the old account.', async () => {
|
||||
@@ -340,14 +354,14 @@ describe('Account Move', () => {
|
||||
});
|
||||
|
||||
test('Unfollowed after 10 sec (24 hours in production).', async () => {
|
||||
await setTimeout(1000 * 8);
|
||||
await vi.waitFor(async () => {
|
||||
const following = await api('users/following', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
|
||||
const following = await api('users/following', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
|
||||
assert.strictEqual(following.status, 200);
|
||||
assert.strictEqual(following.body.length, 0);
|
||||
assert.strictEqual(following.status, 200);
|
||||
assert.strictEqual(following.body.length, 0);
|
||||
}, waitForDelayedUnfollowJobOptions);
|
||||
});
|
||||
|
||||
test('Unable to move if the destination account has already moved.', async () => {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user