File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -281,3 +281,30 @@ describe('language banner', () => {
281281 }
282282 } )
283283} )
284+
285+ // The Explorer in the iFrame will not be accessible on localhost, but we can still
286+ // test the query param handling
287+ describe ( 'GraphQL Explorer' , ( ) => {
288+ it ( 'preserves query strings on the Explorer page without opening search' , async ( ) => {
289+ const queryString = `query {
290+ viewer {
291+ foo
292+ }
293+ }`
294+ // Encoded as: query%20%7B%0A%20%20viewer%20%7B%0A%20%20%20%20foo%0A%20%20%7D%0A%7D
295+ const encodedString = encodeURIComponent ( queryString )
296+ const explorerUrl = 'http://localhost:4001/en/graphql/overview/explorer'
297+
298+ await page . goto ( `${ explorerUrl } ?query=${ encodedString } ` )
299+
300+ // On non-Explorer pages, query params handled by search JS get form-encoded using `+` instead of `%20`.
301+ // So on these pages, the following test will be false; but on the Explorer page, it should be true.
302+ expect ( page . url ( ) . endsWith ( encodedString ) ) . toBe ( true )
303+
304+ // On non-Explorer pages, query params handled by search JS will populate in the search box and the `js-open`
305+ // class is added. On these pages, the following test will NOT be null; but on the Explorer page, it should be null.
306+ await page . waitForSelector ( '#search-results-container' )
307+ const searchResult = await page . $ ( '#search-results-container.js-open' )
308+ expect ( searchResult ) . toBeNull ( )
309+ } )
310+ } )
You can’t perform that action at this time.
0 commit comments