-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path04_document_spec.js
More file actions
289 lines (273 loc) · 10.1 KB
/
Copy path04_document_spec.js
File metadata and controls
289 lines (273 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/// <reference types="Cypress" />
context('Document Operations', () => {
describe('working with tree view', () => {
before(() => {
cy.connect()
cy.visit('/')
cy.get(`[node-id=${CSS.escape('admin@' + Cypress.env('API_HOST'))}]`)
.should('be.visible')
})
after(() => {
// make sure all test files are gone see #400
cy.get('[node-id$=db]')
.should('be.visible')
cy.get('[node-id$=untitled-1]')
.should('not.exist')
cy.get('[node-id$=test\\.txt]')
.should('not.exist')
cy.get('[node-id$=test\\.xml]')
.should('not.exist')
cy.get('[node-id$=untitled-2]')
.should('not.exist')
})
describe('db context menu', () => {
it('should create documents', () => {
cy.get('.ReactVirtualized__Grid')
.should('be.visible')
cy.get('.fusion-item')
.should('be.visible')
.click({ animationDistanceThreshold: 2 })
// all we need is the final part of the node-id attribute
cy.get('[node-id$=db]')
.should('be.visible')
.rightclick()
.then(() => {
cy.get('.p-Menu')
.should('be.visible')
.contains('New document')
.trigger('mousemove')
cy.get('[data-command="fusion.new-document"] > .p-Menu-itemLabel')
.should('be.visible')
.click()
})
// (DP) untitled-1 document has been created
// (DP): start workaround for #413
cy.get('.fusion-item')
.should('be.visible')
.click({ animationDistanceThreshold: 2 })
cy.get('[node-id$=db]')
.should('be.visible')
.focused()
.type('{enter}')
// end workaround for #413
cy.get('.ReactVirtualized__Grid')
.should('be.visible')
.contains('untitled-1')
// (DP) cleanup welcome tab so we don't have to deal with it in later tests
cy.get('#shell-tab-fusion-welcome > .p-TabBar-tabCloseIcon')
.click()
cy.get('#shell-tab-fusion-welcome')
.should('not.exist')
// TODO(DP):
// - add test for #413 : remove workaround
// - check if tree view is deselected (it is but need not be),
// - check if Explorer is updated properly (seems inconsistent need to double click)
// - check if editor window is opening the newly create doc in a new tab (it doesn't)
// - two file create routes one with follow-up dialog (xquery lib) one without (txt, xml)
})
// see https://github.com/cypress-io/cypress/pull/15388/files#
// see #414
it('should edit document contents', () => {
cy.get('.fusion-item')
.should('be.visible')
// (DP) edit and save untitled-1
cy.get('[node-id$=untitled-1]')
.dblclick()
if (Cypress.platform === 'darwin') {
cy.get('.view-line')
.type('asdf{meta+s}')
} else {
cy.get('.view-line')
.type('asdf{ctrl+s}')
}
// (DP): see #525 close edited editor pane
cy.get('#theia-main-content-panel > .p-TabBar > .p-TabBar-content-container > .p-TabBar-content')
.within(() => {
cy.get('.p-TabBar-tabCloseIcon')
.click({ multiple: true })
})
cy.get('.main')
.click()
cy.get('.view-lines')
.should('not.exist')
cy.get('[node-id$=untitled-1]')
.should('exist')
cy.get('[node-id$=untitled-2]')
.should('not.exist')
})
// (DP): Fix #527 then finish this
it.skip('should load previously stored document', () => {
cy.get('.fusion-item')
.should('be.visible')
cy.get('[node-id$=untitled-1]')
.dblclick()
cy.get('.view-lines')
.should('exist')
.contains('asdf')
cy.get('#theia-main-content-panel > .p-TabBar > .p-TabBar-content-container > .p-TabBar-content')
.within(() => {
cy.get('.p-TabBar-tabCloseIcon')
.click({ multiple: true })
})
cy.get('.main')
.click()
cy.get('[node-id$=untitled-1]')
.should('exist')
cy.get('[node-id$=untitled-2]')
.should('not.exist')
})
it('should display document properties', () => {
cy.get('[node-id$=untitled-1]')
.should('be.visible')
.type('{alt+enter}', { force: true })
cy.get('.dialogTitle')
.should('contain.text', 'Properties')
// check properties table
// TODO (DP) # 519 flaky test, properties table changes based on filetype
// hence only check visibility.
cy.get('.dialogContent')
.find('.keys > tr')
// .should('have.length', 11)
// .should('contain.text', 'Media Type')
.should('be.visible')
cy.get('.dialogContent')
.find('.keys > tr')
.should('contain.text', 'Owner')
// check permissions table
cy.get('.dialogContent')
.find('.permissions-editor > tr')
.should('have.length', 3)
.should('contain.text', 'user')
cy.get('.secondary')
.click()
cy.get('[node-id$=untitled-1]')
.should('exist')
})
it('should not create duplicate documents', () => {
cy.get('[node-id$=db]')
.should('be.visible')
.rightclick()
.then(() => {
cy.get('.p-Menu')
.should('be.visible')
.contains('New document')
.trigger('mousemove')
cy.get('[data-command="fusion.new-document"] > .p-Menu-itemLabel')
.should('be.visible')
.click()
cy.get('.fs-inline-input > .theia-input')
.clear()
.type('untitled-1{enter}')
cy.get('.error')
.should('exist')
.should('contain.text', 'Item already exists')
.type('{esc}')
cy.get('[node-id$=untitled-1]')
.should('exist')
})
})
it('should delete documents', () => {
cy.get('[node-id$=untitled-1]')
.should('be.visible')
.rightclick()
cy.get('[data-command="fusion.delete"] > .p-Menu-itemLabel')
.should('be.visible')
.click()
cy.get('.main')
.click()
cy.get('[node-id$=db]')
.should('be.visible')
cy.get('[node-id$=untitled-1]')
.should('not.exist')
})
// see #414 workaround is to run this after editing and saving the document,
// we should be able to rename before editing content
it.skip('should let users rename documents', () => {
cy.get('.fusion-item')
.should('exist')
// (DP) rename untitled-1 -> test.xml
cy.get('[node-id$=untitled-1]')
.should('be.visible')
// (DP) press F2 not working see #526
// .trigger('keydown', { keyCode: 112, which: 112 })
// .trigger('keyup', { keyCode: 112, which: 112 })
// (DP) see #522
.rightclick({ force: true })
cy.get('[data-command="fusion.rename"] > .p-Menu-itemLabel')
.should('be.visible')
.click()
.focused()
.clear()
.type('test.txt{enter}', { force: true })
// (DP): see #414 here the funkyness starts instead of having renamed the first file upon hitting {enter}
// - we now have 2 files in the db tree untitled-1 and test.txt, there should only be 1 => test.txt
// - test.txt isn't really renamed as its contents are empty, it should have the contents previously stored as untitled-1
// - uncomment the following to test any potential fixes
// cy.get('[node-id$=untitled-1]')
// .should('not.exist')
// (DP): failed workaround which needs to include a subworkaround but ultimately fails due to #527
// cy.get('.ReactVirtualized__Grid')
// .then(() => {
// cy.get('[node-id$=test\\.txt]')
// .dblclick()
// })
// if (Cypress.platform === 'darwin') {
// cy.get('.view-line')
// .type('fdsa{meta+s}')
// } else {
// cy.get('.view-line')
// .type('fdsa{ctrl+s}')
// }
// // (DP): subworkaround #525 close edited editor pane
// cy.get('#theia-main-content-panel > .p-TabBar > .p-TabBar-content-container > .p-TabBar-content')
// .within(() => {
// cy.get('.p-TabBar-tabCloseIcon')
// .click({ multiple: true })
// })
// cy.get('.main')
// .click()
// (DP): end workarounds #414 #525 #527
// (DP): if #414 is fixed the below needs to be activated
// cy.get('[node-id$=test\\.txt]')
// .should('be.visible')
})
it.skip('should not create duplicate documents', () => {
cy.get('[node-id$=db]')
.should('be.visible')
.rightclick()
.then(() => {
cy.get('.p-Menu')
.should('be.visible')
.contains('New document')
.trigger('mousemove')
cy.get('[data-command="fusion.new-document"] > .p-Menu-itemLabel')
.should('be.visible')
.click()
cy.get('.fs-inline-input > .theia-input')
.clear()
.type('test.txt{enter}')
cy.get('.error')
.should('exist')
.should('contain.text', 'Item already exists')
// DP see #414 activate to confirm fix
// cy.get('[node-id$=untitled-1]')
// .should('not.exist')
})
})
it.skip('should delete documents', () => {
cy.get('[node-id$=test\\.txt]')
.should('be.visible')
.rightclick()
cy.get('[data-command="fusion.delete"] > .p-Menu-itemLabel')
.should('be.visible')
.click()
cy.get('.main')
.click()
cy.get('[node-id$=db]')
.should('be.visible')
cy.get('[node-id$=test\\.txt]')
.should('not.exist')
})
})
})
})