@@ -170,6 +170,11 @@ describe('GraphiQL', () => {
170170 expect ( queryVariables3 ?. style . height ) . toEqual ( '' ) ;
171171 } ) ;
172172
173+ it ( 'defaults to closed history panel' , ( ) => {
174+ const { container } = render ( < GraphiQL fetcher = { noOpFetcher } /> ) ;
175+ expect ( container . querySelector ( '.historyPaneWrap' ) ) . not . toBeInTheDocument ( ) ;
176+ } ) ;
177+
173178 it ( 'adds a history item when the execute query function button is clicked' , ( ) => {
174179 const { getByTitle, container } = render (
175180 < GraphiQL
@@ -180,6 +185,7 @@ describe('GraphiQL', () => {
180185 fetcher = { noOpFetcher }
181186 /> ,
182187 ) ;
188+ fireEvent . click ( getByTitle ( 'Show History' ) ) ;
183189 fireEvent . click ( getByTitle ( 'Execute Query (Ctrl-Enter)' ) ) ;
184190 expect ( container . querySelectorAll ( '.history-contents li' ) ) . toHaveLength ( 1 ) ;
185191 } ) ;
@@ -188,6 +194,7 @@ describe('GraphiQL', () => {
188194 const { getByTitle, container } = render (
189195 < GraphiQL query = { mockBadQuery } fetcher = { noOpFetcher } /> ,
190196 ) ;
197+ fireEvent . click ( getByTitle ( 'Show History' ) ) ;
191198 fireEvent . click ( getByTitle ( 'Execute Query (Ctrl-Enter)' ) ) ;
192199 expect ( container . querySelectorAll ( '.history-contents li' ) ) . toHaveLength ( 0 ) ;
193200 } ) ;
@@ -202,6 +209,7 @@ describe('GraphiQL', () => {
202209 headers = { mockHeaders1 }
203210 /> ,
204211 ) ;
212+ fireEvent . click ( getByTitle ( 'Show History' ) ) ;
205213 fireEvent . click ( getByTitle ( 'Execute Query (Ctrl-Enter)' ) ) ;
206214 expect ( container . querySelectorAll ( '.history-contents li' ) ) . toHaveLength ( 1 ) ;
207215 } ) ;
@@ -216,6 +224,7 @@ describe('GraphiQL', () => {
216224 headers = { mockHeaders1 }
217225 /> ,
218226 ) ;
227+ fireEvent . click ( getByTitle ( 'Show History' ) ) ;
219228 fireEvent . click ( getByTitle ( 'Execute Query (Ctrl-Enter)' ) ) ;
220229 expect ( container . querySelectorAll ( '.history-contents li' ) ) . toHaveLength ( 1 ) ;
221230 fireEvent . click ( getByTitle ( 'Execute Query (Ctrl-Enter)' ) ) ;
@@ -232,6 +241,7 @@ describe('GraphiQL', () => {
232241 headers = { mockHeaders1 }
233242 /> ,
234243 ) ;
244+ fireEvent . click ( getByTitle ( 'Show History' ) ) ;
235245 const executeQueryButton = getByTitle ( 'Execute Query (Ctrl-Enter)' ) ;
236246 fireEvent . click ( executeQueryButton ) ;
237247 expect ( container . querySelectorAll ( '.history-contents li' ) ) . toHaveLength ( 1 ) ;
@@ -260,6 +270,7 @@ describe('GraphiQL', () => {
260270 headers = { mockHeaders1 }
261271 /> ,
262272 ) ;
273+ fireEvent . click ( getByTitle ( 'Show History' ) ) ;
263274 const executeQueryButton = getByTitle ( 'Execute Query (Ctrl-Enter)' ) ;
264275 fireEvent . click ( executeQueryButton ) ;
265276 expect ( container . querySelectorAll ( '.history-label' ) ) . toHaveLength ( 1 ) ;
@@ -286,6 +297,7 @@ describe('GraphiQL', () => {
286297 headerEditorEnabled
287298 /> ,
288299 ) ;
300+ fireEvent . click ( getByTitle ( 'Show History' ) ) ;
289301 const executeQueryButton = getByTitle ( 'Execute Query (Ctrl-Enter)' ) ;
290302 fireEvent . click ( executeQueryButton ) ;
291303 expect ( container . querySelectorAll ( '.history-label' ) ) . toHaveLength ( 1 ) ;
0 commit comments