Skip to content

Commit fd7829c

Browse files
authored
test: retain service on next schema if url if not in input (#6697)
1 parent b945fd4 commit fd7829c

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

integration-tests/tests/cli/__snapshots__/schema.spec.ts.snap

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ stdout--------------------------------------------:
8484
ℹ Available at http://__URL__
8585
`;
8686

87-
exports[`FEDERATION > can update a service without providing a url if previously published > schema publish same url 1`] = ``;
87+
exports[`FEDERATION > can update a service without providing a url if previously published > schema publish same url 1`] = `
88+
:::::::::::::::: CLI SUCCESS OUTPUT :::::::::::::::::
89+
90+
stdout--------------------------------------------:
91+
✔ Schema published
92+
ℹ Available at http://__URL__
93+
`;
8894

8995
exports[`FEDERATION > can update a service without providing a url if previously published > schemaPublish (initial) 1`] = `
9096
:::::::::::::::: CLI SUCCESS OUTPUT :::::::::::::::::

integration-tests/tests/cli/schema.spec.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { createHash } from 'node:crypto';
33
import { ProjectType } from 'testkit/gql/graphql';
44
import * as GraphQLSchema from 'testkit/gql/graphql';
5+
import type { CompositeSchema } from '@hive/api/__generated__/types';
56
import { createCLI, schemaCheck, schemaPublish } from '../../testkit/cli';
67
import { cliOutputSnapshotSerializer } from '../../testkit/cli-snapshot-serializer';
78
import { initSeed } from '../../testkit/seed';
@@ -423,25 +424,45 @@ describe.each([ProjectType.Stitching, ProjectType.Federation, ProjectType.Single
423424
}),
424425
).resolves.toMatchSnapshot('schema publish initial');
425426

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+
426440
await expect(
427441
cli.publish({
428-
sdl,
442+
sdl: sdl2,
429443
commit: 'push2',
430444
serviceName,
431-
expect: 'ignored',
445+
serviceUrl: undefined,
446+
expect: 'latest-composable',
432447
}),
433448
).resolves.toMatchSnapshot('schema publish same url');
434449

435450
const versions = await fetchVersions(3);
436-
expect(versions).toHaveLength(1);
451+
expect(versions).toHaveLength(2);
437452

438453
const versionWithNewServiceUrl = versions[0];
439454

455+
const schema = versionWithNewServiceUrl.schemas.nodes?.[0];
456+
expect(schema.__typename).toBe('CompositeSchema');
457+
expect((schema as CompositeSchema).url).toBe('http://localhost:4000');
458+
440459
expect(await compareToPreviousVersion(versionWithNewServiceUrl.id)).toEqual(
441460
expect.objectContaining({
442461
target: expect.objectContaining({
443462
schemaVersion: expect.objectContaining({
444-
safeSchemaChanges: null,
463+
safeSchemaChanges: {
464+
nodes: expect.anything(),
465+
},
445466
schemaCompositionErrors: null,
446467
}),
447468
}),

0 commit comments

Comments
 (0)