Skip to content

Commit b80d75e

Browse files
committed
test: missing client info
1 parent 829df31 commit b80d75e

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

packages/libraries/yoga/tests/yoga.spec.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -372,22 +372,16 @@ test('reports usage', async ({ expect }) => {
372372

373373
test('reports usage with response cache', async ({ expect }) => {
374374
let usageCount = 0;
375+
const results: Array<Record<string, any>> = [];
375376
const graphqlScope = nock('http://localhost')
376377
.post('/usage', body => {
377378
usageCount++;
378-
379-
expect(body.map).toEqual({
380-
f25063b60ab942d0c0d14cdd9cd3172de2e7ebc4: {
381-
fields: ['Query.hi'],
382-
operation: '{hi}',
383-
operationName: 'anonymous',
384-
},
385-
});
386-
379+
results.push(body);
387380
return true;
388381
})
389382
.thrice()
390383
.reply(200);
384+
391385
const yoga = createYoga({
392386
schema: createSchema({
393387
typeDefs: /* GraphQL */ `
@@ -458,6 +452,23 @@ test('reports usage with response cache', async ({ expect }) => {
458452
});
459453
graphqlScope.done();
460454
expect(usageCount).toBe(3);
455+
456+
for (const body of results) {
457+
expect(body.operations[0].metadata).toEqual({
458+
client: {
459+
name: 'brrr',
460+
version: '1',
461+
},
462+
});
463+
464+
expect(body.map).toEqual({
465+
f25063b60ab942d0c0d14cdd9cd3172de2e7ebc4: {
466+
fields: ['Query.hi'],
467+
operation: '{hi}',
468+
operationName: 'anonymous',
469+
},
470+
});
471+
}
461472
});
462473

463474
test('does not report usage for operation that does not pass validation', async ({ expect }) => {
@@ -1107,10 +1118,10 @@ describe('subscription usage reporting', () => {
11071118
expect(res.status).toBe(200);
11081119
expect(await res.text()).toMatchInlineSnapshot(`
11091120
:
1110-
1121+
11111122
event: next
11121123
data: {"errors":[{"message":"Unexpected error.","locations":[{"line":1,"column":1}],"extensions":{"unexpected":true}}]}
1113-
1124+
11141125
event: complete
11151126
data:
11161127
`);

0 commit comments

Comments
 (0)