Skip to content

Commit 96fabcd

Browse files
dondonzacao
authored andcommitted
Add extensions to Cypress setup and tabs e2e test
1 parent 91ea8b5 commit 96fabcd

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

packages/graphiql/cypress/e2e/tabs.cy.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ describe('Tabs', () => {
3131
.eq(1)
3232
.type('{"someHeader":"someValue"', { force: true });
3333

34+
// Enter extensions
35+
cy.contains('Extensions').click();
36+
cy.get('.graphiql-editor-tool textarea')
37+
.eq(2)
38+
.type('{"myExtension":"myString"', { force: true });
39+
3440
// Run the query
3541
cy.clickExecuteQuery();
3642

@@ -45,6 +51,7 @@ describe('Tabs', () => {
4551
cy.assertHasValues({
4652
query: '{id}',
4753
variablesString: '',
54+
extensionsString: '',
4855
headersString: '',
4956
response: { data: { id: 'abc123' } },
5057
});
@@ -60,6 +67,7 @@ describe('Tabs', () => {
6067
cy.assertHasValues({
6168
query: 'query Foo {image}',
6269
variablesString: '{"someVar":42}',
70+
extensionsString: '{"myExtension":"myString"}',
6371
headersString: '{"someHeader":"someValue"}',
6472
response: { data: { image: '/images/logo.svg' } },
6573
});
@@ -74,6 +82,7 @@ describe('Tabs', () => {
7482
cy.assertHasValues({
7583
query: '{id}',
7684
variablesString: '',
85+
extensionsString: '',
7786
headersString: '',
7887
response: { data: { id: 'abc123' } },
7988
});

packages/graphiql/cypress/support/commands.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type Op = {
1414
query: string;
1515
variables?: Record<string, any>;
1616
variablesString?: string;
17+
extensionsString?: string;
1718
headersString?: string;
1819
response?: Record<string, any>;
1920
};
@@ -73,7 +74,7 @@ Cypress.Commands.add('visitWithOp', ({ query, variables, variablesString }) => {
7374

7475
Cypress.Commands.add(
7576
'assertHasValues',
76-
({ query, variables, variablesString, headersString, response }: Op) => {
77+
({ query, variables, variablesString, extensionsString, headersString, response }: Op) => {
7778
cy.get('.graphiql-query-editor').should(element => {
7879
expect(normalize(element.get(0).innerText)).to.equal(
7980
codeWithLineNumbers(query),
@@ -100,14 +101,24 @@ Cypress.Commands.add(
100101
});
101102
}
102103
if (headersString !== undefined) {
103-
cy.contains('Headers').click();
104-
cy.get('.graphiql-editor-tool .graphiql-editor')
105-
.eq(1)
106-
.should(element => {
107-
expect(normalize(element.get(0).innerText)).to.equal(
108-
codeWithLineNumbers(headersString),
109-
);
110-
});
104+
cy.contains('Headers').click();
105+
cy.get('.graphiql-editor-tool .graphiql-editor')
106+
.eq(1)
107+
.should(element => {
108+
expect(normalize(element.get(0).innerText)).to.equal(
109+
codeWithLineNumbers(headersString),
110+
);
111+
});
112+
}
113+
if (extensionsString !== undefined) {
114+
cy.contains('Extensions').click();
115+
cy.get('.graphiql-editor-tool .graphiql-editor')
116+
.eq(2)
117+
.should(element => {
118+
expect(normalize(element.get(0).innerText)).to.equal(
119+
codeWithLineNumbers(extensionsString),
120+
);
121+
});
111122
}
112123
if (response !== undefined) {
113124
cy.get('.result-window').should(element => {

0 commit comments

Comments
 (0)