Skip to content

Commit 800fa00

Browse files
committed
added upload dialog test
1 parent fd9318b commit 800fa00

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

cypress/integration/04_document_spec.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ context('Document Operations', () => {
160160
.type('{esc}')
161161
})
162162

163-
it('should upload a document', () => {
163+
it('should upload a document using drag and drop', () => {
164164
cy.extendedFiles().then(win => {
165165
const file = new win.ExFile('/', [new Blob(['sample text content.'])], 'upload_test.txt', { type: 'text/plain' })
166166

@@ -182,6 +182,38 @@ context('Document Operations', () => {
182182
})
183183
})
184184

185+
it('should upload a document using the upload dialog', () => {
186+
cy.writeFile(require('path').resolve(Cypress.env('homedir'), 'upload_file_test.txt'), 'sample text content');
187+
cy.get('[node-id$=test]')
188+
.rightclick()
189+
cy.get('[data-command="fusion.upload-document"]')
190+
.should('be.visible')
191+
.contains('Upload document(s)')
192+
.click()
193+
cy.get('.dialogBlock .theia-Tree.theia-FileTree')
194+
const timer = Date.now();
195+
new Cypress.Promise((resolve, reject) => {
196+
function tick() {
197+
const file = cy.$$('.theia-TreeNode:contains(upload_file_test.txt)');
198+
if (file.length) {
199+
cy.wrap(file[0])
200+
.click({ force: true })
201+
cy.get('.main').click();
202+
fetchSpy.calledWithMatch(Cypress.env('API_HOST') + '/exist/restxqs/fusiondb/document?uri=/db/test/upload_file_test.txt', { method: 'PUT' })
203+
cy.get('[node-id$="test\\/upload_file_test.txt"]')
204+
.should('be.visible')
205+
resolve();
206+
} else {
207+
if (Date.now() < timer + 5000) {
208+
cy.get('.theia-FileTree.theia-FileDialog.ps .ps__rail-y').click('bottom', { force: true })
209+
cy.wait(100).then(tick);
210+
}
211+
}
212+
}
213+
tick()
214+
})
215+
})
216+
185217
it('should move a document', () => {
186218
const dataTransfer = new DataTransfer();
187219
cy.get('[node-id$="test\\/test.xml"]')

cypress/plugins/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ module.exports = (on, config) => {
5858
report: process.report,
5959
traceDeprecation: process.traceDeprecation,
6060
};
61+
config.env.homedir = require('os').homedir();
6162
return config;
6263
}

0 commit comments

Comments
 (0)