|
@@ -182,9 +182,10 @@ describe('Request entry', function () {
|
|
|
).toBeInTheDocument(); // tooltip description
|
|
|
});
|
|
|
|
|
|
- describe('getBodySection', function () {
|
|
|
+ describe('body section', function () {
|
|
|
it('should return plain-text when given unrecognized inferred Content-Type', function () {
|
|
|
const data: EntryRequest['data'] = {
|
|
|
+ apiTarget: null,
|
|
|
query: [],
|
|
|
data: 'helloworld',
|
|
|
headers: [],
|
|
@@ -219,6 +220,7 @@ describe('Request entry', function () {
|
|
|
|
|
|
it('should return a KeyValueList element when inferred Content-Type is x-www-form-urlencoded', function () {
|
|
|
const data: EntryRequest['data'] = {
|
|
|
+ apiTarget: null,
|
|
|
query: [],
|
|
|
data: {foo: ['bar'], bar: ['baz']},
|
|
|
headers: [],
|
|
@@ -253,6 +255,7 @@ describe('Request entry', function () {
|
|
|
|
|
|
it('should return a ContextData element when inferred Content-Type is application/json', function () {
|
|
|
const data: EntryRequest['data'] = {
|
|
|
+ apiTarget: null,
|
|
|
query: [],
|
|
|
data: {foo: 'bar'},
|
|
|
headers: [],
|
|
@@ -289,6 +292,7 @@ describe('Request entry', function () {
|
|
|
// > decodeURIComponent('a%AFc')
|
|
|
// URIError: URI malformed
|
|
|
const data: EntryRequest['data'] = {
|
|
|
+ apiTarget: null,
|
|
|
query: 'a%AFc',
|
|
|
data: '',
|
|
|
headers: [],
|
|
@@ -320,6 +324,7 @@ describe('Request entry', function () {
|
|
|
|
|
|
it("should not cause an invariant violation if data.data isn't a string", function () {
|
|
|
const data: EntryRequest['data'] = {
|
|
|
+ apiTarget: null,
|
|
|
query: [],
|
|
|
data: [{foo: 'bar', baz: 1}],
|
|
|
headers: [],
|
|
@@ -348,5 +353,71 @@ describe('Request entry', function () {
|
|
|
})
|
|
|
).not.toThrow();
|
|
|
});
|
|
|
+
|
|
|
+ describe('graphql', function () {
|
|
|
+ it('should render a graphql query and variables', function () {
|
|
|
+ const data: EntryRequest['data'] = {
|
|
|
+ apiTarget: 'graphql',
|
|
|
+ method: 'POST',
|
|
|
+ url: '/graphql/',
|
|
|
+ data: {
|
|
|
+ query: 'query Test { test }',
|
|
|
+ variables: {foo: 'bar'},
|
|
|
+ operationName: 'Test',
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ const event = {
|
|
|
+ ...TestStubs.Event(),
|
|
|
+ entries: [
|
|
|
+ {
|
|
|
+ type: EntryType.REQUEST,
|
|
|
+ data,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+
|
|
|
+ render(<Request event={event} data={event.entries[0].data} />);
|
|
|
+
|
|
|
+ expect(screen.getByText('query Test { test }')).toBeInTheDocument();
|
|
|
+ expect(screen.getByRole('row', {name: 'operationName Test'})).toBeInTheDocument();
|
|
|
+ expect(
|
|
|
+ screen.getByRole('row', {name: 'variables { foo : bar }'})
|
|
|
+ ).toBeInTheDocument();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('highlights graphql query lines with errors', function () {
|
|
|
+ const data: EntryRequest['data'] = {
|
|
|
+ apiTarget: 'graphql',
|
|
|
+ method: 'POST',
|
|
|
+ url: '/graphql/',
|
|
|
+ data: {
|
|
|
+ query: 'query Test { test }',
|
|
|
+ variables: {foo: 'bar'},
|
|
|
+ operationName: 'Test',
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ const event = {
|
|
|
+ ...TestStubs.Event(),
|
|
|
+ entries: [
|
|
|
+ {
|
|
|
+ type: EntryType.REQUEST,
|
|
|
+ data,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ contexts: {response: {data: {errors: [{locations: [{line: 1}]}]}}},
|
|
|
+ };
|
|
|
+
|
|
|
+ const {container} = render(
|
|
|
+ <Request event={event} data={event.entries[0].data} />
|
|
|
+ );
|
|
|
+
|
|
|
+ expect(container.querySelector('.line-highlight')).toBeInTheDocument();
|
|
|
+ expect(
|
|
|
+ container.querySelector('.line-highlight')?.getAttribute('data-start')
|
|
|
+ ).toBe('1');
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
});
|