Files
suaveplan/e2e/foundation-stack-engines/tests/engines-coexist.spec.ts
2026-05-27 23:29:53 +01:00

60 lines
1.8 KiB
TypeScript

import { expect, test } from "@playwright/test";
/**
* Stage-7 closure smoke — proves that the four Stage-7 engines
* (`api-graphql-yoga`, `api-graphql-apollo`, `api-ws-bun`,
* `api-sse-bun`) coexist on a single Bun.serve host without route
* collision, and that GraphQL federation across two plugins works
* identically through both engines.
*/
const FED_QUERY = `
query Federated {
pluginA
pluginB
bothA
bothB
}
`;
interface GraphqlResponse {
readonly data?: Record<string, unknown> | null;
readonly errors?: ReadonlyArray<{ readonly message: string }>;
}
test.describe("foundation-stack-engines — Stage-7 coexistence", () => {
test("1. yoga federates GraphQL across plugin-a + plugin-b", async ({
request,
}) => {
const res = await request.post("/graphql/yoga", {
data: { query: FED_QUERY, operationName: "Federated" },
});
expect(res.status()).toBe(200);
const body = (await res.json()) as GraphqlResponse;
expect(body.errors).toBeUndefined();
expect(body.data).toEqual({
pluginA: "from plugin-a",
pluginB: "from plugin-b",
bothA: "A-half-of-both",
bothB: "B-half-of-both",
});
});
test("2. apollo federates the same SDL across plugin-a + plugin-b", async ({
request,
}) => {
const res = await request.post("/graphql/apollo", {
data: { query: FED_QUERY, operationName: "Federated" },
});
expect(res.status()).toBe(200);
const body = (await res.json()) as GraphqlResponse;
expect(body.errors).toBeUndefined();
expect(body.data).toEqual({
pluginA: "from plugin-a",
pluginB: "from plugin-b",
bothA: "A-half-of-both",
bothB: "B-half-of-both",
});
});
});