-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
257 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,55 @@ | ||
import { createTenv, type Container } from '@e2e/tenv'; | ||
import { createTenv, type Tenv } from '@e2e/tenv'; | ||
|
||
const { compose, service, serve, container } = createTenv(__dirname); | ||
|
||
let petstore!: Container; | ||
beforeAll(async () => { | ||
petstore = await container({ | ||
function createPetstore(tenv: Tenv) { | ||
return tenv.container({ | ||
name: 'petstore', | ||
image: 'swaggerapi/petstore3:1.0.7', | ||
containerPort: 8080, | ||
healthcheck: ['CMD-SHELL', 'wget --spider http://localhost:8080'], | ||
}); | ||
}); | ||
} | ||
|
||
it('should compose the appropriate schema', async () => { | ||
const { result } = await compose({ | ||
services: [petstore, await service('vaccination')], | ||
it.concurrent('should compose the appropriate schema', async () => { | ||
await using tenv = createTenv(__dirname); | ||
await using petstore = await createPetstore(tenv); | ||
await using vaccination = await tenv.service('vaccination'); | ||
const { supergraphSdl: result } = await tenv.compose({ | ||
services: [petstore, vaccination], | ||
maskServicePorts: true, | ||
}); | ||
expect(result).toMatchSnapshot(); | ||
}); | ||
|
||
it.concurrent.each([ | ||
{ | ||
name: 'GetPet', | ||
query: /* GraphQL */ ` | ||
query GetPet { | ||
getPetById(petId: 1) { | ||
__typename | ||
id | ||
name | ||
vaccinated | ||
} | ||
} | ||
`, | ||
}, | ||
])('should execute $name', async ({ query }) => { | ||
const { output } = await compose({ | ||
it.concurrent('should execute GetPet', async () => { | ||
await using tenv = createTenv(__dirname); | ||
await using petstore = await createPetstore(tenv); | ||
await using vaccination = await tenv.service('vaccination'); | ||
await using composition = await tenv.compose({ | ||
output: 'graphql', | ||
services: [petstore, await service('vaccination')], | ||
services: [petstore, vaccination], | ||
}); | ||
await using gw = await tenv.gateway({ supergraph: composition.supergraphPath }); | ||
await expect( | ||
gw.execute({ | ||
query: /* GraphQL */ ` | ||
query GetPet { | ||
getPetById(petId: 1) { | ||
__typename | ||
id | ||
name | ||
vaccinated | ||
} | ||
} | ||
`, | ||
}), | ||
).resolves.toMatchObject({ | ||
data: { | ||
getPetById: { | ||
__typename: 'Pet', | ||
id: 1, | ||
name: 'Cat 1', | ||
vaccinated: false, | ||
}, | ||
}, | ||
}); | ||
const { execute } = await serve({ supergraph: output }); | ||
await expect(execute({ query })).resolves.toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { createTenv } from '@e2e/tenv'; | ||
import { fetch } from '@whatwg-node/fetch'; | ||
|
||
const { serve, compose, fs } = createTenv(__dirname); | ||
|
||
it('should serve', async () => { | ||
const proc = await serve({ | ||
supergraph: await fs.tempfile('supergraph.graphql', 'type Query { hello: String }'), | ||
it.concurrent('should serve', async () => { | ||
await using tenv = createTenv(__dirname); | ||
await using proc = await tenv.gateway({ | ||
supergraph: await tenv.fs.tempfile('supergraph.graphql', 'type Query { hello: String }'), | ||
}); | ||
const res = await fetch(`http://${proc.hostname}:${proc.port}/healthcheck`); | ||
expect(res.ok).toBeTruthy(); | ||
}); | ||
|
||
it('should compose', async () => { | ||
const proc = await compose(); | ||
expect(proc.result).toMatchSnapshot(); | ||
it.concurrent('should compose', async () => { | ||
await using tenv = createTenv(__dirname); | ||
await using proc = await tenv.compose(); | ||
expect(proc.supergraphSdl).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,11 @@ | ||
import { createTenv } from '@e2e/tenv'; | ||
|
||
const { compose, fs } = createTenv(__dirname); | ||
|
||
it('should write compose output to supergraph.graphql', async () => { | ||
const { output } = await compose({ output: 'graphql' }); | ||
await expect(fs.read(output)).resolves.toMatchSnapshot(); | ||
}); | ||
|
||
it('should write compose output to supergraph.json', async () => { | ||
const { output } = await compose({ output: 'json' }); | ||
await expect(fs.read(output)).resolves.toMatchSnapshot(); | ||
}); | ||
|
||
it('should write compose output to supergraph.js', async () => { | ||
const { output } = await compose({ output: 'js' }); | ||
await expect(fs.read(output)).resolves.toMatchSnapshot(); | ||
}); | ||
|
||
it('should write compose output to supergraph.ts', async () => { | ||
const { output } = await compose({ output: 'ts' }); | ||
await expect(fs.read(output)).resolves.toMatchSnapshot(); | ||
}); | ||
const outputTypes = ['graphql', 'json', 'js', 'ts'] as const; | ||
|
||
for (const output of outputTypes) { | ||
it.concurrent(`should write compose output to supergraph.${output}`, async () => { | ||
await using tenv = createTenv(__dirname); | ||
await using composition = await tenv.compose({ output }); | ||
await expect(tenv.fs.read(composition.supergraphPath)).resolves.toMatchSnapshot(); | ||
}); | ||
} |
18 changes: 9 additions & 9 deletions
18
e2e/esm-config-in-cjs-project/esm-config-in-cjs-project.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { createTenv } from '@e2e/tenv'; | ||
import { fetch } from '@whatwg-node/fetch'; | ||
|
||
const { serve, compose, fs } = createTenv(__dirname); | ||
|
||
it('should serve', async () => { | ||
const proc = await serve({ | ||
supergraph: await fs.tempfile('supergraph.graphql', 'type Query { hello: String }'), | ||
it.concurrent('should serve', async () => { | ||
await using tenv = createTenv(__dirname); | ||
await using gw = await tenv.gateway({ | ||
supergraph: await tenv.fs.tempfile('supergraph.graphql', 'type Query { hello: String }'), | ||
}); | ||
const res = await fetch(`http://${proc.hostname}:${proc.port}/healthcheck`); | ||
const res = await fetch(`http://${gw.hostname}:${gw.port}/healthcheck`); | ||
expect(res.ok).toBeTruthy(); | ||
}); | ||
|
||
it('should compose', async () => { | ||
const proc = await compose(); | ||
expect(proc.result).toMatchSnapshot(); | ||
it.concurrent('should compose', async () => { | ||
await using tenv = createTenv(__dirname); | ||
await using proc = await tenv.compose(); | ||
expect(proc.supergraphSdl).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { createTenv } from '@e2e/tenv'; | ||
import { fetch } from '@whatwg-node/fetch'; | ||
|
||
const { serve, compose, fs } = createTenv(__dirname); | ||
|
||
it('should serve', async () => { | ||
const proc = await serve({ | ||
supergraph: await fs.tempfile('supergraph.graphql', 'type Query { hello: String }'), | ||
it.concurrent('should serve', async () => { | ||
await using tenv = createTenv(__dirname); | ||
await using gw = await tenv.gateway({ | ||
supergraph: await tenv.fs.tempfile('supergraph.graphql', 'type Query { hello: String }'), | ||
}); | ||
const res = await fetch(`http://${proc.hostname}:${proc.port}/healthcheck`); | ||
const res = await fetch(`http://${gw.hostname}:${gw.port}/healthcheck`); | ||
expect(res.ok).toBeTruthy(); | ||
}); | ||
|
||
it('should compose', async () => { | ||
const proc = await compose(); | ||
expect(proc.result).toMatchSnapshot(); | ||
it.concurrent('should compose', async () => { | ||
await using tenv = createTenv(__dirname); | ||
await using composition = await tenv.compose(); | ||
expect(composition.supergraphSdl).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.