From 6087d020476762ccdd816d9c74edd977da0615fe Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Sat, 8 Jul 2023 15:40:48 +0200 Subject: [PATCH] adjust tests --- .../src/core/activitypub/models/ApPersonService.ts | 4 ++-- packages/backend/test/misc/mock-resolver.ts | 6 +++++- packages/backend/test/unit/activitypub.ts | 10 +++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index de0e377a70..a20b715d0a 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -642,8 +642,8 @@ export class ApPersonService implements OnModuleInit { await resolver.resolveOrderedCollectionPage(collection.first) : collection; - // Perform activity but only the first 15 ones - await this.apInboxService.performActivity(user, firstPage, 15); + // Perform activity but only the first 20 ones + await this.apInboxService.performActivity(user, firstPage, 20); } @bindThis diff --git a/packages/backend/test/misc/mock-resolver.ts b/packages/backend/test/misc/mock-resolver.ts index a7bcd859ae..8b21d381d3 100644 --- a/packages/backend/test/misc/mock-resolver.ts +++ b/packages/backend/test/misc/mock-resolver.ts @@ -38,13 +38,17 @@ export class MockResolver extends Resolver { ); } - public async _register(uri: string, content: string | Record, type = 'application/activity+json') { + public _register(uri: string, content: string | Record, type = 'application/activity+json') { this._rs.set(uri, { type, content: typeof content === 'string' ? content : JSON.stringify(content), }); } + public clear() { + this._rs.clear(); + } + @bindThis public async resolve(value: string | IObject): Promise { if (typeof value !== 'string') return value; diff --git a/packages/backend/test/unit/activitypub.ts b/packages/backend/test/unit/activitypub.ts index 530b6a9111..a95f0bfa5a 100644 --- a/packages/backend/test/unit/activitypub.ts +++ b/packages/backend/test/unit/activitypub.ts @@ -91,7 +91,7 @@ describe('ActivityPub', () => { let rendererService: ApRendererService; let resolver: MockResolver; - beforeEach(async () => { + beforeAll(async () => { const app = await Test.createTestingModule({ imports: [GlobalModule, CoreModule], }).compile(); @@ -109,6 +109,10 @@ describe('ActivityPub', () => { jest.spyOn(federatedInstanceService, 'fetch').mockImplementation(() => new Promise(() => { })); }); + beforeEach(() => { + resolver.clear(); + }); + describe('Parse minimum object', () => { const actor = createRandomActor(); @@ -227,8 +231,8 @@ describe('ActivityPub', () => { await personService.createPerson(actor.id, resolver); const items = outbox.orderedItems as ICreate[]; - assert.ok(await noteService.fetchNote(items[99].object)); - assert.ok(!await noteService.fetchNote(items[100].object)); + assert.ok(await noteService.fetchNote(items[19].object)); + assert.ok(!await noteService.fetchNote(items[20].object)); }); }); });