@@ -223,14 +223,14 @@ describe('api tests', () => {
223223
224224 // Needs an extra step, due to the structure of the returned JSON
225225 let temp = JSON . parse ( response . body )
226- let jsonBody = temp [ 0 ]
227226
228- expect ( jsonBody ) . to . have . property ( 'name' , 'Candidate_Information_Candidate_First_Pref_Votes_idx' )
229- expect ( jsonBody ) . to . have . property ( 'table' , 'Candidate_Information' )
227+ let jsonBody = temp [ 0 ]
228+ expect ( jsonBody ) . to . have . property ( 'name' )
229+ expect ( jsonBody ) . to . have . property ( 'table' )
230230
231231 let columns = jsonBody . columns [ 0 ]
232- expect ( columns ) . to . have . property ( 'id' , 0 )
233- expect ( columns ) . to . have . property ( 'name' , 'Candidate_First_Pref_Votes' )
232+ expect ( columns ) . to . have . property ( 'id' )
233+ expect ( columns ) . to . have . property ( 'name' )
234234 }
235235 )
236236 } )
@@ -285,4 +285,60 @@ describe('api tests', () => {
285285 }
286286 )
287287 } )
288+
289+ // Tables
290+ // Equivalent curl command:
291+ // curl -k -F apikey="2MXwA5jGZkIQ3UNEcKsuDNSPMlx" \
292+ // -F dbowner="default" -F dbname="Assembly Election 2017.sqlite" \
293+ // https://localhost:9444/v1/tables
294+ it ( 'tables' , ( ) => {
295+ cy . request ( {
296+ method : 'POST' ,
297+ url : 'https://localhost:9444/v1/tables' ,
298+ form : true ,
299+ body : {
300+ apikey : '2MXwA5jGZkIQ3UNEcKsuDNSPMlx' ,
301+ dbowner : 'default' ,
302+ dbname : 'Assembly Election 2017.sqlite'
303+ } ,
304+ } ) . then (
305+ ( response ) => {
306+ expect ( response . status ) . to . eq ( 200 )
307+
308+ let jsonBody = JSON . parse ( response . body )
309+ expect ( jsonBody ) . to . have . members ( [
310+ "Candidate_Information" ,
311+ "Constituency_Turnout_Information" ,
312+ "Elected_Candidates"
313+ ]
314+ )
315+ }
316+ )
317+ } )
318+
319+ // Webpage
320+ // Equivalent curl command:
321+ // curl -k -F apikey="2MXwA5jGZkIQ3UNEcKsuDNSPMlx" \
322+ // -F dbowner="default" -F dbname="Assembly Election 2017.sqlite" \
323+ // https://localhost:9444/v1/webpage
324+ it ( 'webpage' , ( ) => {
325+ cy . request ( {
326+ method : 'POST' ,
327+ url : 'https://localhost:9444/v1/webpage' ,
328+ form : true ,
329+ body : {
330+ apikey : '2MXwA5jGZkIQ3UNEcKsuDNSPMlx' ,
331+ dbowner : 'default' ,
332+ dbname : 'Assembly Election 2017.sqlite'
333+ } ,
334+ } ) . then (
335+ ( response ) => {
336+ expect ( response . status ) . to . eq ( 200 )
337+
338+ let jsonBody = JSON . parse ( response . body )
339+ expect ( jsonBody ) . to . have . property ( 'web_page' )
340+ expect ( jsonBody . web_page ) . to . match ( / .* \/ d e f a u l t \/ A s s e m b l y \ E l e c t i o n \ 2 0 1 7 \. s q l i t e $ / )
341+ }
342+ )
343+ } )
288344} )
0 commit comments