Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed Aug 15, 2024
1 parent 51dd93e commit be49600
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/graphiql/cypress/e2e/tabs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('Tabs', () => {

cy.get('.graphiql-tab-button + .graphiql-tab-close').eq(1).click();

cy.get('.graphiql-tab-button').should('have.length', 1);
cy.get('.graphiql-tab-button').should('have.length', 0);
});
});
});
20 changes: 5 additions & 15 deletions packages/graphiql/resources/renderExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,14 @@
*
* It is used by:
* - the netlify demo
* - end to end tests
* - end-to-end tests
* - webpack dev server
*/

// Parse the search string to get url parameters.
const parameters = {};
for (const entry of window.location.search.slice(1).split('&')) {
const eq = entry.indexOf('=');
if (eq >= 0) {
parameters[decodeURIComponent(entry.slice(0, eq))] = decodeURIComponent(
entry.slice(eq + 1),
);
}
}
const parameters = Object.fromEntries(
new URLSearchParams(location.search).entries(),
);

// When the query and variables string is edited, update the URL bar so
// that it can be easily shared.
Expand Down Expand Up @@ -53,10 +47,6 @@ function confirmCloseTab(index) {
return confirm(`Are you sure you want to close tab with index ${index}?`);
}

const searchParams = Object.fromEntries(
new URLSearchParams(location.search).entries(),
);

function updateURL() {
const newSearch = Object.entries(parameters)
.filter(([_key, value]) => value)
Expand Down Expand Up @@ -111,7 +101,7 @@ root.render(
shouldPersistHeaders: true,
inputValueDeprecation: GraphQLVersion.includes('15.5') ? undefined : true,
confirmCloseTab:
searchParams.confirmCloseTab === 'true' ? confirmCloseTab : undefined,
parameters.confirmCloseTab === 'true' ? confirmCloseTab : undefined,
onTabChange,
forcedTheme: parameters.forcedTheme,
}),
Expand Down

0 comments on commit be49600

Please sign in to comment.