Skip to content

Commit 5aafe5d

Browse files
authored
Merge pull request #409 from duncdrum/e2e-rewrite
fix(connection_spec): isolate connection test
2 parents f8cb91c + a15c83c commit 5aafe5d

19 files changed

+491
-212
lines changed

cypress.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"baseUrl": "http://localhost:3000",
33
"ignoreTestFiles": "**/integration/examples/*.*",
44
"projectId": "ftw148",
5-
"experimentalFetchPolyfill": true
5+
"experimentalFetchPolyfill": true,
6+
"env": {
7+
"API_HOST": "http://localhost:8080"
8+
}
69
}

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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/// <reference types="Cypress" />
2+
context('Fusion Studio', () => {
3+
describe('Connection Dialogue', () => {
4+
before(() => {
5+
cy.connect()
6+
})
7+
8+
it('should create a connection', () => {
9+
cy.visit('/')
10+
// see it in action
11+
cy.get('.ReactVirtualized__Grid')
12+
.should('be.visible')
13+
.should('contain', 'localhost')
14+
cy.get('.fusion-item')
15+
.click()
16+
.then(() => {
17+
cy.get('.ReactVirtualized__Grid__innerScrollContainer')
18+
.should('contain', 'db')
19+
.should('contain', 'RestXQ')
20+
})
21+
})
22+
23+
})
24+
25+
26+
})
Lines changed: 90 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,102 @@
11
/// <reference types="Cypress" />
2-
context('Fusion Studio', function () {
3-
describe('Connection Dialog', function () {
4-
it('should accept user input', function () {
2+
context('Connecting to Servers', () => {
3+
describe('Connection Dialogue', () => {
4+
after(() => {
5+
// cleanup connections after test
6+
cy.clearLocalStorage('connections')
7+
cy.reload()
8+
})
9+
10+
it('should create a connection', () => {
511
cy.visit('/')
612
cy.get('#theia-top-panel .p-MenuBar-item').contains('File')
713
.click()
814
.then(() => {
915
cy.get('[data-command="fusion.connect"] > .p-Menu-itemLabel')
1016
.contains('New Server.')
11-
.trigger('mousemove')
1217
.click()
1318
// 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()
19+
cy.get('div.name-field > input').clear().type('server1')
20+
cy.get('div.server-field > input').clear().type(Cypress.env('API_HOST'))
21+
cy.get('div.username-field > input').clear().type('admin')
22+
cy.get('div.password-field > input').clear()
23+
cy.get('.main').click()
1924
})
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-
});
25+
// see it in action
26+
cy.get('.ReactVirtualized__Grid')
27+
.should('be.visible')
28+
.should('contain', 'server1')
29+
cy.get('.fusion-item')
30+
.click()
31+
.then(() => {
32+
cy.get('.ReactVirtualized__Grid__innerScrollContainer')
33+
.should('contain', 'db')
34+
.should('contain', 'RestXQ')
35+
})
36+
})
37+
38+
it('should fail gracefully', () => {
39+
// Use a differet route
40+
cy.get('#fusion-toolbar-button-add > .fa-fw')
41+
.click()
42+
.then(() => {
43+
// bad credentials
44+
cy.get('div.name-field > input').clear().type('server2')
45+
cy.get('div.server-field > input').clear().type(Cypress.env('API_HOST'))
46+
cy.get('div.username-field > input').clear().type('badmin')
47+
cy.get('.main').click()
48+
})
49+
50+
// see it in action
51+
cy.get('.ReactVirtualized__Grid')
52+
.should('be.visible')
53+
.should('contain', 'server2')
54+
cy.get(`[node-id=${CSS.escape('badmin@' + Cypress.env('API_HOST'))}]`)
55+
.click()
56+
.then(() => {
57+
cy.get('.dialogContent')
58+
// TODO(DP): #408 this needs a meaningful error message
59+
.contains('error')
60+
cy.get('.dialogControl > .theia-button').click()
61+
})
62+
})
63+
64+
65+
// TODO(DP): add Connection properties tests here (rename and contencheck)
66+
// it('Connection properties', function () {
67+
// cy.waitForLoading();
68+
// cy.getTreeNode(mkApiPathUrl('admin')).rightclick()
69+
// .getMenuCommand('fusion.properties').should('be.visible').click()
70+
// cy.get(dialogTitle).should('contain.text', 'Edit Connection');
71+
// cy.get(dialogBody).should('be.visible').then(body => {
72+
// cy.wrap(body).find('.vertical-form .name-field span').contains('Connection Name:')
73+
// .find('+ input.theia-input[type=text]').should('have.value', 'localhost');
74+
// cy.wrap(body).find('.vertical-form .server-field span').contains('Server URI:')
75+
// .find('+ input.theia-input[type=text]').should('have.value', apiHost + apiPort);
76+
// cy.wrap(body).find('.vertical-form .username-field span').contains('Username:')
77+
// .find('+ input.theia-input[type=text]').should('have.value', 'admin');
78+
// cy.wrap(body).find('.vertical-form .password-field span').contains('Password')
79+
// .find('+ input.theia-input[type=password]').should('have.value', '');
80+
// cy.get(dialogSecondaryButton).should('be.visible').click();
81+
// cy.get(dialog).should('not.exist');
82+
// });
83+
// })
84+
85+
it('should remove bad connection', () => {
86+
cy.get(`[node-id=${CSS.escape('badmin@' + Cypress.env('API_HOST'))}]`)
87+
.rightclick()
88+
.then(() => {
89+
cy.get('[data-command="fusion.disconnect"] > .p-Menu-itemLabel')
90+
.click()
91+
cy.get('.dialogContent')
92+
.contains('you sure')
93+
cy.get('.main').click()
94+
})
95+
cy.get('.ReactVirtualized__Grid')
96+
.should('be.visible')
97+
.should('not.contain', 'server2')
98+
})
3299
})
100+
101+
33102
})

cypress/integration/02_api-spec.js

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

3-
context('Fusion Studio', function () {
4-
describe('API version', function () {
5-
it('should connect with newer api', function () {
3+
context('Talking to the api directly', () => {
4+
describe('API version', () => {
5+
it.skip('should connect with newer api', () => {
66
cy.visit('/')
77
// TODO: Why does this have UUID is the ID stable, this needs a meaningful selector
88
.get('#d184cace-9938-4ad5-b8df-925a91942661')
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/// <reference types="Cypress" />
2+
context('Evaluation', () => {
3+
before(() => {
4+
cy.visit('/')
5+
.get('#theia-top-panel')
6+
.should('be.visible')
7+
.get('.theia-preload').should('not.exist')
8+
})
9+
10+
describe('The Theia Panel', () => {
11+
it('should be accessible from command panel', () => {
12+
// invoke command panel and run the command
13+
cy.get('body').trigger('keydown', { keyCode: 112, which: 112 })
14+
.trigger('keyup', { keyCode: 112, which: 112 })
15+
cy.get('.quick-open-overlay .quick-open-input input')
16+
.clear()
17+
.type('>Toggle Evaluation View{enter}')
18+
// check the panel
19+
cy.get('.x-body')
20+
.should('be.visible')
21+
cy.get('#shell-tab-fusion-eval')
22+
.should('contain', 'Evaluation')
23+
cy.get('#fusion-eval')
24+
.should('be.visible')
25+
})
26+
27+
it('should offer serialization selections', () => {
28+
cy.get('.x-header > span.x-document')
29+
.should('contain', 'Open a document to evaluate.')
30+
cy.get('.x-header > span.x-document + span.x-separator + span')
31+
.should('contain', 'Serialization Type:')
32+
cy.get('.x-header > select')
33+
.should('be.disabled')
34+
.should('contain.text', 'Adaptive')
35+
.should('contain.text', 'XML')
36+
.should('contain.text', 'JSON')
37+
.should('contain.text', 'Text')
38+
})
39+
40+
// TODO see #401
41+
it.skip('should let users do stuff', () => {
42+
cy.get('.x-footer > :nth-child(4)')
43+
.contains('file')
44+
.click()
45+
})
46+
47+
it('should have proper header and footer', () => {
48+
cy.get('.x-header > button')
49+
.should('be.disabled')
50+
.should('contain', 'Evaluate')
51+
cy.get('.x-body')
52+
.should('be.empty')
53+
cy.get('.x-footer > button')
54+
.should('be.disabled')
55+
.should('contain', 'New file')
56+
})
57+
58+
it('should disappear again', () => {
59+
// invoke command panel and run the command again
60+
cy.get('body')
61+
.trigger('keydown', { keyCode: 112, which: 112 })
62+
.trigger('keyup', { keyCode: 112, which: 112 })
63+
cy.get('.quick-open-overlay .quick-open-input input')
64+
.clear()
65+
.type('>Toggle Evaluation View{enter}')
66+
// check the panel
67+
cy.get('#shell-tab-fusion-eval')
68+
.should('not.be.visible')
69+
cy.get('#fusion-eval')
70+
.should('not.be.visible')
71+
})
72+
})
73+
})

0 commit comments

Comments
 (0)