|
2 | 2 | import { createHash } from 'node:crypto';
|
3 | 3 | import { ProjectType } from 'testkit/gql/graphql';
|
4 | 4 | import * as GraphQLSchema from 'testkit/gql/graphql';
|
| 5 | +import type { CompositeSchema } from '@hive/api/__generated__/types'; |
5 | 6 | import { createCLI, schemaCheck, schemaPublish } from '../../testkit/cli';
|
6 | 7 | import { cliOutputSnapshotSerializer } from '../../testkit/cli-snapshot-serializer';
|
7 | 8 | import { initSeed } from '../../testkit/seed';
|
@@ -423,25 +424,45 @@ describe.each([ProjectType.Stitching, ProjectType.Federation, ProjectType.Single
|
423 | 424 | }),
|
424 | 425 | ).resolves.toMatchSnapshot('schema publish initial');
|
425 | 426 |
|
| 427 | + const sdl2 = /* GraphQL */ ` |
| 428 | + type Query { |
| 429 | + users: [User!] |
| 430 | + } |
| 431 | +
|
| 432 | + type User { |
| 433 | + id: ID! |
| 434 | + name: String! |
| 435 | + email: String! |
| 436 | + phone: String |
| 437 | + } |
| 438 | + `; |
| 439 | + |
426 | 440 | await expect(
|
427 | 441 | cli.publish({
|
428 |
| - sdl, |
| 442 | + sdl: sdl2, |
429 | 443 | commit: 'push2',
|
430 | 444 | serviceName,
|
431 |
| - expect: 'ignored', |
| 445 | + serviceUrl: undefined, |
| 446 | + expect: 'latest-composable', |
432 | 447 | }),
|
433 | 448 | ).resolves.toMatchSnapshot('schema publish same url');
|
434 | 449 |
|
435 | 450 | const versions = await fetchVersions(3);
|
436 |
| - expect(versions).toHaveLength(1); |
| 451 | + expect(versions).toHaveLength(2); |
437 | 452 |
|
438 | 453 | const versionWithNewServiceUrl = versions[0];
|
439 | 454 |
|
| 455 | + const schema = versionWithNewServiceUrl.schemas.nodes?.[0]; |
| 456 | + expect(schema.__typename).toBe('CompositeSchema'); |
| 457 | + expect((schema as CompositeSchema).url).toBe('http://localhost:4000'); |
| 458 | + |
440 | 459 | expect(await compareToPreviousVersion(versionWithNewServiceUrl.id)).toEqual(
|
441 | 460 | expect.objectContaining({
|
442 | 461 | target: expect.objectContaining({
|
443 | 462 | schemaVersion: expect.objectContaining({
|
444 |
| - safeSchemaChanges: null, |
| 463 | + safeSchemaChanges: { |
| 464 | + nodes: expect.anything(), |
| 465 | + }, |
445 | 466 | schemaCompositionErrors: null,
|
446 | 467 | }),
|
447 | 468 | }),
|
|
0 commit comments