Skip to content

Commit 025d292

Browse files
committed
Update smoke test to check both versions
1 parent b151633 commit 025d292

File tree

2 files changed

+67
-40
lines changed

2 files changed

+67
-40
lines changed

smoke-test/smoke-test.cjs

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const { ApolloServer } = require('@apollo/server');
22
const { startStandaloneServer } = require('@apollo/server/standalone');
33
const fetch = require('make-fetch-happen');
44
const assert = require('assert');
5-
const { version: graphqlVersion } = require('graphql');
65

76
async function validateAllImports() {
87
require('@apollo/server');
@@ -50,27 +49,23 @@ async function smokeTest() {
5049
}
5150

5251
if (process.env.INCREMENTAL_DELIVERY_TESTS_ENABLED) {
53-
const specVersion =
54-
graphqlVersion === '17.0.0-alpha.9'
55-
? 'incrementalDeliverySpec=3283f8a'
56-
: 'deferSpec=20220824';
57-
const response = await fetch(url, {
58-
method: 'POST',
59-
headers: {
60-
'content-type': 'application/json',
61-
accept: `multipart/mixed; ${specVersion}, application/json`,
62-
},
63-
body: JSON.stringify({ query: '{h1: hello ...@defer{ h2: hello }}' }),
64-
});
52+
{
53+
const response = await fetch(url, {
54+
method: 'POST',
55+
headers: {
56+
'content-type': 'application/json',
57+
accept: `multipart/mixed; deferSpec=20220824, application/json`,
58+
},
59+
body: JSON.stringify({ query: '{h1: hello ...@defer{ h2: hello }}' }),
60+
});
6561

66-
assert.strictEqual(
67-
response.headers.get('content-type'),
68-
`multipart/mixed; boundary="-"; ${specVersion}`,
69-
);
62+
assert.strictEqual(
63+
response.headers.get('content-type'),
64+
`multipart/mixed; boundary="-"; deferSpec=20220824`,
65+
);
7066

71-
const body = await response.text();
67+
const body = await response.text();
7268

73-
if (graphqlVersion === '17.0.0-alpha.2') {
7469
assert.strictEqual(
7570
body,
7671
'\r\n' +
@@ -84,7 +79,25 @@ async function smokeTest() {
8479
'{"hasNext":false,"incremental":[{"path":[],"data":{"h2":"world"}}]}\r\n' +
8580
'-----\r\n',
8681
);
87-
} else {
82+
}
83+
84+
{
85+
const response = await fetch(url, {
86+
method: 'POST',
87+
headers: {
88+
'content-type': 'application/json',
89+
accept: `multipart/mixed; incrementalDeliverySpec=3283f8a, application/json`,
90+
},
91+
body: JSON.stringify({ query: '{h1: hello ...@defer{ h2: hello }}' }),
92+
});
93+
94+
assert.strictEqual(
95+
response.headers.get('content-type'),
96+
`multipart/mixed; boundary="-"; incrementalDeliverySpec=3283f8a`,
97+
);
98+
99+
const body = await response.text();
100+
88101
assert.strictEqual(
89102
body,
90103
'\r\n' +

smoke-test/smoke-test.mjs

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { ApolloServer } from '@apollo/server';
22
import { startStandaloneServer } from '@apollo/server/standalone';
33
import fetch from 'make-fetch-happen';
44
import assert from 'assert';
5-
import { version as graphqlVersion } from 'graphql';
65

76
// validate all deep imports
87
await import('@apollo/server');
@@ -46,27 +45,23 @@ const { url } = await startStandaloneServer(s, { listen: { port: 0 } });
4645
}
4746

4847
if (process.env.INCREMENTAL_DELIVERY_TESTS_ENABLED) {
49-
const specVersion =
50-
graphqlVersion === '17.0.0-alpha.9'
51-
? 'incrementalDeliverySpec=3283f8a'
52-
: 'deferSpec=20220824';
53-
const response = await fetch(url, {
54-
method: 'POST',
55-
headers: {
56-
'content-type': 'application/json',
57-
accept: `multipart/mixed; ${specVersion}, application/json`,
58-
},
59-
body: JSON.stringify({ query: '{h1: hello ...@defer{ h2: hello }}' }),
60-
});
48+
{
49+
const response = await fetch(url, {
50+
method: 'POST',
51+
headers: {
52+
'content-type': 'application/json',
53+
accept: `multipart/mixed; deferSpec=20220824, application/json`,
54+
},
55+
body: JSON.stringify({ query: '{h1: hello ...@defer{ h2: hello }}' }),
56+
});
6157

62-
assert.strictEqual(
63-
response.headers.get('content-type'),
64-
`multipart/mixed; boundary="-"; ${specVersion}`,
65-
);
58+
assert.strictEqual(
59+
response.headers.get('content-type'),
60+
`multipart/mixed; boundary="-"; deferSpec=20220824`,
61+
);
6662

67-
const body = await response.text();
63+
const body = await response.text();
6864

69-
if (graphqlVersion === '17.0.0-alpha.2') {
7065
assert.strictEqual(
7166
body,
7267
'\r\n' +
@@ -80,7 +75,25 @@ if (process.env.INCREMENTAL_DELIVERY_TESTS_ENABLED) {
8075
'{"hasNext":false,"incremental":[{"path":[],"data":{"h2":"world"}}]}\r\n' +
8176
'-----\r\n',
8277
);
83-
} else {
78+
}
79+
80+
{
81+
const response = await fetch(url, {
82+
method: 'POST',
83+
headers: {
84+
'content-type': 'application/json',
85+
accept: `multipart/mixed; incrementalDeliverySpec=3283f8a, application/json`,
86+
},
87+
body: JSON.stringify({ query: '{h1: hello ...@defer{ h2: hello }}' }),
88+
});
89+
90+
assert.strictEqual(
91+
response.headers.get('content-type'),
92+
`multipart/mixed; boundary="-"; incrementalDeliverySpec=3283f8a`,
93+
);
94+
95+
const body = await response.text();
96+
8497
assert.strictEqual(
8598
body,
8699
'\r\n' +
@@ -96,6 +109,7 @@ if (process.env.INCREMENTAL_DELIVERY_TESTS_ENABLED) {
96109
);
97110
}
98111
}
112+
99113
await s.stop();
100114

101115
console.log('ESM smoke test passed!');

0 commit comments

Comments
 (0)