Skip to content

Commit 80172a5

Browse files
authored
Publishing then checking the same schema no longer can cause a diff (#8361)
1 parent f6916d3 commit 80172a5

11 files changed

Lines changed: 713 additions & 23 deletions

File tree

.changeset/breezy-ears-raise.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'hive': patch
3+
---
4+
5+
Remove pretty print from check diff view. Add integration and e2e tests to verify publishing then
6+
checking the same SDL won't cause a difference in the schema check diff viewer

e2e/fixtures.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// eslint-disable-next-line import/no-extraneous-dependencies -- required before loading seed helpers
22
import 'reflect-metadata';
33
import { test as base, expect, type Page } from '@playwright/test';
4-
import { initSeed } from '../integration-tests/testkit/seed';
4+
import { initSeed, ProjectType } from '../integration-tests/testkit/seed';
55
import { createAppHelper, type AppHelper } from './helpers/app';
66
import { createAuthHelper, type AuthHelper } from './helpers/auth';
77
import { createLaboratoryHelper, type LaboratoryHelper } from './helpers/laboratory';
@@ -10,7 +10,17 @@ import { createUsageHelper, type UsageHelper } from './helpers/usage';
1010

1111
export type SeedHelper = {
1212
seedOrg(): Promise<{ slug: string; accessToken: string; refreshToken: string; email: string }>;
13-
seedTarget(): Promise<{ slug: string; accessToken: string; refreshToken: string; email: string }>;
13+
seedTarget(type: ProjectType): Promise<{
14+
slug: string;
15+
accessToken: string;
16+
refreshToken: string;
17+
email: string;
18+
resources: {
19+
organizationId: string;
20+
projectId: string;
21+
targetId: string;
22+
};
23+
}>;
1424
getEmailConfirmationLink(input: string | { email: string; now: number }): Promise<string>;
1525
purgeOIDCDomains(): Promise<void>;
1626
purgeUserByEmail(email: string): Promise<void>;
@@ -50,16 +60,21 @@ async function createSeedHelper(): Promise<SeedHelper> {
5060
email: owner.ownerEmail,
5161
};
5262
},
53-
async seedTarget() {
63+
async seedTarget(projectType?: ProjectType) {
5464
const owner = await seed.createOwner();
5565
const org = await owner.createOrg();
56-
const project = await org.createProject();
66+
const project = await org.createProject(projectType);
5767

5868
return {
5969
slug: `${org.organization.slug}/${project.project.slug}/${project.target.slug}`,
6070
accessToken: owner.ownerToken,
6171
refreshToken: owner.ownerRefreshToken,
6272
email: owner.ownerEmail,
73+
resources: {
74+
organizationId: org.organization.id,
75+
projectId: project.project.id,
76+
targetId: project.target.id,
77+
},
6378
};
6479
},
6580
async getEmailConfirmationLink(input) {

e2e/local.sh

100644100755
File mode changed.

e2e/specs/checks.spec.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { readFileSync } from 'fs';
2+
import { checkSchema, publishSchema } from 'testkit/flow';
3+
import { ProjectType } from 'testkit/seed';
4+
import { expect, test } from '../fixtures';
5+
6+
test.describe('checks', () => {
7+
test('should not show a diff for a version and check with the same SDL', async ({
8+
page,
9+
seed,
10+
auth,
11+
}) => {
12+
// const { accessToken, refreshToken, slug } = await seed.seedOrg();
13+
const { accessToken, refreshToken, slug, resources } = await seed.seedTarget(
14+
ProjectType.Federation,
15+
);
16+
const sdl = readFileSync('integration-tests/fixtures/federation-00.graphql', 'utf-8');
17+
await publishSchema(
18+
{
19+
sdl,
20+
service: 'test',
21+
url: 'http://localhost:4141/test',
22+
target: {
23+
byId: resources.targetId,
24+
},
25+
author: 'e2e',
26+
commit: 'xyz',
27+
},
28+
accessToken,
29+
);
30+
const check = await checkSchema(
31+
{
32+
sdl,
33+
service: 'test',
34+
url: 'http://localhost:4141/test',
35+
target: {
36+
byId: resources.targetId,
37+
},
38+
},
39+
accessToken,
40+
).then(r => r.expectNoGraphQLErrors());
41+
await expect(check.schemaCheck.__typename).toBe('SchemaCheckSuccess');
42+
if (check.schemaCheck.__typename === 'SchemaCheckSuccess') {
43+
async function editorHasNoDeletions() {
44+
let previousScrollTop = -1;
45+
let currentScrollTop = 0;
46+
while (currentScrollTop !== previousScrollTop) {
47+
previousScrollTop = currentScrollTop;
48+
currentScrollTop = await page.evaluate(async () => {
49+
const scroller = document.querySelector(
50+
'.monaco-editor .monaco-scrollable-element',
51+
) as HTMLElement;
52+
scroller.scrollTop += 400; // Shift downwards
53+
return scroller.scrollTop;
54+
});
55+
await expect(page.locator('.monaco-editor .gutter-delete')).toBeHidden(); // no "removed" diff element
56+
await page.waitForTimeout(50);
57+
}
58+
}
59+
60+
await auth.useSession({ refreshToken, accessToken });
61+
await page.goto(
62+
`/${slug}/checks/${check.schemaCheck.schemaCheck?.id}?filter_changed=false&filter_failed=false`,
63+
{
64+
waitUntil: 'domcontentloaded',
65+
},
66+
);
67+
68+
await page.getByTestId('service-view-btn').click(); // move to service tab
69+
await expect(page.locator('.monaco-editor.gutter')).toBeAttached({ timeout: 2000 }); // schema diff editor exists
70+
await editorHasNoDeletions();
71+
72+
await page.getByTestId('schema-view-btn').click(); // move to schema tab
73+
await expect(page.locator('.monaco-editor.gutter')).toBeAttached({ timeout: 2000 }); // schema diff editor exists
74+
await editorHasNoDeletions();
75+
76+
await page.getByTestId('supergraph-view-btn').click(); // move to supergraph tab
77+
await expect(page.locator('.monaco-editor.gutter')).toBeAttached({ timeout: 2000 }); // schema diff editor exists
78+
await editorHasNoDeletions();
79+
}
80+
});
81+
});

0 commit comments

Comments
 (0)