Skip to content

Commit

Permalink
Reimplement tests for deletion of collaborators
Browse files Browse the repository at this point in the history
  • Loading branch information
individual-it committed Jul 24, 2019
1 parent fa424bd commit 57bb060
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 74 deletions.
2 changes: 1 addition & 1 deletion apps/files/src/components/Collaborators/Collaborator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<oc-accordion-item :key="collaborator.info.id" class="files-collaborators-collaborator uk-margin-small-bottom">
<template slot="title">
<div class="uk-text-meta uk-flex uk-flex-middle uk-margin-small-bottom"><oc-icon name="repeat" class="uk-margin-small-right" /> {{ collaborator.info.displayname_owner }}</div>
<div class="uk-flex uk-flex-wrap uk-flex-middle">
<div class="files-collaborators-collaborator-information uk-flex uk-flex-wrap uk-flex-middle">
<oc-avatar :src="collaborator.avatar" class="uk-margin-small-right" />
<div class="uk-flex uk-flex-column uk-flex-center">
<div class="oc-text"><span class="files-collaborators-collaborator-name uk-text-bold">{{ collaborator.displayName }}</span><span v-if="collaborator.additionalInfo" class="uk-text-meta"> ({{ collaborator.additionalInfo }})</span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ Feature: Federation Sharing - sharing with users on other cloud storages
And the user accepts the offered remote shares using the webUI
And user "user1" from server "REMOTE" shares "/simple-folder (2)" with user "user2" from server "LOCAL" using the sharing API
And user "user1" re-logs in to "%local_server%" using the webUI
And the user opens the share dialog for folder "simple-folder"
And the user opens the share dialog for folder "simple-folder" using the webUI
And the user sets the sharing permissions of "user2@%local_server% (federated)" for "simple-folder" using the webUI to
| edit | no |
And user "user2" re-logs in to "%local_server%" using the webUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,35 +127,35 @@ Feature: Sharing files and folders with internal groups
When the administrator excludes group "system-group" from receiving shares using the webUI
And the user re-logs in as "user1" using the webUI
And the user browses to the files page
And the user opens the share dialog for folder "simple-folder"
And the user opens the share dialog for folder "simple-folder" using the webUI
And the user types "system-group" in the share-with-field
Then a tooltip with the text "No users or groups found for system-group" should be shown near the share-with-field on the webUI
And the autocomplete list should not be displayed on the webUI

@skip @yetToImplement
@yetToImplement
Scenario: user shares the file/folder with a group and delete the share with user
Given user "user1" has logged in using the webUI
And user "user1" has shared file "lorem.txt" with group "grp1"
When the user opens the share dialog for file "lorem.txt"
Then "grp1" should be listed in the shared with list
When the user deletes share with group "grp1" for the current file
Then "grp1" should not be listed in the shared with list
When the user opens the share dialog for file "lorem.txt" using the webUI
Then group "grp1" should be listed as "Editor" in the collaborators list on the webUI
When the user deletes "grp1" as collaborator for the current file using the webUI
Then group "grp1" should not be listed in the collaborators list on the webUI
# And file "lorem.txt" should not be listed in shared-with-others page on the webUI
And as "user2" file "lorem (2).txt" should not exist

@skip @yetToImplement
@yetToImplement
Scenario: user shares the file/folder with multiple internal users and delete the share with one user user
Given group "grp2" has been created
And user "user3" has been added to group "grp2"
And user "user1" has logged in using the webUI
And user "user1" has shared file "lorem.txt" with group "grp1"
And user "user1" has shared file "lorem.txt" with group "grp2"
When the user opens the share dialog for file "lorem.txt"
Then "grp1" should be listed in the shared with list
And "grp2" should be listed in the shared with list
When the user deletes share with group "grp1" for the current file
Then "grp1" should not be listed in the shared with list
And "grp2" should be listed in the shared with list
When the user opens the share dialog for file "lorem.txt" using the webUI
Then group "grp1" should be listed as "Editor" in the collaborators list on the webUI
And group "grp2" should be listed as "Editor" in the collaborators list on the webUI
When the user deletes "grp1" as collaborator for the current file using the webUI
Then group "grp1" should not be listed in the collaborators list on the webUI
And group "grp2" should be listed as "Editor" in the collaborators list on the webUI
# And file "lorem.txt" should be listed in shared-with-others page on the webUI
And as "user2" file "lorem (2).txt" should not exist
But as "user3" file "lorem (2).txt" should exist
Original file line number Diff line number Diff line change
Expand Up @@ -234,32 +234,32 @@ Feature: Sharing files and folders with internal users
And the share-with field should not be visible in the details panel
And user "user1" should not be able to share file "testimage (2).jpg" with user "User Three" using the sharing API

@skip @yetToImplement
@yetToImplement
Scenario: user shares the file/folder with another internal user and delete the share with user
Given user "user1" has logged in using the webUI
And user "user1" has shared file "lorem.txt" with user "user2"
When the user opens the share dialog for file "lorem.txt"
Then "User Two" should be listed in the shared with list
When the user opens the share dialog for file "lorem.txt" using the webUI
Then user "User Two" should be listed as "Editor" in the collaborators list on the webUI
And as "user2" file "lorem (2).txt" should exist
When the user deletes share with user "User Two" for the current file
Then "User Two" should not be listed in the shared with list
When the user deletes "User Two" as collaborator for the current file using the webUI
Then user "User Two" should not be listed in the collaborators list on the webUI
# And file "lorem.txt" should not be listed in shared-with-others page on the webUI
And as "user2" file "lorem (2).txt" should not exist

@skip @yetToImplement
@yetToImplement
Scenario: user shares the file/folder with multiple internal users and delete the share with one user user
Given user "user3" has been created with default attributes
And user "user1" has logged in using the webUI
And user "user1" has shared file "lorem.txt" with user "user2"
And user "user1" has shared file "lorem.txt" with user "user3"
When the user opens the share dialog for file "lorem.txt"
Then "User Two" should be listed in the shared with list
And "User Three" should be listed in the shared with list
When the user opens the share dialog for file "lorem.txt" using the webUI
Then user "User Two" should be listed as "Editor" in the collaborators list on the webUI
And user "User Three" should be listed as "Editor" in the collaborators list on the webUI
And as "user2" file "lorem (2).txt" should exist
And as "user3" file "lorem (2).txt" should exist
When the user deletes share with user "User Two" for the current file
Then "User Two" should not be listed in the shared with list
And "User Three" should be listed in the shared with list
When the user deletes "User Two" as collaborator for the current file using the webUI
Then user "User Two" should not be listed in the collaborators list on the webUI
And user "User Three" should be listed as "Editor" in the collaborators list on the webUI
# And file "lorem.txt" should be listed in shared-with-others page on the webUI
And as "user2" file "lorem (2).txt" should not exist
But as "user3" file "lorem (2).txt" should exist
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Feature: Share by public link
Scenario: user shares a public link via email adding few addresses before and then removing some addresses afterwards
Given parameter "shareapi_allow_public_notification" of app "core" has been set to "yes"
And the user has reloaded the current page of the webUI
When the user opens the share dialog for folder "simple-folder"
When the user opens the share dialog for folder "simple-folder" using the webUI
And the user opens the public link share tab
And the user opens the create public link share popup
And the user adds the following email addresses using the webUI:
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/webUIWebdavLocks/locks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Feature: Locks

@skip @yetToImplement
Scenario: clicking other tabs does not change the lock symbol
When the user opens the share dialog for folder "simple-folder"
When the user opens the share dialog for folder "simple-folder" using the webUI
Then folder "simple-folder" should not be marked as locked on the webUI

@skip @yetToImplement
Expand Down
57 changes: 35 additions & 22 deletions tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,30 +118,38 @@ module.exports = {
*/
deleteShareWithUserGroup: function (item) {
const util = require('util')
const deleteSelector = util.format(this.elements.deleteShareButton.selector, item)
const informationSelector = util.format(this.elements.collaboratorInformationByCollaboratorName.selector, item)
const moreInformationSelector = informationSelector + this.elements.collaboratorMoreInformation.selector
const deleteSelector = informationSelector + this.elements.deleteShareButton.selector
return this
.useXpath()
.waitForElementVisible(deleteSelector, () => {
this.api.click(deleteSelector)
})
.waitForElementNotPresent(util.format(this.elements.sharedWithListItem.selector, item))
.waitForElementVisible(moreInformationSelector)
.click(moreInformationSelector)
.waitForElementVisible(deleteSelector)
.waitForAnimationToFinish()
.click(deleteSelector)
.waitForElementNotPresent(informationSelector)
},
/**
*
* @returns {Promise.<string[]>} Array of users/groups in share list
*/
getShareList: function () {
const shareList = []
return this.waitForElementVisible('@sharedWithList')
.api.elements('@sharedWithNames', async result => {
console.log(result)
getCollaboratorsList: async function () {
const promiseList = []
await this.initAjaxCounters()
.waitForElementPresent({ selector: '@collaboratorsInformation', abortOnFailure: false })
.waitForOutstandingAjaxCalls()
.api.elements('css selector', this.elements['collaboratorsInformation'], result => {
result.value.map(item => {
this.api.elementIdText(item['ELEMENT'], text => {
shareList.push(text.value)
promiseList.push(new Promise((resolve, reject) => {
this.api.elementIdText(item['ELEMENT'], text => {
resolve(text.value)
})
})
)
})
})
.then(() => shareList)
return Promise.all(promiseList)
},
/**
*
Expand Down Expand Up @@ -172,21 +180,26 @@ module.exports = {
selector: '//div[@class="sidebar-container"]//div[@class="action"]//button',
locateStrategy: 'xpath'
},
sharedWithList: {
selector: '#files-collaborators-list'
},
sharedWithListItems: {
selector: '.files-collaborators-collaborator'
},
sharedWithListItem: {
selector: '//*[@id="file-share-list"]//*[@class="oc-user"]//div[.="%s"]/../..',
locateStrategy: 'xpath'
},
sharedWithNames: {
selector: '#files-collaborators-list .files-collaborators-collaborator .files-collaborators-collaborator-name'
collaboratorsInformation: {
// addresses users and groups
selector: '.files-collaborators-collaborator .files-collaborators-collaborator-information'
},
collaboratorInformationByCollaboratorName: {
selector: '//*[contains(@class, "files-collaborators-collaborator-name") and .="%s"]/ancestor::li',
locateStrategy: 'xpath'
},
collaboratorMoreInformation: {
// within collaboratorInformationByCollaboratorName
selector: '/a',
locateStrategy: 'xpath'
},
deleteShareButton: {
selector: '//*[@id="file-share-list"]//*[@class="oc-user"]//div[.="%s"]/../..//*[@aria-label="Delete Share"]',
// within collaboratorInformationByCollaboratorName
selector: '//*[@aria-label="Delete Share"]',
locateStrategy: 'xpath'
},
addShareButton: {
Expand Down
93 changes: 70 additions & 23 deletions tests/acceptance/stepDefinitions/sharingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,62 @@ const shareFileFolder = function (elementToShare, sharer, receiver, shareType =
})
}

/**
*
* @param {string} type user|group
* @param {string} name
* @param {string} role
* @returns {Promise}
*/
const assertCollaboratorslistContains = function (type, name, role) {
return client.page.FilesPageElement.sharingDialog().getCollaboratorsList()
.then(shares => {
let expectedString = name + '\n' + role
if (type === 'user') {
expectedString = expectedString + client.page.FilesPageElement.sharingDialog().getUserSharePostfix()
} else if (type === 'group') {
expectedString = expectedString + client.page.FilesPageElement.sharingDialog().getGroupSharePostfix()
} else {
throw new Error('illegal type')
}

if (!shares || !shares.includes(expectedString)) {
assert.fail(
`"${name}" was expected to be in share list but was not present. Found collaborators text:"` + shares + `"`
)
}
})
}

/**
*
* @param {string} type
* @param {string} name
* @returns {Promise}
*/
const assertCollaboratorslistDoesNotContain = function (type, name) {
return client.page.FilesPageElement.sharingDialog().getCollaboratorsList()
.then(shares => {
if (shares) {
var searchregex
if (type === 'user') {
searchregex = new RegExp(name + '\n.*' + client.page.FilesPageElement.sharingDialog().getUserSharePostfix())
} else if (type === 'group') {
searchregex = new RegExp(name + '\n.*' + client.page.FilesPageElement.sharingDialog().getGroupSharePostfix())
} else {
throw new Error('illegal type')
}
shares.map(share => {
assert.strictEqual(
searchregex.test(share),
false,
`"${name}" not expected to be in the share list but is present`
)
})
}
})
}

Given('user {string} has shared file/folder {string} with user {string}', function (sharer, elementToShare, receiver) {
return shareFileFolder(elementToShare, sharer, receiver)
})
Expand Down Expand Up @@ -173,35 +229,26 @@ Then('user {string} should not be listed in the autocomplete list on the webUI',
})
})

When('the user opens the share dialog for file {string}', function (file) {
When('the user opens the share dialog for file {string} using the webUI', function (file) {
return client.page.FilesPageElement.filesList().openSharingDialog(file)
})

When('the user deletes share with user/group {string} for the current file', function (user) {
When('the user deletes {string} as collaborator for the current file/folder using the webUI', function (user) {
return client.page.FilesPageElement.sharingDialog().deleteShareWithUserGroup(user)
})

Then('{string} should be listed in the shared with list', function (user) {
return client.page.FilesPageElement.sharingDialog().getShareList()
.then(shares => {
console.log(shares)
if (!shares || !shares.includes(user)) {
assert.fail(`"${user}" was expected to be in share list but was not present.`)
}
})
Then('user {string} should be listed as {string} in the collaborators list on the webUI', function (user, role) {
return assertCollaboratorslistContains('user', user, role)
})

Then('{string} should not be listed in the shared with list', function (user) {
return client.page.FilesPageElement.sharingDialog().getShareList()
.then(shares => {
if (shares) {
shares.map(shareUser => {
assert.notStrictEqual(
shareUser,
user,
`"${user}" not expected to be in the share list but is present`
)
})
}
})
Then('group {string} should be listed as {string} in the collaborators list on the webUI', function (group, role) {
return assertCollaboratorslistContains('group', group, role)
})

Then('user {string} should not be listed in the collaborators list on the webUI', function (user) {
return assertCollaboratorslistDoesNotContain('user', user)
})

Then('group {string} should not be listed in the collaborators list on the webUI', function (user) {
return assertCollaboratorslistDoesNotContain('group', user)
})

0 comments on commit 57bb060

Please sign in to comment.