11/// <reference types="Cypress" />
22
3- import { apiHost } from "../support/config" ;
4-
53context ( 'Talking to the api directly' , ( ) => {
64 describe ( 'API version' , ( ) => {
75 before ( function ( ) {
86 cy . connect ( ) ;
97 cy . visit ( '/' ) ;
108 } ) ;
119 it ( 'should fail to connect with older api' , ( ) => {
12- cy . window ( ) . then ( function ( win ) {
13- cy . stub ( win , 'fetch' ) . callThrough ( ) . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/version' ) . as ( 'version api' ) . resolves ( {
14- status : 200 ,
15- ok : true ,
16- json : ( ) => ( {
17- version : '0.0.1' ,
18- "server" : {
19- "product-name" : "eXist" ,
20- "build" : "20200123123609" ,
21- "version" : "5.2.0" ,
22- "revision" : "c58d04ec45de50e7738489dee072fcc863dc8b1b"
23- } ,
24- "exist-db" : {
25- "compatible-version" : null
26- }
27- } ) ,
28- } ) ;
29- } ) ;
10+ cy . intercept ( 'GET' , Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/version' , { fixture : 'bad_api' } ) ;
3011 cy . get ( '.fusion-item' ) . click ( ) . then ( ( ) => {
3112 cy . get ( '.dialogTitle' ) . should ( 'contain.text' , 'New Connection' ) ;
3213 cy . get ( '.dialogContent' ) . should ( 'be.visible' )
@@ -36,27 +17,25 @@ context('Talking to the api directly', () => {
3617 cy . get ( '.dialogBlock' ) . should ( 'not.exist' ) ;
3718 } ) ;
3819 } ) ;
39- it . only ( 'should connect with newer api' , ( ) => {
20+ it ( 'should connect with newer api' , ( ) => {
4021 cy . window ( ) . then ( function ( win ) {
4122 const fetchSpy = cy . spy ( win , 'fetch' ) ;
42- const versionSpy = fetchSpy . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/version' ) . as ( 'version api' ) ;
43- const explorerSpy = fetchSpy . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/explorer?uri=/' ) . as ( 'explorer' ) ;
44- const userSpy = fetchSpy . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/user' ) . as ( 'user' ) ;
45- const groupSpy = fetchSpy . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/group' ) . as ( 'group' ) ;
46- const indexSpy = fetchSpy . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/index' ) . as ( 'index' ) ;
47- const restxqSpy = fetchSpy . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/restxq' ) . as ( 'restxq' ) ;
48- cy . get ( '.fusion-item' ) . click ( ) . then ( ( ) => {
49- cy . get ( '.ReactVirtualized__Grid__innerScrollContainer' )
50- . should ( 'contain' , 'db' )
51- . should ( 'contain' , 'RestXQ' ) . then ( ( ) => {
52- expect ( versionSpy ) . to . be . called ;
53- expect ( explorerSpy ) . to . be . called ;
54- expect ( userSpy ) . to . be . called ;
55- expect ( groupSpy ) . to . be . called ;
56- expect ( indexSpy ) . to . be . called ;
57- expect ( restxqSpy ) . to . be . called ;
58- } ) ;
59- } ) ;
23+ fetchSpy . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/version' ) . as ( '/version' ) ;
24+ fetchSpy . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/explorer?uri=/' ) . as ( '/explorer' ) ;
25+ fetchSpy . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/user' ) . as ( '/user' ) ;
26+ fetchSpy . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/group' ) . as ( '/group' ) ;
27+ fetchSpy . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/index' ) . as ( '/index' ) ;
28+ fetchSpy . withArgs ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/restxq' ) . as ( '/restxq' ) ;
29+ cy . get ( '.fusion-item' ) . click ( ) ;
30+ cy . get ( '.fusion-view' )
31+ . should ( 'contain' , 'db' )
32+ . should ( 'contain' , 'RestXQ' ) ;
33+ cy . get ( '@/version' ) . should ( 'be.called' ) ;
34+ cy . get ( '@/explorer' ) . should ( 'be.called' ) ;
35+ cy . get ( '@/user' ) . should ( 'be.called' ) ;
36+ cy . get ( '@/group' ) . should ( 'be.called' ) ;
37+ cy . get ( '@/index' ) . should ( 'be.called' ) ;
38+ cy . get ( '@/restxq' ) . should ( 'be.called' ) ;
6039 } ) ;
6140 } ) ;
6241 } ) ;
0 commit comments