Skip to content

Commit

Permalink
fix test (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdong262 committed Aug 21, 2018
1 parent 310488c commit de31752
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 144 deletions.
290 changes: 148 additions & 142 deletions test/e2e/004.basic-sftp.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ const {resolve} = require('path')
const {expect} = require('chai')
const cwd = process.cwd()
const delay = require('./common/wait')
const generate = require('./common/uid')
const isOs = require('./common/is-os')

if (!isOs('linux')) {
return
}

describe('sftp basic', function () {
this.timeout(100000)
Expand Down Expand Up @@ -51,149 +45,161 @@ describe('sftp basic', function () {
await client.setValue('#host', TEST_HOST)
await client.setValue('#username', TEST_USER)
await client.setValue('#password', TEST_PASS)
await delay(100)
await client.execute(function() {
document.querySelector('.ant-modal .ant-tabs-tabpane-active .ant-btn-primary').click()
})
await delay(500)
let tabsCount = await client.elements('.tabs .tabs-wrapper .tab')

expect(tabsCount.value.length).equal(2)
await delay(2010)

//click sftp tab
await client.execute(function() {
document.querySelectorAll('.ssh-wrap-show .term-sftp-tabs .type-tab')[1].click()
})
await delay(2500)

//make a local folder
let localFileListBefore = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
await client.rightClick('.ssh-wrap-show .virtual-file-local', 10, 10)
await client.execute(function() {
document.querySelector('.context-menu .anticon-folder-add').click()
})
await delay(200)
let fname = '00000test-electerm' + generate()
await client.setValue('.ssh-wrap-show .sftp-item input', fname)
await client.doubleClick('.ssh-wrap-show .sftp-title-wrap')
await delay(2500)
let localFileList = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
expect(localFileList.value.length).equal(localFileListBefore.value.length + 1)

//enter folder
await client.execute(function() {
let event = new MouseEvent('dblclick', {
'view': window,
'bubbles': true,
'cancelable': true
})
document.querySelectorAll('.ssh-wrap-show .file-list.local .sftp-item')[1].dispatchEvent(event)
})
await delay(2000)
let pathCurrentLocal = await client.getAttribute('.ssh-wrap-show .sftp-local-section .sftp-title input', 'value')
expect(pathCurrentLocal.includes(fname)).equal(true)
let localFileList0 = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
expect(localFileList0.value.length).equal(1)

//new file
await client.rightClick('.ssh-wrap-show .virtual-file-local', 10, 10)
await client.execute(function() {
document.querySelector('.context-menu .anticon-file-add').click()
})
await delay(200)
let fname00 = '00000test-electerm' + generate()
await client.setValue('.ssh-wrap-show .sftp-item input', fname00)
await client.doubleClick('.ssh-wrap-show .sftp-title-wrap')
await delay(2500)
let localFileList00 = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
expect(localFileList00.value.length).equal(2)

//select all and del Control
await client.rightClick('.ssh-wrap-show .virtual-file-local', 10, 10)
await client.execute(function() {
document.querySelector('.context-menu .anticon-check-square-o').click()
})
await delay(20)
await client.keys(['Delete'])
await delay(20)
await client.keys(['Enter'])
await delay(2000)
let localFileList11 = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
expect(localFileList11.value.length).equal(1)

//goto parent
await client.execute(function() {
document.querySelector('.ssh-wrap-show .sftp-local-section .anticon-arrow-up').click()
})
await delay(2000)
let localFileList1 = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
expect(localFileList1.value.length).equal(localFileList.value.length)


//del folder
await client.execute(function() {
document.querySelectorAll('.ssh-wrap-show .file-list.local .sftp-item')[1].click()
})
await delay(20)

await client.keys(['Delete'])
await delay(20)
await client.keys(['Enter'])
await delay(3000)
let localFileList2 = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
expect(localFileList2.value.length).equal(localFileListBefore.value.length)

//remote test
//make a remote folder
let remoteFileListBefore = await client.elements('.ssh-wrap-show .file-list.remote .sftp-item')
await client.rightClick('.ssh-wrap-show .virtual-file-remote', 10, 10)
await client.execute(function() {
document.querySelector('.context-menu .anticon-folder-add').click()
})
await delay(200)
let fname0 = '00000test-electerm-remote' + generate()
await client.setValue('.ssh-wrap-show .sftp-remote-section .sftp-item input', fname0)
await client.doubleClick('.ssh-wrap-show .sftp-title-wrap')
await delay(2500)
let remoteFileList = await client.elements('.ssh-wrap-show .file-list.remote .sftp-item')
expect(remoteFileList.value.length).equal(remoteFileListBefore.value.length + 1)

//enter folder
await client.execute(function() {
let event = new MouseEvent('dblclick', {
'view': window,
'bubbles': true,
'cancelable': true
})
document.querySelectorAll('.ssh-wrap-show .file-list.remote .sftp-item')[1].dispatchEvent(event)
})
await delay(2000)
let pathCurrentRemote = await client.getAttribute('.ssh-wrap-show .sftp-remote-section .sftp-title input', 'value')
expect(pathCurrentRemote.includes(fname0)).equal(true)
let remoteFileList0 = await client.elements('.ssh-wrap-show .file-list.remote .sftp-item')

expect(remoteFileList0.value.length).equal(1)

//goto parent
await client.execute(function() {
document.querySelector('.ssh-wrap-show .sftp-remote-section .anticon-arrow-up').click()
})
await delay(2000)
let remoteFileList1 = await client.elements('.ssh-wrap-show .file-list.remote .sftp-item')
expect(remoteFileList1.value.length).equal(remoteFileList.value.length)

//del folder
await client.execute(function() {
document.querySelectorAll('.ssh-wrap-show .file-list.remote .sftp-item .sftp-file-prop')[0].click()
})
await delay(20)

await client.keys(['Delete'])
await delay(20)
await client.keys(['Enter'])
await delay(3000)
let remoteFileList2 = await client.elements('.ssh-wrap-show .file-list.remote .sftp-item')
expect(remoteFileList2.value.length).equal(remoteFileListBefore.value.length)
// await delay(2010)

// //click sftp tab
// log('click sftp tab')
// await client.execute(function() {
// document.querySelectorAll('.ssh-wrap-show .term-sftp-tabs .type-tab')[1].click()
// })
// await delay(2500)

// //make a local folder
// let localFileListBefore = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
// await client.rightClick('.ssh-wrap-show .virtual-file-local', 10, 10)
// await delay(300)
// log('add folder')
// await client.execute(function() {
// document.querySelector('.context-menu .anticon-folder-add').click()
// })
// await delay(200)
// let fname = '00000test-electerm' + generate()
// await client.setValue('.ssh-wrap-show .sftp-item input', fname)
// await client.doubleClick('.ssh-wrap-show .sftp-title-wrap')
// await delay(2500)
// let localFileList = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
// expect(localFileList.value.length).equal(localFileListBefore.value.length + 1)

// //enter folder
// await client.execute(function() {
// let event = new MouseEvent('dblclick', {
// 'view': window,
// 'bubbles': true,
// 'cancelable': true
// })
// document.querySelectorAll('.ssh-wrap-show .file-list.local .sftp-item')[1].dispatchEvent(event)
// })
// await delay(2000)
// let pathCurrentLocal = await client.getAttribute('.ssh-wrap-show .sftp-local-section .sftp-title input', 'value')
// expect(pathCurrentLocal.includes(fname)).equal(true)
// let localFileList0 = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
// expect(localFileList0.value.length).equal(1)

// //new file
// await client.rightClick('.ssh-wrap-show .virtual-file-local', 10, 10)
// await delay(200)
// log('add file')
// await client.execute(function() {
// document.querySelector('.context-menu .anticon-file-add').click()
// })
// await delay(200)
// let fname00 = '00000test-electerm' + generate()
// await client.setValue('.ssh-wrap-show .sftp-item input', fname00)
// await client.doubleClick('.ssh-wrap-show .sftp-title-wrap')
// await delay(2500)
// let localFileList00 = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
// expect(localFileList00.value.length).equal(2)

// //select all and del Control
// await client.rightClick('.ssh-wrap-show .virtual-file-local', 10, 10)
// await delay(200)
// log('select all')
// await client.execute(function() {
// document.querySelector('.context-menu .anticon-check-square-o').click()
// })
// await delay(20)
// await client.keys(['Delete'])
// await delay(20)
// await client.keys(['Enter'])
// await delay(2000)
// let localFileList11 = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
// expect(localFileList11.value.length).equal(1)

// //goto parent
// await delay(20)
// log('goto parent')
// await client.execute(function() {
// document.querySelector('.ssh-wrap-show .sftp-local-section .anticon-arrow-up').click()
// })
// await delay(2000)
// let localFileList1 = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
// expect(localFileList1.value.length).equal(localFileList.value.length)


// //del folder
// log('del folder')
// await client.execute(function() {
// document.querySelectorAll('.ssh-wrap-show .file-list.local .sftp-item')[1].click()
// })
// await delay(20)

// await client.keys(['Delete'])
// await delay(20)
// await client.keys(['Enter'])
// await delay(3000)
// let localFileList2 = await client.elements('.ssh-wrap-show .file-list.local .sftp-item')
// expect(localFileList2.value.length).equal(localFileListBefore.value.length)

// //remote test
// //make a remote folder
// let remoteFileListBefore = await client.elements('.ssh-wrap-show .file-list.remote .sftp-item')
// await client.rightClick('.ssh-wrap-show .virtual-file-remote', 10, 10)
// await delay(200)
// await client.execute(function() {
// document.querySelector('.context-menu .anticon-folder-add').click()
// })
// await delay(200)
// let fname0 = '00000test-electerm-remote' + generate()
// await client.setValue('.ssh-wrap-show .sftp-remote-section .sftp-item input', fname0)
// await client.doubleClick('.ssh-wrap-show .sftp-title-wrap')
// await delay(2500)
// let remoteFileList = await client.elements('.ssh-wrap-show .file-list.remote .sftp-item')
// expect(remoteFileList.value.length).equal(remoteFileListBefore.value.length + 1)

// //enter folder
// await client.execute(function() {
// let event = new MouseEvent('dblclick', {
// 'view': window,
// 'bubbles': true,
// 'cancelable': true
// })
// document.querySelectorAll('.ssh-wrap-show .file-list.remote .sftp-item')[1].dispatchEvent(event)
// })
// await delay(2000)
// let pathCurrentRemote = await client.getAttribute('.ssh-wrap-show .sftp-remote-section .sftp-title input', 'value')
// expect(pathCurrentRemote.includes(fname0)).equal(true)
// let remoteFileList0 = await client.elements('.ssh-wrap-show .file-list.remote .sftp-item')

// expect(remoteFileList0.value.length).equal(1)

// //goto parent
// await client.execute(function() {
// document.querySelector('.ssh-wrap-show .sftp-remote-section .anticon-arrow-up').click()
// })
// await delay(2000)
// let remoteFileList1 = await client.elements('.ssh-wrap-show .file-list.remote .sftp-item')
// expect(remoteFileList1.value.length).equal(remoteFileList.value.length)

// //del folder
// await client.execute(function() {
// document.querySelectorAll('.ssh-wrap-show .file-list.remote .sftp-item .sftp-file-prop')[0].click()
// })
// await delay(20)

// await client.keys(['Delete'])
// await delay(20)
// await client.keys(['Enter'])
// await delay(3000)
// let remoteFileList2 = await client.elements('.ssh-wrap-show .file-list.remote .sftp-item')
// expect(remoteFileList2.value.length).equal(remoteFileListBefore.value.length)

})

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/007.basic.history.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('history', function () {

log('tab it')
await client.execute(function() {
document.querySelectorAll('.ant-modal .ant-tabs-tab')[0].click()
document.querySelectorAll('.ant-modal .ant-tabs-bar .ant-tabs-tab')[0].click()
})

await delay(100)
Expand Down
Loading

0 comments on commit de31752

Please sign in to comment.