Skip to content

Commit

Permalink
added upload dialog test
Browse files Browse the repository at this point in the history
  • Loading branch information
ccheraa committed Jun 18, 2021
1 parent 3894000 commit dd3ebb6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 33 additions & 1 deletion cypress/integration/04_document_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ context('Document Operations', () => {
.type('{esc}')
})

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

Expand All @@ -182,6 +182,38 @@ context('Document Operations', () => {
})
})

it('should upload a document using the upload dialog', () => {
cy.writeFile(require('path').resolve(Cypress.env('homedir'), 'upload_file_test.txt'), 'sample text content');
cy.get('[node-id$=test]')
.rightclick()
cy.get('[data-command="fusion.upload-document"]')
.should('be.visible')
.contains('Upload document(s)')
.click()
cy.get('.dialogBlock .theia-Tree.theia-FileTree')
const timer = Date.now();
new Cypress.Promise((resolve, reject) => {
function tick() {
const file = cy.$$('.theia-TreeNode:contains(upload_file_test.txt)');
if (file.length) {
cy.wrap(file[0])
.click({ force: true })
cy.get('.main').click();
fetchSpy.calledWithMatch(Cypress.env('API_HOST') + '/exist/restxqs/fusiondb/document?uri=/db/test/upload_file_test.txt', { method: 'PUT' })
cy.get('[node-id$="test\\/upload_file_test.txt"]')
.should('be.visible')
resolve();
} else {
if (Date.now() < timer + 5000) {
cy.get('.theia-FileTree.theia-FileDialog.ps .ps__rail-y').click('bottom', { force: true })
cy.wait(100).then(tick);
}
}
}
tick()
})
})

it('should move a document', () => {
const dataTransfer = new DataTransfer();
cy.get('[node-id$="test\\/test.xml"]')
Expand Down
2 changes: 2 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
config.env.homedir = require('os').homedir();
return config;
}

0 comments on commit dd3ebb6

Please sign in to comment.