|
| 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