11/// <reference types="Cypress" />
2- context ( 'Basic Operations' , ( ) => {
3- describe ( 'working with tree view' , ( ) => {
4- before ( ( ) => {
5- cy . connect ( )
6- } )
72
8- describe ( 'db context menu' , ( ) => {
9- it ( 'should display creation options' , ( ) => {
10- cy . visit ( '/' )
11- cy . get ( '.ReactVirtualized__Grid' , { timeout : 55000 } )
12- . should ( 'be.visible' )
13- cy . get ( '.fusion-item' )
14- . click ( )
15- // all we need is the final part of the node-id attribute
16- cy . get ( '[node-id$=db]' )
17- . rightclick ( )
18- . then ( ( ) => {
19- cy . get ( '.p-Menu' )
20- . should ( 'be.visible' )
21- . contains ( 'New document' )
22- . trigger ( 'mousemove' )
23- cy . get ( '[data-command="fusion.new-document"] > .p-Menu-itemLabel' )
24- . should ( 'be.visible' )
25- . click ( )
26- } )
27- // (DP): start workaround for #413
28- cy . get ( '[node-id$=db]' )
29- . trigger ( 'mousemove' )
30- . type ( '{enter}' )
31- // end workaround for #413
32- cy . get ( '.ReactVirtualized__Grid' )
33- . contains ( 'untitled-1' )
3+ context ( 'Document Operations' , ( ) => {
4+ describe ( 'working with tree view' , ( ) => {
5+ before ( ( ) => {
6+ cy . connect ( )
7+ // TODO(DP): might have to improve by adding more before / after hooks to prevent dangling documents
8+ // see #400
9+ } )
10+
11+ describe ( 'db context menu' , ( ) => {
12+ it ( 'should display creation options' , ( ) => {
13+ cy . visit ( '/' )
14+ cy . get ( '.ReactVirtualized__Grid' , { timeout : 55000 } )
15+ . should ( 'be.visible' )
16+ cy . get ( '.fusion-item' )
17+ . click ( )
18+ // all we need is the final part of the node-id attribute
19+ cy . get ( '[node-id$=db]' )
20+ . rightclick ( )
21+ . then ( ( ) => {
22+ cy . get ( '.p-Menu' )
23+ . should ( 'be.visible' )
24+ . contains ( 'New document' )
25+ . trigger ( 'mousemove' )
26+ cy . get ( '[data-command="fusion.new-document"] > .p-Menu-itemLabel' )
27+ . should ( 'be.visible' )
28+ . click ( )
29+ } )
30+ // (DP): start workaround for #413
31+ cy . get ( '[node-id$=db]' )
32+ . trigger ( 'mousemove' )
33+ . type ( '{enter}' )
34+ // end workaround for #413
35+ cy . get ( '.ReactVirtualized__Grid' )
36+ . contains ( 'untitled-1' )
37+
38+ // TODO(DP):
39+ // - add test for #413 : change order, remove workaround, might need a call to focused()
40+ // - check if tree view is deselected (it is but need not be),
41+ // - check if Explorer is updated properly (seems inconsistent need to double click)
42+ // - check if editor window is opening the newly create doc in a new tab (it doesn't)
43+ // - two file create routes one with follow-up dialog (xquery lib) one without (txt, xml)
44+ } )
45+
46+ // TODO(DP): make this work on all OS by either adjusting the key sequence ctrl+s cmd+s …
47+ // or by using the file menu UI instead
48+ // see #414
49+ it ( 'should let users edit new document' , ( ) => {
50+ cy . get ( '[node-id$=untitled-1]' )
51+ . dblclick ( )
52+ cy . get ( '.view-line' )
53+ . type ( 'asdf{meta+s}' )
54+ } )
55+ // see #414 workaround is to run this after editing and saving the document,
56+ // we should be able to rename before entering content
57+ it ( 'should let users rename documents' , ( ) => {
58+ cy . get ( '[node-id$=untitled-1]' )
59+ . rightclick ( )
60+ cy . get ( '[data-command="fusion.rename"] > .p-Menu-itemLabel' )
61+ . should ( 'be.visible' )
62+ . click ( )
63+ . focused ( )
64+ . type ( 'test.txt{enter}' )
65+ } )
3466
35- // TODO(DP):
36- // - add test for #413 : change order, remove workaround, might need a call to focused()
37- // - check if tree view is deselected (it is but need not be),
38- // - check if Explorer is updated properly (seems inconsistent need to double click)
39- // - check if editor window is opening the newly create doc in a new tab (it doesn't)
40- // - two file create routes one with follow-up dialog (xquery lib) one without (txt, xml)
41- } )
67+ it ( 'should display document properties' , ( ) => {
68+ cy . get ( '[node-id$=test\\.txt]' )
69+ . rightclick ( )
70+ . type ( '{alt+enter}' , { force : true } )
71+ cy . get ( '.dialogTitle' )
72+ . should ( 'contain.text' , 'Properties' )
73+ // rename file -> text.xml
74+ cy . get ( '.value > .theia-input' )
75+ . clear ( )
76+ . type ( 'test.xml' )
77+ // check properties table
78+ cy . get ( '.dialogContent' )
79+ . find ( '.keys > tr' )
80+ . should ( 'have.length' , 11 )
81+ . contains ( 'Media Type' )
82+ cy . get ( '.dialogContent' )
83+ . find ( '.keys > tr' )
84+ . contains ( 'Owner' )
85+ // check permissions table
86+ cy . get ( '.dialogContent' )
87+ . find ( '.permissions-editor > tr' )
88+ . should ( 'have.length' , 3 )
89+ . contains ( 'user' )
90+ cy . get ( '.main' )
91+ . click ( )
92+ } )
4293
43- // TODO(DP): make this work on all OS by either adjusting the key sequence ctrl+s cmd+s …
44- // or by using the file menu UI instead
45- // see #414
46- it ( 'should let users edit new document' , ( ) => {
47- cy . get ( '[node-id$=untitled-1]' )
48- . dblclick ( )
49- cy . get ( '.view-line' )
50- . type ( 'asdf{meta+s}' )
51- } )
52- // see #414 workaround is to run this after editing and saving the document,
53- // we should be able to rename before entering content
54- it ( 'should let users rename documents' , ( ) => {
55- cy . get ( '[node-id$=untitled-1]' )
56- . rightclick ( )
57- cy . get ( '[data-command="fusion.rename"] > .p-Menu-itemLabel' )
58- . should ( 'be.visible' )
59- . click ( )
60- . focused ( )
61- . type ( 'test.txt{enter}' )
62- } )
94+ it ( 'should not create duplicate documents' , ( ) => {
95+ cy . get ( '[node-id$=db]' )
96+ . rightclick ( )
97+ . then ( ( ) => {
98+ cy . get ( '.p-Menu' )
99+ . should ( 'be.visible' )
100+ . contains ( 'New document' )
101+ . trigger ( 'mousemove' )
102+ cy . get ( '[data-command="fusion.new-document-template:xml"] > .p-Menu-itemLabel' )
103+ . should ( 'be.visible' )
104+ . click ( )
105+ cy . get ( '.fs-inline-input > .theia-input' )
106+ . clear ( )
107+ . type ( 'test.xml{enter}' )
108+ cy . get ( '.error' )
109+ . should ( 'exist' )
110+ . should ( 'contain.text' , 'Item already exists' )
111+ } )
112+ } )
63113
64- // TODO(DP): documents properties test could go here
65- // it('Document properties', function () {
66- // cy.waitForLoading();
67- // cy.getTreeNode(mkApiPathUrl('admin', '/db/test_col/text_file.txt')).rightclick()
68- // .getMenuCommand('fusion.properties').should('be.visible').click()
69- // cy.get(dialogTitle).should('contain.text', 'Properties');
70- // cy.get(dialogBody).should('be.visible').then(body => {
71- // cy.wrap(body).find('td.label').contains('Name')
72- // .find('+ td.value input.theia-input[type=text]').should('contain.value', 'text_file.txt');
73- // cy.wrap(body).find('td.label').contains('Collection')
74- // .find('+ td.value').should('contain.text', '/db/test_col');
75- // cy.wrap(body).find('td.label').contains('Created')
76- // .find('+ td.value').should('contain.text', Cypress.formatDate());
77- // cy.wrap(body).find('td.label').contains('Modified')
78- // .find('+ td.value').should('contain.text', Cypress.formatDate());
79- // cy.wrap(body).find('td.label').contains('Media Type')
80- // .find('+ td.value').should('contain.text', 'text/plain');
81- // cy.wrap(body).find('td.label').contains('Binary')
82- // .find('+ td.value').should('contain.text', 'Yes')
83- // .find('button.theia-button').should('contain.text', 'Convert to non-binary');
84- // cy.wrap(body).find('td.label').contains('Size')
85- // .find('+ td.value').should('contain.text', '24 B');
86- // cy.wrap(body).find('td.label').contains('Owner')
87- // .find('+ td.value input.theia-input[type=text]').should('contain.value', 'admin');
88- // cy.wrap(body).find('td.label').contains('Group')
89- // .find('+ td.value input.theia-input[type=text]').should('contain.value', 'dba');
90- // cy.wrap(body).find('table.permissions-editor tr').then(trs => {
91- // cy.wrap(trs).eq(0).find('td').then(tds => {
92- // cy.wrap(tds).eq(0).should('contain.text', 'user');
93- // cy.wrap(tds).eq(1).findCheckbox().should('contain.text', 'read').checked();
94- // cy.wrap(tds).eq(2).findCheckbox().should('contain.text', 'write').checked();
95- // cy.wrap(tds).eq(3).findCheckbox().should('contain.text', 'execute').notChecked();
96- // cy.wrap(tds).eq(4).findCheckbox().should('contain.text', 'setUID').notChecked();
97- // });
98- // cy.wrap(trs).eq(1).find('td').then(tds => {
99- // cy.wrap(tds).eq(0).should('contain.text', 'group');
100- // cy.wrap(tds).eq(1).findCheckbox().should('contain.text', 'read').checked();
101- // cy.wrap(tds).eq(2).findCheckbox().should('contain.text', 'write').notChecked();
102- // cy.wrap(tds).eq(3).findCheckbox().should('contain.text', 'execute').notChecked();
103- // cy.wrap(tds).eq(4).findCheckbox().should('contain.text', 'setGID').notChecked();
104- // });
105- // cy.wrap(trs).eq(2).find('td').then(tds => {
106- // cy.wrap(tds).eq(0).should('contain.text', 'other');
107- // cy.wrap(tds).eq(1).findCheckbox().should('contain.text', 'read').checked();
108- // cy.wrap(tds).eq(2).findCheckbox().should('contain.text', 'write').notChecked();
109- // cy.wrap(tds).eq(3).findCheckbox().should('contain.text', 'execute').notChecked();
110- // cy.wrap(tds).eq(4).findCheckbox().should('contain.text', 'sticky').notChecked();
111- // });
112- // });
113- // });
114- // cy.get(dialogSecondaryButton).should('be.visible').click();
115- // cy.get(dialog).should('not.exist');
116- // cy.getTreeNode(mkApiPathUrl('admin', '/db/test_col/xml_file.xml')).rightclick()
117- // .getMenuCommand('fusion.properties').should('be.visible').click()
118- // cy.get(dialogBody).should('be.visible').find('td.label').contains('Binary')
119- // .find('+ td.value').should('contain.text', 'No')
120- // .find('button.theia-button').should('contain.text', 'Convert to binary');
121- // cy.get(dialogSecondaryButton).should('be.visible').click();
122- // cy.get(dialog).should('not.exist');
123- // })
124- // TODO(DP): only allow unique document creation test should go here
125114
126- it ( 'should let users delete documents' , ( ) => {
127- cy . get ( '[node-id$=test\\.txt]' )
128- . rightclick ( )
129- cy . get ( '[data-command="fusion.delete"] > .p-Menu-itemLabel' )
130- . should ( 'be.visible' )
131- . click ( )
132- cy . get ( '.main' )
133- . click ( )
134- cy . get ( '[node-id$=test\\.txt]' )
135- . should ( 'not.exist' )
136- } )
137- } )
115+ it ( 'should let users delete documents' , ( ) => {
116+ cy . get ( '[node-id$=test\\.xml]' )
117+ . rightclick ( )
118+ cy . get ( '[data-command="fusion.delete"] > .p-Menu-itemLabel' )
119+ . should ( 'be.visible' )
120+ . click ( )
121+ cy . get ( '.main' )
122+ . click ( )
123+ // make sure all test files are gone see #400
124+ cy . get ( '[node-id$=untitled-1]' )
125+ . should ( 'not.exist' )
126+ cy . get ( '[node-id$=test\\.txt]' )
127+ . should ( 'not.exist' )
128+ cy . get ( '[node-id$=test\\.xml]' )
129+ . should ( 'not.exist' )
130+ cy . get ( '[node-id$=untitled-2]' )
131+ . should ( 'not.exist' )
132+ } )
138133 } )
134+ } )
139135} )
0 commit comments