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} )
0 commit comments