Skip to content

Commit

Permalink
Test for the clearer errors when a reference is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF committed Oct 11, 2018
1 parent 36f85d6 commit 1a479a1
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions test/integration/cloud/not_found_enrichment.js
@@ -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',
});
},
);
});
});
});

0 comments on commit 1a479a1

Please sign in to comment.