@@ -9,7 +9,7 @@ describe("Templated query", () => {
99 cy . contains ( "Example queries" ) . click ( ) ;
1010 cy . contains ( "A templated query about musicians" ) . click ( ) ;
1111
12- // Fill in the query, select Baroque (7 existant artists -> perfect for this test)
12+ // Fill in the query, select Baroque (7 existing artists -> perfect for this test)
1313 cy . get ( 'form' ) . within ( ( ) => {
1414 cy . get ( '#genre' ) . click ( ) ;
1515 } ) ;
@@ -57,7 +57,7 @@ describe("Templated query", () => {
5757 cy . get ( '.column-name' ) . find ( 'span' ) . should ( "have.length" , 2 ) ;
5858 } ) ;
5959
60- it ( "With 2 variables" , ( ) => {
60+ it ( "With 2 variables; change variables " , ( ) => {
6161 cy . visit ( "/" ) ;
6262 cy . contains ( "Example queries" ) . click ( ) ;
6363 cy . contains ( "A templated query about musicians (two variables)" ) . click ( ) ;
@@ -79,35 +79,71 @@ describe("Templated query", () => {
7979
8080 // Check that the page loaded and that we can see the correct data
8181 cy . contains ( "Finished in:" ) ;
82- cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Wolfgang Amadeus Mozart" ) ;
83- } ) ;
82+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Wolfgang Amadeus Mozart" ) . should ( "exist" ) ; ;
83+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Franz Schubert" ) . should ( "not.exist" ) ;
84+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Johann Sebastian Bach" ) . should ( "not.exist" ) ;
85+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Ludwig van Beethoven" ) . should ( "not.exist" ) ;
8486
85- it ( "Able to change variables after making a templated query" , ( ) => {
86- cy . visit ( "/" ) ;
87- cy . contains ( "Example queries" ) . click ( ) ;
88- cy . contains ( "A templated query about musicians" ) . click ( ) ;
87+ // Check if the button to make a new query exists and use it
88+ cy . get ( 'button' ) . contains ( "Change Variables" ) . should ( "exist" ) ;
89+ cy . get ( 'button' ) . contains ( "Change Variables" ) . click ( ) ;
90+
91+ // Making sure we get the form to enter new variables
92+ // and that the previously selected value(s) are still there
93+ cy . get ( 'form' ) . within ( ( ) => {
94+ cy . get ( '#genre' ) . should ( 'have.value' , '"Classical"' ) ;
95+ cy . get ( '#sameAsUrl' ) . should ( 'have.value' , '<https://en.wikipedia.org/wiki/Wolfgang_Amadeus_Mozart>' ) ;
96+ } ) ;
97+
98+ // Previously selected variables are still there; submit the same combination again
99+ cy . get ( 'button[type="submit"]' ) . click ( ) ;
100+
101+ cy . contains ( "Finished in:" ) ;
102+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Wolfgang Amadeus Mozart" ) . should ( "exist" ) ; ;
103+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Franz Schubert" ) . should ( "not.exist" ) ;
104+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Johann Sebastian Bach" ) . should ( "not.exist" ) ;
105+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Ludwig van Beethoven" ) . should ( "not.exist" ) ;
106+
107+ // Change variables and make a nonexisting combination
108+ cy . get ( 'button' ) . contains ( "Change Variables" ) . should ( "exist" ) ;
109+ cy . get ( 'button' ) . contains ( "Change Variables" ) . click ( ) ;
89110
90- // Fill in the query
91111 cy . get ( 'form' ) . within ( ( ) => {
92112 cy . get ( '#genre' ) . click ( ) ;
93113 } ) ;
94114 cy . get ( 'li' ) . contains ( 'Baroque' ) . click ( ) ;
95115
96- // Comfirm query
97- cy . get ( 'button' ) . contains ( 'Query' ) . click ( ) ;
116+ cy . get ( 'form' ) . within ( ( ) => {
117+ cy . get ( '#sameAsUrl' ) . click ( ) ;
118+ } ) ;
119+ cy . get ( 'li' ) . contains ( 'Beethoven' ) . click ( ) ;
98120
99- // Check that the page loaded and that we can see the correct data
100- cy . contains ( "Finished in:" ) ;
101- cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Johann Sebastian Bach" ) ;
121+ cy . get ( 'button[type="submit"]' ) . click ( ) ;
102122
103- // Check if the button to make a new query exists and use it
123+ cy . get ( 'span' ) . contains ( "The result list is empty." ) . should ( "exist" ) ;
124+
125+ // Change variables and make another existing combination
104126 cy . get ( 'button' ) . contains ( "Change Variables" ) . should ( "exist" ) ;
105127 cy . get ( 'button' ) . contains ( "Change Variables" ) . click ( ) ;
106128
107- // Making sure we get the form to enter new variables
108129 cy . get ( 'form' ) . within ( ( ) => {
109- cy . get ( '#genre' ) . should ( "exist" ) ;
130+ cy . get ( '#genre' ) . click ( ) ;
131+ } ) ;
132+ cy . get ( 'li' ) . contains ( 'Romantic' ) . click ( ) ;
133+
134+ cy . get ( 'form' ) . within ( ( ) => {
135+ cy . get ( '#sameAsUrl' ) . click ( ) ;
110136 } ) ;
137+ cy . get ( 'li' ) . contains ( 'Schubert' ) . click ( ) ;
138+
139+ cy . get ( 'button[type="submit"]' ) . click ( ) ;
140+
141+ cy . get ( 'span' ) . contains ( "The result list is empty." ) . should ( "not.exist" ) ;
142+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Ludwig van Beethoven" ) . should ( "not.exist" ) ;
143+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Johann Sebastian Bach" ) . should ( "not.exist" ) ;
144+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Antonio Vivaldi" ) . should ( "not.exist" ) ;
145+ cy . get ( '.column-name' ) . find ( 'span' ) . contains ( "Franz Schubert" ) . should ( "exist" ) ;
146+
111147 } ) ;
112148
113149 it ( "Correct message displayed when no resulting data" , ( ) => {
@@ -161,8 +197,11 @@ describe("Templated query", () => {
161197 cy . get ( 'button' ) . contains ( "Change Variables" ) . click ( ) ;
162198
163199 // Making sure we get the form to enter new variables
200+ // and that the previously selected value(s) are still there
164201 cy . get ( 'form' ) . within ( ( ) => {
165202 cy . get ( '#genre' ) . should ( "exist" ) ;
203+ cy . get ( '#genre' ) . should ( 'have.value' , '"Classical"' ) ;
204+ cy . get ( '#sameAsUrl' ) . should ( 'have.value' , '<https://en.wikipedia.org/wiki/Johann_Sebastian_Bach>' ) ;
166205 } ) ;
167206
168207 } ) ;
0 commit comments