Repository: cloudflare/wildebeest
File: backend/test/activitypub.spec.ts (TypeScript)

Code before:
		test("doesn't show private notes to anyone", async () => {
			const db = await makeDB()
			const actorA = await createPerson(domain, db, userKEK, 'a@cloudflare.com')
			const actorB = await createPerson(domain, db, userKEK, 'b@cloudflare.com')

			const note = await createPrivateNote(domain, db, 'DM', actorA, actorB)
			await addObjectInOutbox(db, actorA, note, undefined, actorB.id.toString())

			{
				const res = await ap_outbox_page.handleRequest(domain, db, 'a')
				assert.equal(res.status, 200)

				const data = await res.json<any>()
				assert.equal(data.orderedItems.length, 0)
			}

			{
				const res = await ap_outbox_page.handleRequest(domain, db, 'b')
				assert.equal(res.status, 200)

				const data = await res.json<any>()
				assert.equal(data.orderedItems.length, 0)
			}
		})

		test("should show private notes to target but doesn't yet", async () => {
			const db = await makeDB()
			const actorA = await createPerson(domain, db, userKEK, 'a@cloudflare.com')
			const actorB = await createPerson(domain, db, userKEK, 'target@cloudflare.com')

			const note = await createPrivateNote(domain, db, 'DM', actorA, actorB)
			await addObjectInOutbox(db, actorA, note)

			const res = await ap_outbox_page.handleRequest(domain, db, 'target')
			assert.equal(res.status, 200)

			const data = await res.json<any>()
			assert.equal(data.orderedItems.length, 0)
		})
	})

	describe('Objects', () => {
		test('cacheObject deduplicates object', async () => {
			const db = await makeDB()
			const properties = { type: 'Note', a: 1, b: 2 }
			const actor = await createPerson(domain, db, userKEK, 'a@cloudflare.com')
			const originalObjectId = new URL('https://example.com/object1')

			let result: any

			// Cache object once adds it to the database

Review comment (suggestion):
```suggestion
		test("doesn't show private note in target outbox", async () => {
```

Code after:
		test("doesn't show private notes to anyone", async () => {
			const db = await makeDB()
			const actorA = await createPerson(domain, db, userKEK, 'a@cloudflare.com')
			const actorB = await createPerson(domain, db, userKEK, 'b@cloudflare.com')

			const note = await createPrivateNote(domain, db, 'DM', actorA, actorB)
			await addObjectInOutbox(db, actorA, note, undefined, actorB.id.toString())

			{
				const res = await ap_outbox_page.handleRequest(domain, db, 'a')
				assert.equal(res.status, 200)

				const data = await res.json<any>()
				assert.equal(data.orderedItems.length, 0)
			}

			{
				const res = await ap_outbox_page.handleRequest(domain, db, 'b')
				assert.equal(res.status, 200)

				const data = await res.json<any>()
				assert.equal(data.orderedItems.length, 0)
			}
		})

		test("doesn't show private note in target outbox", async () => {
			const db = await makeDB()
			const actorA = await createPerson(domain, db, userKEK, 'a@cloudflare.com')
			const actorB = await createPerson(domain, db, userKEK, 'target@cloudflare.com')

			const note = await createPrivateNote(domain, db, 'DM', actorA, actorB)
			await addObjectInOutbox(db, actorA, note)

			const res = await ap_outbox_page.handleRequest(domain, db, 'target')
			assert.equal(res.status, 200)

			const data = await res.json<any>()
			assert.equal(data.orderedItems.length, 0)
		})
	})

	describe('Objects', () => {
		test('cacheObject deduplicates object', async () => {
			const db = await makeDB()
			const properties = { type: 'Note', a: 1, b: 2 }
			const actor = await createPerson(domain, db, userKEK, 'a@cloudflare.com')
			const originalObjectId = new URL('https://example.com/object1')

			let result: any

			// Cache object once adds it to the database