From be08c8fa3b81467922efe9fb16bf7270e2da4efe Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Thu, 15 Aug 2024 16:47:04 +0200 Subject: [PATCH] upd fix lint this should fix cypress fix --- packages/graphiql-react/src/editor/context.tsx | 15 +++------------ packages/graphiql/cypress/e2e/headers.cy.ts | 6 ++++-- packages/graphiql/cypress/e2e/tabs.cy.ts | 2 +- packages/graphiql/resources/renderExample.js | 1 + 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/packages/graphiql-react/src/editor/context.tsx b/packages/graphiql-react/src/editor/context.tsx index a1a0fed8491..339f84cf03b 100644 --- a/packages/graphiql-react/src/editor/context.tsx +++ b/packages/graphiql-react/src/editor/context.tsx @@ -360,14 +360,7 @@ export function EditorContextProvider(props: EditorContextProviderProps) { headerEditor, responseEditor, }); - const { - onTabChange, - headers, - query, - defaultHeaders, - defaultQuery, - children, - } = props; + const { onTabChange, defaultHeaders, defaultQuery, children } = props; const setEditorValues = useSetEditorValues({ queryEditor, variableEditor, @@ -384,8 +377,8 @@ export function EditorContextProvider(props: EditorContextProviderProps) { tabs: [ ...updatedValues.tabs, createTab({ - headers: headers ?? defaultHeaders, - query: query ?? defaultQuery ?? DEFAULT_QUERY, + headers: defaultHeaders, + query: defaultQuery ?? DEFAULT_QUERY, }), ], activeTabIndex: updatedValues.tabs.length, @@ -396,8 +389,6 @@ export function EditorContextProvider(props: EditorContextProviderProps) { return updated; }); }, [ - headers, - query, defaultHeaders, defaultQuery, onTabChange, diff --git a/packages/graphiql/cypress/e2e/headers.cy.ts b/packages/graphiql/cypress/e2e/headers.cy.ts index da453b052d3..7e4df95b56c 100644 --- a/packages/graphiql/cypress/e2e/headers.cy.ts +++ b/packages/graphiql/cypress/e2e/headers.cy.ts @@ -3,7 +3,9 @@ const DEFAULT_HEADERS = '{"foo":2}'; describe('Headers', () => { describe('`defaultHeaders`', () => { it('should have default headers while open new tabs', () => { - cy.visit(`/?query={test}&defaultHeaders=${DEFAULT_HEADERS}`); + cy.visit( + `/?query={test}&defaultHeaders=${DEFAULT_HEADERS}&defaultQuery=`, + ); cy.assertHasValues({ query: '{test}', headersString: DEFAULT_HEADERS }); cy.get('.graphiql-tab-add').click(); cy.assertHasValues({ query: '', headersString: DEFAULT_HEADERS }); @@ -14,7 +16,7 @@ describe('Headers', () => { it('in case `headers` and `defaultHeaders` are set, `headers` should be on 1st tab and `defaultHeaders` for other opened tabs', () => { const HEADERS = '{"bar":true}'; cy.visit( - `/?query={test}&defaultHeaders=${DEFAULT_HEADERS}&headers=${HEADERS}`, + `/?query={test}&defaultHeaders=${DEFAULT_HEADERS}&headers=${HEADERS}&defaultQuery=`, ); cy.assertHasValues({ query: '{test}', headersString: HEADERS }); cy.get('.graphiql-tab-add').click(); diff --git a/packages/graphiql/cypress/e2e/tabs.cy.ts b/packages/graphiql/cypress/e2e/tabs.cy.ts index 13cdba3f066..007bd2d5ded 100644 --- a/packages/graphiql/cypress/e2e/tabs.cy.ts +++ b/packages/graphiql/cypress/e2e/tabs.cy.ts @@ -1,6 +1,6 @@ describe('Tabs', () => { it('Should store editor contents when switching between tabs', () => { - cy.visit('/?query='); + cy.visit('/?defaultQuery=&query='); // Assert that no tab visible when there's only one session cy.get('#graphiql-session-tab-0').should('not.exist'); diff --git a/packages/graphiql/resources/renderExample.js b/packages/graphiql/resources/renderExample.js index 208d6accc2d..b3276303ddb 100644 --- a/packages/graphiql/resources/renderExample.js +++ b/packages/graphiql/resources/renderExample.js @@ -94,5 +94,6 @@ root.render( parameters.confirmCloseTab === 'true' ? confirmCloseTab : undefined, onTabChange, forcedTheme: parameters.forcedTheme, + defaultQuery: parameters.defaultQuery, }), );