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