mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
test: group actor assertion tests
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user