fix unit test
This commit is contained in:
parent
9c04952ebc
commit
1cc6159442
|
|
@ -73,7 +73,7 @@ export class UserSuspendService {
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
await this.postUnsuspend(user, false).catch((e: any) => { });
|
await this.postUnsuspend(user, false).catch((e: any) => { });
|
||||||
await this.restoreFollowings(user).catch((e: any) => { });
|
await this.restoreFollowings(user).catch((e: any) => { console.error(e); });
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import { AccountUpdateService } from '@/core/AccountUpdateService.js';
|
||||||
import { ApDeliverManagerService } from '@/core/activitypub/ApDeliverManagerService.js';
|
import { ApDeliverManagerService } from '@/core/activitypub/ApDeliverManagerService.js';
|
||||||
import { RelayService } from '@/core/RelayService.js';
|
import { RelayService } from '@/core/RelayService.js';
|
||||||
import { ApLoggerService } from '@/core/activitypub/ApLoggerService.js';
|
import { ApLoggerService } from '@/core/activitypub/ApLoggerService.js';
|
||||||
|
import { MiRemoteUser } from '@/models/User.js';
|
||||||
|
|
||||||
function genHost() {
|
function genHost() {
|
||||||
return randomString() + '.example.com';
|
return randomString() + '.example.com';
|
||||||
|
|
@ -96,6 +97,7 @@ describe('UserSuspendService', () => {
|
||||||
useFactory: () => ({
|
useFactory: () => ({
|
||||||
isLocalUser: jest.fn(),
|
isLocalUser: jest.fn(),
|
||||||
genLocalUserUri: jest.fn(),
|
genLocalUserUri: jest.fn(),
|
||||||
|
isSuspendedEither: jest.fn(),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -244,6 +246,8 @@ describe('UserSuspendService', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should restore follower relationships', async () => {
|
test('should restore follower relationships', async () => {
|
||||||
|
userEntityService.isSuspendedEither.mockReturnValue(false);
|
||||||
|
|
||||||
const user = await createUser({ isSuspended: true });
|
const user = await createUser({ isSuspended: true });
|
||||||
const followee1 = await createUser();
|
const followee1 = await createUser();
|
||||||
const followee2 = await createUser();
|
const followee2 = await createUser();
|
||||||
|
|
@ -286,6 +290,8 @@ describe('UserSuspendService', () => {
|
||||||
|
|
||||||
describe('integration test: suspend and unsuspend cycle', () => {
|
describe('integration test: suspend and unsuspend cycle', () => {
|
||||||
test('should preserve follow relationships through suspend/unsuspend cycle', async () => {
|
test('should preserve follow relationships through suspend/unsuspend cycle', async () => {
|
||||||
|
userEntityService.isSuspendedEither.mockReturnValue(false);
|
||||||
|
|
||||||
const user = await createUser();
|
const user = await createUser();
|
||||||
const followee1 = await createUser();
|
const followee1 = await createUser();
|
||||||
const followee2 = await createUser();
|
const followee2 = await createUser();
|
||||||
|
|
@ -441,7 +447,7 @@ describe('UserSuspendService', () => {
|
||||||
|
|
||||||
describe('suspension from remote', () => {
|
describe('suspension from remote', () => {
|
||||||
test('should suspend remote user and post suspend event', async () => {
|
test('should suspend remote user and post suspend event', async () => {
|
||||||
const remoteUser = { id: secureRndstr(16), host: genHost() };
|
const remoteUser = await createUser({ host: genHost() }) as MiRemoteUser;
|
||||||
await userSuspendService.suspendFromRemote(remoteUser);
|
await userSuspendService.suspendFromRemote(remoteUser);
|
||||||
|
|
||||||
// ユーザーがリモート凍結されているかチェック
|
// ユーザーがリモート凍結されているかチェック
|
||||||
|
|
@ -456,7 +462,7 @@ describe('UserSuspendService', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should unsuspend remote user and post unsuspend event', async () => {
|
test('should unsuspend remote user and post unsuspend event', async () => {
|
||||||
const remoteUser = { id: secureRndstr(16), host: genHost() };
|
const remoteUser = await createUser({ host: genHost(), isRemoteSuspended: true }) as MiRemoteUser;
|
||||||
await userSuspendService.unsuspendFromRemote(remoteUser);
|
await userSuspendService.unsuspendFromRemote(remoteUser);
|
||||||
|
|
||||||
// ユーザーのリモート凍結が解除されているかチェック
|
// ユーザーのリモート凍結が解除されているかチェック
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue