Skip to content

Commit 361a3bf

Browse files
committed
fix(connection_spec): isolate connection test
add delete test add 2nd create route cleanup connections see #408, #399,
1 parent f8cb91c commit 361a3bf

6 files changed

Lines changed: 101 additions & 88 deletions

File tree

cypress/fixtures/bad_api.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"server": {
3+
"product-name": "eXist",
4+
"build": "20200123123609",
5+
"version": "5.2.0",
6+
"revision": "c58d04ec45de50e7738489dee072fcc863dc8b1b"
7+
},
8+
"exist-db": {
9+
"compatible-version": "0.0.1"
10+
}
11+
}

cypress/fixtures/good_api.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"server": {
3+
"product-name": "eXist",
4+
"build": "20200123123609",
5+
"version": "5.2.0",
6+
"revision": "c58d04ec45de50e7738489dee072fcc863dc8b1b"
7+
},
8+
"exist-db": {
9+
"compatible-version": null
10+
}
11+
}
Lines changed: 75 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,87 @@
11
/// <reference types="Cypress" />
2-
context('Fusion Studio', function () {
3-
describe('Connection Dialog', function () {
4-
it('should accept user input', function () {
2+
context('Fusion Studio', () => {
3+
describe('Connection Dialogue', () => {
4+
after(() => {
5+
// cleanup connections before each test
6+
cy.visit('/')
7+
cy.get('.fusion-item')
8+
.rightclick()
9+
.then(() => {
10+
cy.get('[data-command="fusion.disconnect"] > .p-Menu-itemLabel')
11+
.click()
12+
cy.get('.main').click()
13+
})
14+
})
15+
16+
it('should create a connection', () => {
517
cy.visit('/')
618
cy.get('#theia-top-panel .p-MenuBar-item').contains('File')
719
.click()
820
.then(() => {
921
cy.get('[data-command="fusion.connect"] > .p-Menu-itemLabel')
1022
.contains('New Server.')
11-
.trigger('mousemove')
1223
.click()
1324
// set connection credentials
14-
cy.get('div.name-field > input').clear().type('localhost')
15-
cy.get('div.server-field > input').clear().type('http://localhost:8080')
16-
cy.get('div.username-field > input').clear().type('admin')
17-
cy.get('div.password-field > input').clear()
18-
cy.get('.main').click()
25+
cy.get('div.name-field > input').clear().type('server1')
26+
cy.get('div.server-field > input').clear().type('http://localhost:8080')
27+
cy.get('div.username-field > input').clear().type('admin')
28+
cy.get('div.password-field > input').clear()
29+
cy.get('.main').click()
30+
})
31+
// see it in action
32+
cy.get('.ReactVirtualized__Grid')
33+
.should('be.visible')
34+
.should('contain', 'server1')
35+
cy.get('.fusion-item')
36+
.click()
37+
.then(() => {
38+
cy.get('.ReactVirtualized__Grid__innerScrollContainer')
39+
.should('contain', 'db')
40+
.should('contain', 'RestXQ')
41+
})
42+
})
43+
44+
it('should fail gracefully', () => {
45+
// Use a differet route
46+
cy.get('#fusion-toolbar-button-add > .fa-fw')
47+
.click()
48+
.then(() => {
49+
// bad credentials
50+
cy.get('div.name-field > input').clear().type('server2')
51+
cy.get('div.server-field > input').clear().type('http://localhost:8080')
52+
cy.get('div.username-field > input').clear().type('badmin')
53+
cy.get('.main').click()
54+
})
55+
56+
// see it in action
57+
cy.get('.ReactVirtualized__Grid')
58+
.should('be.visible')
59+
.should('contain', 'server2')
60+
cy.get(`[node-id=${CSS.escape('badmin@http://localhost:8080')}]`)
61+
.click()
62+
.then(() => {
63+
cy.get('.dialogContent')
64+
// TODO(DP): #408 this needs a meaningful error message
65+
.contains('error')
66+
cy.get('.dialogControl > .theia-button').click()
67+
})
68+
})
69+
70+
it('should remove bad connection', () => {
71+
cy.get(`[node-id=${CSS.escape('badmin@http://localhost:8080')}]`)
72+
.rightclick()
73+
.then(() => {
74+
cy.get('[data-command="fusion.disconnect"] > .p-Menu-itemLabel')
75+
.click()
76+
cy.get('.dialogContent')
77+
.contains('you sure')
78+
cy.get('.main').click()
1979
})
20-
// set connection credentials
21-
// cy.get('div.name-field > input').clear().type('localhost')
22-
// cy.get('div.server-field > input').clear().type('http://localhost:8080')
23-
// cy.get('div.username-field > input').clear().type('admin')
24-
// const passwordField = cy.get('div.password-field > input').clear();
25-
// // if (password) {
26-
// // passwordField.type(password);
27-
// // }
28-
// cy.get(dialogMainButton).click();
29-
// cy.getTreeNode('admin' + '@' + 'http://localhost:8080').click();
30-
// cy.waitForLoading();
31-
});
80+
cy.get('.ReactVirtualized__Grid')
81+
.should('be.visible')
82+
.should('not.contain', 'server2')
83+
})
3284
})
85+
86+
3387
})

cypress/integration/api.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ context('Fusion Studio', function () {
3131
cy.getTreeNode(mkApiPathUrl('admin', '/db')).should('exist');
3232
})
3333
// TODO(DP) this test is failing properly it seems, figure out why and adjust test logic
34-
it.skip('shouldn\'t connect with older api', function () {
34+
it('shouldn\'t connect with older api', function () {
3535
cy.visit('/', {
3636
onBeforeLoad(win) {
3737
cy.stub(win, 'fetch').callThrough().withArgs(mkApiUrl('/version')).as('version api').resolves({
@@ -47,15 +47,14 @@ context('Fusion Studio', function () {
4747
"exist-db": {
4848
"compatible-version" : "0.0.1"
4949
}
50-
5150
}),
5251
});
5352
},
5453
}).get('#theia-top-panel', {timeout: 60000})
5554
.should('be.visible')
5655
.get('.theia-preload').should('not.exist');
5756
cy.addConnection();
58-
// cy.get(dialogTitle).should('contain.text', 'New Connection');
57+
cy.get(dialogTitle).should('contain.text', 'New Connection');
5958
cy.get(dialogBody).should('be.visible')
6059
.should('contain.text', 'Outdated API "0.0.1"')
6160
.should('contain.text', 'You need to update your API to version "0.2.0" or higher');

cypress/integration/tree_spec.js

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,6 @@
22
import { apiHost, apiPort } from '../support/config.js';
33
// TODO(DP): more folding in here
44
context('Fusion Studio', function() {
5-
describe('Connections', function() {
6-
beforeEach('IDE', function(){
7-
cy.visit('/')
8-
.get('#theia-top-panel', {timeout: 60000})
9-
.should('be.visible')
10-
.get('.theia-preload').should('not.exist');
11-
})
12-
it('create a new connection', function(){
13-
// trigger new connection dialog
14-
cy.get(':nth-child(1) > .p-MenuBar-itemLabel')
15-
.click()
16-
.then(() => {
17-
cy.get('[data-command="fusion.connect"] > .p-Menu-itemLabel')
18-
.contains('New Server.')
19-
.trigger('mousemove')
20-
.click()
21-
})
22-
// set connection credentials
23-
cy.get('div.name-field > input').clear().type(apiHost)
24-
cy.get('div.server-field > input').clear().type( apiHost + apiPort)
25-
cy.get('div.username-field > input').clear().type('admin')
26-
cy.get('div.password-field > input').clear()
27-
// open connection
28-
cy.get('.main').click()
29-
// see it in action
30-
cy.get('.ReactVirtualized__Grid')
31-
.should('be.visible')
32-
.should('contain', apiHost)
33-
cy.get('.fusion-item')
34-
.click()
35-
.then(() => {
36-
cy.get('.ReactVirtualized__Grid__innerScrollContainer')
37-
.should('contain', 'db')
38-
.should('contain', 'RestXQ')
39-
})
40-
})
41-
it('fails gracefully', function(){
42-
// trigger new connection dialog
43-
cy.get(':nth-child(1) > .p-MenuBar-itemLabel')
44-
.click()
45-
.then(() => {
46-
cy.get('[data-command="fusion.connect"] > .p-Menu-itemLabel')
47-
.contains('New Server.')
48-
.trigger('mousemove')
49-
.click()
50-
})
51-
// bad credentials
52-
cy.get('.password-field > input')
53-
.type('123456')
54-
cy.get('.main').click()
55-
// see it in action
56-
cy.get('.ReactVirtualized__Grid')
57-
.should('be.visible')
58-
.should('contain', 'localhost')
59-
cy.get('.fusion-item')
60-
.click()
61-
.then(() => {
62-
cy.get('.ReactVirtualized__Grid__innerScrollContainer')
63-
.should('not.contain', 'db')
64-
.should('not.contain', 'RestXQ')
65-
})
66-
})
67-
})
68-
695
describe('Security', function() {
706
before('Connect', function () {
717
cy.visit('/')

cypress/support/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { apiHost, apiPort } from '../support/config.js';
22

3+
// CSS does not require custom approach
4+
// see https://docs.cypress.io/faq/questions/using-cypress-faq#How-do-I-use-special-characters-with-cy-get
35
export function treenode(id) {
46
return '[node-id=' + CSS.escape(id) + ']';
57
}

0 commit comments

Comments
 (0)