Skip to content

Commit 733a3b4

Browse files
committed
basic api tests
1 parent 1f1826c commit 733a3b4

File tree

1 file changed

+59
-9
lines changed

1 file changed

+59
-9
lines changed

cypress/integration/02_api-spec.js

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,63 @@
11
/// <reference types="Cypress" />
22

3-
context('Talking to the api directly', () => {
4-
describe('API version', () => {
5-
it.skip('should connect with newer api', () => {
6-
cy.visit('/')
7-
// TODO: Why does this have UUID is the ID stable, this needs a meaningful selector
8-
.get('#d184cace-9938-4ad5-b8df-925a91942661')
9-
.should('be.visible')
10-
})
3+
import { apiHost } from "../support/config";
114

12-
})
5+
context('Talking to the api directly', () => {
6+
describe('API version', () => {
7+
before(function() {
8+
cy.connect();
9+
cy.visit('/');
10+
});
11+
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+
});
30+
cy.get('.fusion-item').click().then(() => {
31+
cy.get('.dialogTitle').should('contain.text', 'New Connection');
32+
cy.get('.dialogContent').should('be.visible')
33+
.should('contain.text', 'Outdated API "0.0.1"')
34+
.should('contain.text', 'You need to update your API to version "0.2.0" or higher');
35+
cy.get('.theia-button.main').should('be.visible').click();
36+
cy.get('.dialogBlock').should('not.exist');
37+
});
38+
});
39+
it.only('should connect with newer api', () => {
40+
cy.window().then(function(win) {
41+
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+
});
60+
});
61+
});
62+
});
1363
})

0 commit comments

Comments
 (0)