test: group actor assertion tests

This commit is contained in:
Julian Lam
2025-03-17 11:44:32 -04:00
parent 0fa98237af
commit ca9a5b6dfb
3 changed files with 43 additions and 2 deletions

View File

@@ -13,6 +13,8 @@ const utils = require('../../src/utils');
const request = require('../../src/request');
const slugify = require('../../src/slugify');
const helpers = require('./helpers');
describe('Actor asserton', () => {
describe('happy path', () => {
let uid;
@@ -90,6 +92,38 @@ describe('Actor asserton', () => {
});
});
describe.only('Group assertion', () => {
let actorUri;
before(async () => {
const { id, actor } = helpers.mocks.group();
actorUri = id;
activitypub._cache.set(`0;${id}`, actor);
});
it('should assert a uri identifying as "Group" into a remote category', async () => {
const assertion = await activitypub.actors.assertGroup([actorUri]);
assert(assertion, Array.isArray(assertion));
assert.strictEqual(assertion.length, 1);
const category = assertion.pop();
assert.strictEqual(category.cid, actorUri);
});
it('should be considered existing when checked', async () => {
const exists = await categories.exists(actorUri);
assert(exists);
});
it('should return category data when getter methods are called', async () => {
const category = await categories.getCategoryData(actorUri);
assert(category);
assert.strictEqual(category.cid, actorUri);
});
});
describe('Controllers', () => {
describe('User Actor endpoint', () => {
let uid;

View File

@@ -37,7 +37,7 @@ describe('FEPs', () => {
await groups.join('administrators', adminUid);
uid = await user.create({ username: utils.generateUUID() });
const { id: followerId, actor } = helpers.mocks.actor();
const { id: followerId, actor } = helpers.mocks.person();
activitypub._cache.set(`0;${followerId}`, actor);
user.setCategoryWatchState(followerId, [cid], categories.watchStates.tracking);

View File

@@ -8,7 +8,7 @@ const Helpers = module.exports;
Helpers.mocks = {};
Helpers.mocks.actor = () => {
Helpers.mocks.person = () => {
const baseUrl = 'https://example.org';
const uuid = utils.generateUUID();
const id = `${baseUrl}/${uuid}`;
@@ -37,6 +37,13 @@ Helpers.mocks.actor = () => {
return { id, actor };
};
Helpers.mocks.group = () => {
const { id, actor } = Helpers.mocks.person();
actor.type = 'Group';
return { id, actor };
};
Helpers.mocks.note = (override = {}) => {
const baseUrl = 'https://example.org';
const uuid = utils.generateUUID();