Skip to content

Commit

Permalink
update test to include check for no duplicate missing references
Browse files Browse the repository at this point in the history
  • Loading branch information
SiddharthMantri committed Nov 18, 2024
1 parent 5544b88 commit 5d17ff3
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,36 @@ describe('validateReferences()', () => {
'Error fetching references for imported objects'
);
});

// test that when references are missing returns only deduplicated errors
test('returns only deduplicated errors when references are missing', async () => {
const params = setup({
objects: [
{
id: '2',
type: 'visualization',
attributes: { title: 'My Visualization 2' },
references: [
{ name: 'ref_0', type: 'index-pattern', id: '3' },
{ name: 'ref_0', type: 'index-pattern', id: '3' },
],
},
],
});
params.savedObjectsClient.bulkGet.mockResolvedValue({
saved_objects: [createNotFoundError({ type: 'index-pattern', id: '3' })],
});

const result = await validateReferences(params);
expect(result).toEqual([
expect.objectContaining({
type: 'visualization',
id: '2',
error: {
type: 'missing_references',
references: [{ type: 'index-pattern', id: '3' }],
},
}),
]);
});
});

0 comments on commit 5d17ff3

Please sign in to comment.