@@ -163,9 +163,9 @@ SELECT * WHERE {
163163
164164 cy . get ( 'textarea[name="queryURL"]' ) . invoke ( 'val' ) . then ( ( val ) => {
165165 expect ( val ) . to . include ( '?name=new+query&description=new+description&queryString=PREFIX+schema%3A+%3Chttp%3A%2F%2Fschema.org%2F%3E+%0ASELECT+*+WHERE+%7B%0A++++%3Flist+schema%3Aname+%3FlistTitle%3B%0A++++++schema%3AitemListElement+%5B%0A++++++schema%3Aname+%3FbookTitle%3B%0A++++++schema%3Acreator+%5B%0A++++++++schema%3Aname+%3FauthorName%0A++++++%5D%0A++++%5D.%0A%7D&source=http%3A%2F%2Flocalhost%3A8080%2Fexample%2Fwish-list' ) ;
166- } ) ;
167-
168-
166+ } ) ;
167+
168+
169169 } )
170170
171171 it ( "Custom templated query" , ( ) => {
@@ -184,7 +184,7 @@ SELECT ?name ?sameAs_url WHERE {
184184 schema:genre $genre;
185185 schema:sameAs ?sameAs_url;
186186}`
187- ) ;
187+ ) ;
188188
189189 cy . get ( 'input[name="source"]' ) . type ( "http://localhost:8080/example/favourite-musicians" ) ;
190190 cy . get ( 'input[name="templatedQueryCheck"]' ) . click ( )
@@ -245,7 +245,7 @@ WHERE {
245245 ?material o:name ?materialName ;
246246}
247247ORDER BY ?componentName`
248- ) ;
248+ ) ;
249249
250250 // No Comunica Sources Required
251251 cy . get ( 'input[name="sourceIndexCheck"]' ) . click ( )
@@ -260,11 +260,149 @@ SELECT ?object
260260WHERE {
261261 example:index-example rdfs:seeAlso ?object .
262262}`
263- )
263+ )
264264 cy . get ( 'button[type="submit"]' ) . click ( ) ;
265265
266266 cy . contains ( "https://www.example.com/data/component-c01" ) . should ( 'exist' ) ;
267267
268268 } )
269269
270+
271+
272+ it ( "Make a templated query, then edit it to make it a normal query" , ( ) => {
273+
274+ // First create the query
275+ cy . visit ( "/#/customQuery" ) ;
276+
277+ cy . get ( 'input[name="name"]' ) . type ( "custom template" ) ;
278+ cy . get ( 'textarea[name="description"]' ) . type ( "description for template" ) ;
279+
280+ // Query handling a variable
281+ cy . get ( 'textarea[name="queryString"]' ) . clear ( ) ;
282+ cy . get ( 'textarea[name="queryString"]' ) . type ( `PREFIX schema: <http://schema.org/>
283+ SELECT ?name ?sameAs_url WHERE {
284+ ?list schema:name ?listTitle;
285+ schema:name ?name;
286+ schema:genre $genre;
287+ schema:sameAs ?sameAs_url;
288+ }`
289+ ) ;
290+
291+ cy . get ( 'input[name="source"]' ) . type ( "http://localhost:8080/example/favourite-musicians" ) ;
292+ cy . get ( 'input[name="templatedQueryCheck"]' ) . click ( )
293+
294+ cy . get ( 'textarea[name="templateOptions"]' ) . clear ( )
295+ cy . get ( 'textarea[name="templateOptions"]' ) . type ( `{"variables" : {
296+ "genre": [
297+ "\\"Romantic\\"",
298+ "\\"Baroque\\"",
299+ "\\"Classical\\""
300+ ]
301+ }}` )
302+ cy . get ( 'button[type="submit"]' ) . click ( ) ;
303+
304+
305+ cy . get ( 'form' ) . within ( ( ) => {
306+ cy . get ( '#genre' ) . click ( ) ;
307+ } ) ;
308+ cy . get ( 'li' ) . contains ( 'Baroque' ) . click ( ) ;
309+
310+ // Comfirm query
311+ cy . get ( 'button[type="submit"]' ) . click ( ) ;
312+
313+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Antonio Caldara" ) . should ( 'exist' ) ;
314+
315+ // Now that this templated one works, lets edit it to make a normal query from it
316+ cy . get ( 'button' ) . contains ( "Edit Query" ) . click ( ) ;
317+
318+ cy . get ( 'textarea[name="queryString"]' ) . clear ( ) ;
319+ cy . get ( 'textarea[name="queryString"]' ) . type ( `PREFIX schema: <http://schema.org/>
320+ SELECT ?name ?genre ?sameAs_url WHERE {
321+ ?list schema:name ?listTitle;
322+ schema:name ?name;
323+ schema:genre ?genre;
324+ schema:sameAs ?sameAs_url;
325+ }`
326+ ) ;
327+
328+ // Remove the templated options
329+ cy . get ( 'input[name="templatedQueryCheck"]' ) . click ( )
330+
331+ cy . get ( 'button[type="submit"]' ) . click ( ) ;
332+
333+ cy . get ( 'form' ) . should ( 'not.exist' )
334+
335+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Ludwig van Beethoven" ) . should ( 'exist' ) ;
336+ } )
337+
338+ // Reverse logic
339+
340+ it ( "Make a normal query, then edit it to make it a templated query" , ( ) => {
341+
342+ // First create the query
343+ cy . visit ( "/#/customQuery" ) ;
344+
345+ cy . get ( 'input[name="name"]' ) . type ( "custom template" ) ;
346+ cy . get ( 'textarea[name="description"]' ) . type ( "description for template" ) ;
347+
348+ // Query handling a variable
349+ cy . get ( 'textarea[name="queryString"]' ) . clear ( ) ;
350+ cy . get ( 'textarea[name="queryString"]' ) . type ( `PREFIX schema: <http://schema.org/>
351+ SELECT ?name ?genre ?sameAs_url WHERE {
352+ ?list schema:name ?listTitle;
353+ schema:name ?name;
354+ schema:genre ?genre;
355+ schema:sameAs ?sameAs_url;
356+ }`
357+ ) ;
358+
359+ cy . get ( 'input[name="source"]' ) . type ( "http://localhost:8080/example/favourite-musicians" ) ;
360+
361+ cy . get ( 'button[type="submit"]' ) . click ( ) ;
362+
363+ cy . get ( 'form' ) . should ( 'not.exist' )
364+
365+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Ludwig van Beethoven" ) . should ( 'exist' ) ;
366+
367+
368+
369+
370+ // Now that this normal one works, lets edit it to make a templated query from it
371+ cy . get ( 'button' ) . contains ( "Edit Query" ) . click ( ) ;
372+
373+ cy . get ( 'textarea[name="queryString"]' ) . clear ( ) ;
374+ cy . get ( 'textarea[name="queryString"]' ) . type ( `PREFIX schema: <http://schema.org/>
375+ SELECT ?name ?sameAs_url WHERE {
376+ ?list schema:name ?listTitle;
377+ schema:name ?name;
378+ schema:genre $genre;
379+ schema:sameAs ?sameAs_url;
380+ }`
381+ ) ;
382+
383+ cy . get ( 'input[name="templatedQueryCheck"]' ) . click ( )
384+
385+ cy . get ( 'textarea[name="templateOptions"]' ) . clear ( )
386+ cy . get ( 'textarea[name="templateOptions"]' ) . type ( `{"variables" : {
387+ "genre": [
388+ "\\"Romantic\\"",
389+ "\\"Baroque\\"",
390+ "\\"Classical\\""
391+ ]
392+ }}` )
393+
394+ cy . get ( 'button[type="submit"]' ) . click ( ) ;
395+
396+
397+ cy . get ( 'form' ) . within ( ( ) => {
398+ cy . get ( '#genre' ) . click ( ) ;
399+ } ) ;
400+ cy . get ( 'li' ) . contains ( 'Baroque' ) . click ( ) ;
401+
402+ // Comfirm query
403+ cy . get ( 'button[type="submit"]' ) . click ( ) ;
404+
405+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Antonio Caldara" ) . should ( 'exist' ) ;
406+ } )
407+
270408} )
0 commit comments