Skip to content
This repository was archived by the owner on Feb 25, 2024. It is now read-only.

Commit 61f8f59

Browse files
authored
Merge pull request #391 from statelyai/mellson/move-to-rest-endpoints
Call REST endpoints in the registry
2 parents a543853 + 9a849e3 commit 61f8f59

35 files changed

+635
-2781
lines changed

.env.development

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
NEXT_PUBLIC_GRAPHQL_API_URL="https://dev.stately.ai/registry/api/graphql"
2-
NEXT_PUBLIC_SUPABASE_API_URL="https://owxhbmonbfrgnegwprcq.supabase.co"
3-
NEXT_PUBLIC_SUPABASE_ANON_API_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYyMzkzNTUzOCwiZXhwIjoxOTM5NTExNTM4fQ.srHSjKsgKFPREW6M0jGbFrvIWsmI0XfSTthBTFOZXI8"
4-
NEXT_PUBLIC_REGISTRY_PUBLIC_URL="https://dev.stately.ai/registry"
1+
NEXT_PUBLIC_SUPABASE_API_URL="https://xxxcbgbmwhknulkwqyjh.supabase.co"
2+
NEXT_PUBLIC_SUPABASE_ANON_API_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4eGNiZ2Jtd2hrbnVsa3dxeWpoIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NjYwMjM1MjIsImV4cCI6MTk4MTU5OTUyMn0.ESGVB9BxmitbVpXxLf4ZugQeUMeRafnIX0ZY-tEqVrM"
3+
NEXT_PUBLIC_REGISTRY_PUBLIC_URL="http://localhost:3000/registry"

.github/workflows/main.yml

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,37 @@ jobs:
1717
run: yarn install --frozen-lockfile
1818

1919
- name: Lint
20-
run: yarn graphql-codegen && yarn tsc
20+
run: yarn tsc
2121

2222
- name: Jest tests
2323
run: yarn jest --ci
2424

25-
- name: Build
26-
run: yarn next build
27-
env:
28-
NEXT_PUBLIC_GRAPHQL_API_URL: https://dev.stately.ai/registry/api/graphql
29-
NEXT_PUBLIC_SUPABASE_API_URL: ${{ secrets.SUPABASE_API_URL }}
30-
NEXT_PUBLIC_SUPABASE_ANON_API_KEY: ${{ secrets.SUPABASE_ANON_API_KEY }}
31-
NEXT_PUBLIC_USE_LOCAL_MONACO: 'true'
32-
CI: 'false'
33-
34-
- name: Run Cypress
35-
uses: cypress-io/github-action@v2
36-
with:
37-
start: yarn serve
38-
wait-on: http://localhost:3000
39-
40-
- name: Upload Screenshots
41-
uses: actions/upload-artifact@v1
42-
if: failure()
43-
with:
44-
name: cypress-screenshots
45-
path: cypress/screenshots
46-
47-
- name: Upload Videos
48-
uses: actions/upload-artifact@v1
49-
if: always()
50-
with:
51-
name: cypress-videos
52-
path: cypress/videos
25+
# TODO: The Cypress tests need updating after we've moved to consume REST endpoints. That work is on hold until we decide how to do e2e tests internally.
26+
#
27+
# - name: Build
28+
# run: yarn next build
29+
# env:
30+
# NEXT_PUBLIC_SUPABASE_API_URL: ${{ secrets.SUPABASE_API_URL }}
31+
# NEXT_PUBLIC_SUPABASE_ANON_API_KEY: ${{ secrets.SUPABASE_ANON_API_KEY }}
32+
# NEXT_PUBLIC_USE_LOCAL_MONACO: 'true'
33+
# CI: 'false'
34+
35+
# - name: Run Cypress
36+
# uses: cypress-io/github-action@v2
37+
# with:
38+
# start: yarn serve
39+
# wait-on: http://localhost:3000
40+
41+
# - name: Upload Screenshots
42+
# uses: actions/upload-artifact@v1
43+
# if: failure()
44+
# with:
45+
# name: cypress-screenshots
46+
# path: cypress/screenshots
47+
48+
# - name: Upload Videos
49+
# uses: actions/upload-artifact@v1
50+
# if: always()
51+
# with:
52+
# name: cypress-videos
53+
# path: cypress/videos

.graphqlconfig.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

codegen.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

cypress/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Cypress tests
2+
3+
The Cypress tests need updating after we've moved to consume REST endpoints. That work is on hold until we decide how to do e2e tests internally.

cypress/integration/editor-persistence.spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { LoggedInUser, SourceFile } from '../../src/apiTypes';
2+
13
describe('Editor persistence', () => {
24
const setup = () => {
35
cy.setMockAuthToken();
4-
cy.interceptGraphQL({
5-
getLoggedInUser: {
6-
id: 'id',
7-
},
6+
cy.interceptAPI<LoggedInUser>({
7+
id: 'id',
88
});
99
};
1010

@@ -37,16 +37,16 @@ describe('Editor persistence', () => {
3737
}),
3838
);
3939

40-
cy.interceptGraphQL({
41-
getLoggedInUser: {
42-
id: 'id',
43-
},
44-
getSourceFile: {
45-
id: 'source-file-id',
46-
updatedAt: '2018-04-02',
47-
text: `// Changes from the registry!`,
48-
},
40+
cy.interceptAPI<LoggedInUser>({
41+
id: 'id',
4942
});
43+
44+
cy.interceptAPI<SourceFile>({
45+
id: 'source-file-id',
46+
updatedAt: new Date('2018-04-02'),
47+
text: `// Changes from the registry!`,
48+
});
49+
5050
cy.visitVizWithNextPageProps({
5151
id: 'source-file-id',
5252
});
@@ -67,7 +67,7 @@ describe('Editor persistence', () => {
6767
}),
6868
);
6969

70-
cy.interceptGraphQL({
70+
cy.interceptAPI({
7171
getLoggedInUser: {
7272
id: 'id',
7373
},

cypress/integration/embed-preview.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
import { GetSourceFileSsrQuery } from '../../src/graphql/GetSourceFileSSR.generated';
1+
import { SourceFile } from '../../src/apiTypes';
22

33
const SOURCE_ID = 'source-file-id';
44

5-
const getSSRParam = (
6-
data: Partial<GetSourceFileSsrQuery['getSourceFile']> & { id: string },
7-
) => {
5+
const getSSRParam = (data: Partial<SourceFile> & { id: string }) => {
86
return encodeURIComponent(JSON.stringify({ data, id: data.id }));
97
};
108

119
describe('Embed Preview', () => {
1210
beforeEach(() => {
13-
cy.interceptGraphQL({
11+
cy.interceptAPI({
1412
getSourceFile: {
1513
id: SOURCE_ID,
1614
text: `

cypress/integration/embedded-mode.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ createMachine({
1919
describe('Embedded mode', () => {
2020
describe('default controls', () => {
2121
before(() => {
22-
cy.interceptGraphQL({
22+
cy.interceptAPI({
2323
getSourceFile: sourceFileFixture,
2424
});
2525
cy.visitEmbedWithNextPageProps({
@@ -35,7 +35,7 @@ describe('Embedded mode', () => {
3535
});
3636
describe('default (mode:viz)1', () => {
3737
before(() => {
38-
cy.interceptGraphQL({
38+
cy.interceptAPI({
3939
getSourceFile: sourceFileFixture,
4040
});
4141
cy.visitEmbedWithNextPageProps({
@@ -52,7 +52,7 @@ describe('Embedded mode', () => {
5252

5353
describe('mode:panels', () => {
5454
beforeEach(() => {
55-
cy.interceptGraphQL({
55+
cy.interceptAPI({
5656
getSourceFile: sourceFileFixture,
5757
});
5858
});
@@ -152,7 +152,7 @@ describe('Embedded mode', () => {
152152

153153
describe('mode:full', () => {
154154
before(() => {
155-
cy.interceptGraphQL({
155+
cy.interceptAPI({
156156
getSourceFile: sourceFileFixture,
157157
});
158158
cy.visitEmbedWithNextPageProps({

cypress/integration/forking.spec.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1+
import { LoggedInUser, SourceFile } from '../../src/apiTypes';
2+
13
describe('Forking', () => {
24
describe('When you do not own the file', () => {
35
it('Should allow you to fork it', () => {
46
cy.setMockAuthToken();
5-
cy.interceptGraphQL({
6-
getLoggedInUser: {
7-
id: 'id',
8-
},
9-
getSourceFile: {
10-
id: 'source-file-id',
7+
cy.interceptAPI<LoggedInUser>({
8+
id: 'id',
9+
});
10+
11+
cy.interceptAPI<SourceFile>({
12+
id: 'source-file-id',
13+
text: '// Source file',
14+
project: {
1115
owner: {
1216
id: 'some-other-id',
1317
},
14-
text: '// Source file',
1518
},
16-
forkSourceFile: {
17-
id: 'source-file-id-2',
19+
});
20+
cy.interceptAPI<SourceFile>({
21+
id: 'source-file-id-2',
22+
project: {
1823
name: 'Source File',
1924
owner: {
2025
id: 'id',
@@ -43,19 +48,22 @@ describe('Forking', () => {
4348
describe('When you do own the file', () => {
4449
it('Should allow you to fork it', () => {
4550
cy.setMockAuthToken();
46-
cy.interceptGraphQL({
47-
getLoggedInUser: {
48-
id: 'user-id',
49-
},
50-
getSourceFile: {
51-
id: 'source-file-id',
51+
cy.interceptAPI<LoggedInUser>({
52+
id: 'user-id',
53+
});
54+
55+
cy.interceptAPI<SourceFile>({
56+
id: 'source-file-id',
57+
text: '// Source file',
58+
project: {
5259
owner: {
5360
id: 'user-id',
5461
},
55-
text: '// Source file',
5662
},
57-
forkSourceFile: {
58-
id: 'source-file-id-2',
63+
});
64+
cy.interceptAPI<SourceFile>({
65+
id: 'source-file-id-2',
66+
project: {
5967
name: 'Source File',
6068
owner: {
6169
id: 'user-id',

cypress/integration/gist.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('Gists', () => {
1010
`;
1111

1212
const setup = () => {
13-
cy.interceptGraphQL({
13+
cy.interceptAPI({
1414
getLoggedInUser: {},
1515
});
1616
cy.setMockAuthToken();
@@ -39,7 +39,7 @@ describe('Gists', () => {
3939

4040
it('Should allow you to fork a source file from a gist', () => {
4141
setup();
42-
cy.interceptGraphQL({
42+
cy.interceptAPI({
4343
createSourceFile: {
4444
id: 'new-id',
4545
},

0 commit comments

Comments
 (0)