Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for the clearer errors when a reference is not found
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
var { CloudContext } = require('./utils'); | ||
var randUserId = require('../utils/hooks').randUserId; | ||
|
||
describe('Enriching not existing references', () => { | ||
let ctx = new CloudContext(); | ||
let zeroUUID = '00000000-0000-0000-0000-000000000000'; | ||
(ctx.cheeseBurger = ctx.alice | ||
.storage('food') | ||
.object(randUserId('cheeseburger'), ctx.cheeseBurgerData)), | ||
describe('When alice eats a cheese burger without adding it to collections', () => { | ||
ctx.requestShouldNotError(async () => { | ||
ctx.response = await ctx.alice.feed('user').addActivity({ | ||
actor: ctx.alice.user, | ||
verb: 'eat', | ||
object: ctx.cheeseBurger, | ||
notExistingActivity: `SA:${zeroUUID}`, | ||
notExistingReaction: `SR:${zeroUUID}`, | ||
}); | ||
}); | ||
describe('and then alice reads her feed', () => { | ||
ctx.requestShouldNotError(async () => { | ||
ctx.response = await ctx.alice.feed('user').get(); | ||
}); | ||
|
||
ctx.responseShouldHaveActivityWithFields( | ||
'notExistingActivity', | ||
'notExistingReaction', | ||
); | ||
ctx.responseShould( | ||
'have the activity with errors in place of references', | ||
() => { | ||
ctx.activity.verb.should.eql('eat'); | ||
ctx.activity.actor.should.eql({ | ||
error: 'ReferenceNotFound', | ||
reference: ctx.alice.user._streamRef(), | ||
reference_type: 'user', | ||
id: ctx.alice.user.id, | ||
}); | ||
ctx.activity.object.should.eql({ | ||
collection: 'food', | ||
id: ctx.cheeseBurger.id, | ||
error: 'ReferenceNotFound', | ||
reference: ctx.cheeseBurger._streamRef(), | ||
reference_type: 'object', | ||
}); | ||
ctx.activity.notExistingActivity.should.eql({ | ||
id: zeroUUID, | ||
error: 'ReferenceNotFound', | ||
reference: `SA:${zeroUUID}`, | ||
reference_type: 'activity', | ||
}); | ||
ctx.activity.notExistingReaction.should.eql({ | ||
id: zeroUUID, | ||
error: 'ReferenceNotFound', | ||
reference: `SR:${zeroUUID}`, | ||
reference_type: 'reaction', | ||
}); | ||
}, | ||
); | ||
}); | ||
}); | ||
}); |