Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
fix lint

this should fix cypress

fix
  • Loading branch information
dimaMachina committed Aug 15, 2024
1 parent fcf470e commit be08c8f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
15 changes: 3 additions & 12 deletions packages/graphiql-react/src/editor/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -396,8 +389,6 @@ export function EditorContextProvider(props: EditorContextProviderProps) {
return updated;
});
}, [
headers,
query,
defaultHeaders,
defaultQuery,
onTabChange,
Expand Down
6 changes: 4 additions & 2 deletions packages/graphiql/cypress/e2e/headers.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql/cypress/e2e/tabs.cy.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
1 change: 1 addition & 0 deletions packages/graphiql/resources/renderExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ root.render(
parameters.confirmCloseTab === 'true' ? confirmCloseTab : undefined,
onTabChange,
forcedTheme: parameters.forcedTheme,
defaultQuery: parameters.defaultQuery,
}),
);

0 comments on commit be08c8f

Please sign in to comment.