Skip to content

Commit

Permalink
Add acceptance test for creating new file
Browse files Browse the repository at this point in the history
  • Loading branch information
jasson99 committed Oct 14, 2019
1 parent 33cb0c0 commit a98ccb7
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/acceptance/features/webUIFiles/hiddenFile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ Feature: Hide file/folders
Then folder ".xyz" should not be listed on the webUI
When the user enables the setting to view hidden folders on the webUI
Then folder ".xyz" should be listed on the webUI

Scenario: create a hidden file
When the user creates a file with the name ".hiddenFile.txt" using the webUI
Then file ".hiddenFile.txt" should not be listed on the webUI
When the user enables the setting to view hidden files on the webUI
Then file ".hiddenFile.txt" should be listed on the webUI
44 changes: 44 additions & 0 deletions tests/acceptance/pageObjects/filesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,32 @@ module.exports = {
}
return this
},
/**
* Create a file with the given name
*
* @param {string} name to set or null to use default value from dialog
* @param {boolean} expectToSucceed
*/
createFile: function (name, expectToSucceed = true) {
this
.waitForElementVisible('@newFileMenuButton')
.click('@newFileMenuButton')
.waitForElementVisible('@newFileButton')
.click('@newFileButton')
.waitForElementVisible('@newFileInput')
if (name !== null) {
this.clearValueWithEvent('@newFileInput')
this.setValue('@newFileInput', name)
}
this
.click('@newFileOkButton')
.waitForElementNotPresent('@createFileLoadingIndicator')
if (expectToSucceed) {
this.waitForElementNotVisible('@newFileDialog')
.waitForAnimationToFinish()
}
return this
},
/**
*
* @param {string} localFileName
Expand Down Expand Up @@ -175,15 +201,29 @@ module.exports = {
newFolderButton: {
selector: '#new-folder-btn'
},
newFileButton: {
selector: '#new-file-btn'
},
newFolderDialog: {
selector: '#new-folder-dialog'
},
newFileDialog: {
selector: '#new-file-dialog'
},
newFolderInput: {
selector: '#new-folder-input'
},
newFileInput: {
selector: "//input[@placeholder='Create new file…']",
locateStrategy: 'xpath'
},
newFolderOkButton: {
selector: '#new-folder-ok'
},
newFileOkButton: {
selector: "//div[@id='new-file-dialog']//span[contains(text(),'Ok')]",
locateStrategy: 'xpath'
},
permalinkCopyButton: {
selector: '#files-permalink-copy'
},
Expand Down Expand Up @@ -215,6 +255,10 @@ module.exports = {
selector: '//div[@id="new-folder-dialog"]//div[@class="oc-loader"]',
locateStrategy: 'xpath'
},
createFileLoadingIndicator: {
selector: '//div[@id="new-file-dialog"]//div[@class="oc-loader"]',
locateStrategy: 'xpath'
},
fileUploadButton: {
selector: '#files-file-upload-button'
},
Expand Down
6 changes: 5 additions & 1 deletion tests/acceptance/stepDefinitions/filesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ When('the user creates a folder with the name {string} using the webUI', functio
return client.page.filesPage().createFolder(folderName)
})

When('the user creates a file with the name {string} using the webUI', function (fileName) {
return client.page.filesPage().createFile(fileName)
})

When('the user creates a folder with default name using the webUI', function () {
return client.page.filesPage().createFolder(null, false)
})
Expand All @@ -117,7 +121,7 @@ Given('the user has opened the share dialog for folder {string}', function (file
return client.page.FilesPageElement.filesList().openSharingDialog(fileName)
})

When('the user enables the setting to view hidden folders on the webUI', function () {
When('the user enables the setting to view hidden files/folders on the webUI', function () {
return client.page.filesPage().showHiddenFiles()
})

Expand Down

0 comments on commit a98ccb7

Please sign in to comment.