mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
Fix test
This commit is contained in:
@@ -6,29 +6,27 @@ describe('GraphQL processError util', () => {
|
||||
const sampleError = new GraphQLError('An error message', { path: ['test_collection'] });
|
||||
const redactedError = {
|
||||
message: 'An unexpected error occurred.',
|
||||
locations: undefined,
|
||||
extensions: {
|
||||
code: 'INTERNAL_SERVER_ERROR',
|
||||
},
|
||||
};
|
||||
|
||||
test('returns redacted error when unauthenticated', () => {
|
||||
expect(processError(null, sampleError)).toEqual(expect.objectContaining(redactedError));
|
||||
expect(processError(null, sampleError)).toEqual(redactedError);
|
||||
});
|
||||
|
||||
test('returns redacted error when authenticated but not an admin', () => {
|
||||
expect(processError({ role: 'd674e22b-f405-48ba-9958-9a7bd16a1aa9' }, sampleError)).toEqual(
|
||||
expect.objectContaining(redactedError)
|
||||
);
|
||||
expect(processError({ role: 'd674e22b-f405-48ba-9958-9a7bd16a1aa9' }, sampleError)).toEqual(redactedError);
|
||||
});
|
||||
|
||||
test('returns original error when authenticated and is an admin', () => {
|
||||
expect(processError({ role: 'd674e22b-f405-48ba-9958-9a7bd16a1aa9', admin: true }, sampleError)).toEqual(
|
||||
expect.objectContaining({
|
||||
...sampleError,
|
||||
extensions: {
|
||||
code: 'INTERNAL_SERVER_ERROR',
|
||||
},
|
||||
})
|
||||
);
|
||||
expect(processError({ role: 'd674e22b-f405-48ba-9958-9a7bd16a1aa9', admin: true }, sampleError)).toEqual({
|
||||
message: 'An error message',
|
||||
path: ['test_collection'],
|
||||
extensions: {
|
||||
code: 'INTERNAL_SERVER_ERROR',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user