mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +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 request = require('../../src/request'); | ||||||
| const slugify = require('../../src/slugify'); | const slugify = require('../../src/slugify'); | ||||||
|  |  | ||||||
|  | const helpers = require('./helpers'); | ||||||
|  |  | ||||||
| describe('Actor asserton', () => { | describe('Actor asserton', () => { | ||||||
| 	describe('happy path', () => { | 	describe('happy path', () => { | ||||||
| 		let uid; | 		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('Controllers', () => { | ||||||
| 	describe('User Actor endpoint', () => { | 	describe('User Actor endpoint', () => { | ||||||
| 		let uid; | 		let uid; | ||||||
|   | |||||||
| @@ -37,7 +37,7 @@ describe('FEPs', () => { | |||||||
| 				await groups.join('administrators', adminUid); | 				await groups.join('administrators', adminUid); | ||||||
| 				uid = await user.create({ username: utils.generateUUID() }); | 				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); | 				activitypub._cache.set(`0;${followerId}`, actor); | ||||||
| 				user.setCategoryWatchState(followerId, [cid], categories.watchStates.tracking); | 				user.setCategoryWatchState(followerId, [cid], categories.watchStates.tracking); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ const Helpers = module.exports; | |||||||
|  |  | ||||||
| Helpers.mocks = {}; | Helpers.mocks = {}; | ||||||
|  |  | ||||||
| Helpers.mocks.actor = () => { | Helpers.mocks.person = () => { | ||||||
| 	const baseUrl = 'https://example.org'; | 	const baseUrl = 'https://example.org'; | ||||||
| 	const uuid = utils.generateUUID(); | 	const uuid = utils.generateUUID(); | ||||||
| 	const id = `${baseUrl}/${uuid}`; | 	const id = `${baseUrl}/${uuid}`; | ||||||
| @@ -37,6 +37,13 @@ Helpers.mocks.actor = () => { | |||||||
| 	return { id, actor }; | 	return { id, actor }; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | Helpers.mocks.group = () => { | ||||||
|  | 	const { id, actor } = Helpers.mocks.person(); | ||||||
|  | 	actor.type = 'Group'; | ||||||
|  |  | ||||||
|  | 	return { id, actor }; | ||||||
|  | }; | ||||||
|  |  | ||||||
| Helpers.mocks.note = (override = {}) => { | Helpers.mocks.note = (override = {}) => { | ||||||
| 	const baseUrl = 'https://example.org'; | 	const baseUrl = 'https://example.org'; | ||||||
| 	const uuid = utils.generateUUID(); | 	const uuid = utils.generateUUID(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user