Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only][full-ci] Get collaborator role using either button or span selector #7064

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = {
if (subSelectors === null) {
subSelectors = {
displayName: this.elements.collaboratorInformationSubName,
role: this.elements.collaboratorInformationSubRole,
role: this.elements.collaboratorInformationSubRoleBtn,
additionalInfo: this.elements.collaboratorInformationSubAdditionalInfo,
shareType: this.elements.collaboratorShareType
}
Expand All @@ -142,16 +142,15 @@ module.exports = {
const collaboratorResult = {}
for (const attrName in subSelectors) {
let attrElementId = null
await this.api.elementIdElement(
collaboratorElementId,
'css selector',
subSelectors[attrName],
(result) => {
if (result.status !== -1) {
attrElementId = result.value.ELEMENT
}
}
)

if (attrName === 'role') {
attrElementId = await this.getCollaboratorRoleElemId(collaboratorElementId)
} else {
attrElementId = await this.getElementIdElement(
collaboratorElementId,
subSelectors[attrName]
)
}

if (attrElementId) {
await this.api.elementIdText(attrElementId, (text) => {
Expand All @@ -168,6 +167,38 @@ module.exports = {
results = await Promise.all(results)
return results
},
getCollaboratorRoleElemId: async function (parentElemId) {
let elementId = null

elementId = await this.getElementIdElement(
parentElemId,
this.elements.collaboratorInformationSubRoleBtn
)

if (!elementId) {
elementId = await this.getElementIdElement(
parentElemId,
this.elements.collaboratorInformationSubRole
)
}
return elementId
},
/**
*
* @param {string} parentElemId Web Element ID
* @param {string} selector valid css selector
*
* @returns {Promise.<string>} Web Element ID
*/
getElementIdElement: async function (parentElemId, selector) {
let elementId = null
await this.api.elementIdElement(parentElemId, 'css selector', selector, (result) => {
if (result.status !== -1) {
elementId = result.value.ELEMENT
}
})
return elementId
},
/**
*
* @returns {Promise.<string[]>} Array of user/group display names in share list
Expand Down Expand Up @@ -254,10 +285,14 @@ module.exports = {
// within collaboratorsListItem
selector: '.files-collaborators-collaborator-name'
},
collaboratorInformationSubRole: {
collaboratorInformationSubRoleBtn: {
// within collaboratorsListItem
selector: '.files-recipient-role-select-btn:first-child'
},
collaboratorInformationSubRole: {
// within collaboratorsListItem
selector: '.files-collaborators-collaborator-role'
},
collaboratorInformationSubAdditionalInfo: {
// within collaboratorsListItem
selector: '.files-collaborators-collaborator-additional-info'
Expand Down
23 changes: 14 additions & 9 deletions tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,20 @@ module.exports = {
* @param {string} collaborator
*/
getDisplayedPermission: async function (collaborator) {
await collaboratorDialog.expandShareRoleDropdown(collaborator)
await this.selectRole('Custom permissions')
// read the permissions from the checkboxes
const currentSharePermissions = await this.getSharePermissions()

// Hide role select dropdown
this.moveToElement('@customPermissionsDrop', -9, 0)
this.api.mouseButtonClick()
this.waitForElementNotPresent('@customPermissionsDrop', 1000)
let currentSharePermissions = {}
try {
await collaboratorDialog.expandShareRoleDropdown(collaborator)
await this.selectRole('Custom permissions')
// read the permissions from the checkboxes
currentSharePermissions = await this.getSharePermissions()

// Hide role select dropdown
await this.moveToElement('@customPermissionsDrop', -9, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get away without that position arguments? I know that has been there before (and even adjusted in between from -7 to -9).
We should get rid of it because

  1. it will always give us problems in the case of a slight change
  2. magic numbers are bad in the first place
    but it could be done in a separate PR

await this.api.mouseButtonClick()
await this.waitForElementNotPresent('@customPermissionsDrop', 1000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to get rid of the fix timeout, this is a main thing why tests are becoming flacky AND slow. We might waste time here or maybe tomorrow 1000 will not be enough.
I know this was there before, so the refactoring could happen in an other PR

} catch (e) {
console.info('Collaborator Role is not editable!')
}
Comment on lines +327 to +340
Copy link
Member Author

@saw-jan saw-jan May 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is this #7063 issue on the web, I am less confident about this change.

And we don't have a test to check that after resharing with read-only permission, the collaborator role is listed as plain text. Tests won't catch the bug (#7063) in the future if this gets implemented.

Also, I am not sure whether the role should be listed as plain text or a drop-down after resharing with read-only permission.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we can work out why this different behavior happens!

@saw-jan do you see the problem manually? (Is it possible to observe both behaviors when slowly using the web UI manually?) (I want to rule out the chance that there is some transient display of UI elements which the automated test sometimes "sees" but for real users maybe the correct UI elements end up being displayed after a "flicker" of the incorrect UI elements)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the issue can be reproduced manually. Steps to reproduce are listed here #7063

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't like to have this kind of workarounds in the test.
We had a similar discussion for the e2e tests in https://confluence.owncloud.com/pages/viewpage.action?pageId=28807613

what to do with bugs discovered by e2e tests?

  • create an issue
  • if possible run the journey without the step that fails
  • if not then don't merge the test-PR that demonstrate the bug till the bug is fixed

We might want to make an exception here, because its not a failing test but a flaky one, but then we have to make super-sure that the workaround will be taken out when the bug is fixed

@kulmann what do you think?

return currentSharePermissions
},
/**
Expand Down