Skip to content

Commit

Permalink
test(e2e): wait for transition to end before action (#11066)
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan authored Jun 19, 2024
1 parent 71f04b1 commit 3eefbd8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
7 changes: 6 additions & 1 deletion tests/e2e/support/objects/app-files/share/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { clearCurrentPopup, createLinkArgs } from '../link/actions'
import { config } from '../../../../config.js'
import { createdLinkStore } from '../../../store'
import { User } from '../../../types'
import { locatorUtils } from '../../../utils'

const invitePanel = '//*[@id="oc-files-sharing-sidebar"]'
const quickShareButton =
'//*[@data-test-resource-name="%s"]/ancestor::tr//button[contains(@class, "files-quick-action-show-shares")]'
const noPermissionToShareLabel =
Expand Down Expand Up @@ -76,7 +78,10 @@ export const createShare = async (args: createShareArgs): Promise<void> => {

if (expirationDate) {
await page.locator(showMoreOptionsButton).click()
await page.getByTestId(calendarDatePickerId).click()
await Promise.all([
locatorUtils.waitForEvent(page.locator(invitePanel), 'transitionend'),
page.getByTestId(calendarDatePickerId).click()
])
await Collaborator.setExpirationDate(page, expirationDate)
}
await Collaborator.inviteCollaborators({ page, collaborators: recipients })
Expand Down
29 changes: 18 additions & 11 deletions tests/e2e/support/objects/app-files/share/collaborator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { startCase } from 'lodash'
import util from 'util'
import { Group, User } from '../../../types'
import { getActualExpiryDate } from '../../../utils/datePicker'
import { locatorUtils } from '../../../utils'

export interface ICollaborator {
collaborator: User | Group
Expand Down Expand Up @@ -77,7 +78,7 @@ export default class Collaborator {
private static readonly denyShareCollaboratorButton =
'%s//ul[contains(@class,"collaborator-edit-dropdown-options-list")]//span[contains(@class,"deny-share")]//button[contains(@aria-checked,"%s")]'
private static readonly setExpirationDateCollaboratorButton =
'%s//ul[contains(@class,"collaborator-edit-dropdown-options-list")]//button[contains(@class,"files-collaborators-expiration-button")]'
'%s//ul[contains(@class,"collaborator-edit-dropdown-options-list")]//button[@data-testid="recipient-datepicker-btn"]'
private static readonly removeExpirationDateCollaboratorButton =
'%s//ul[contains(@class,"collaborator-edit-dropdown-options-list")]//button[contains(@class,"remove-expiration-date")]'
private static readonly showAccessDetailsButton =
Expand Down Expand Up @@ -239,9 +240,14 @@ export default class Collaborator {
await page
.locator(util.format(Collaborator.collaboratorEditDropdownButton, collaboratorRow))
.click()
await page
.locator(util.format(Collaborator.setExpirationDateCollaboratorButton, collaboratorRow))
.click()

const panel = page.locator(Collaborator.invitePanel)
await Promise.all([
locatorUtils.waitForEvent(panel, 'transitionend'),
page
.locator(util.format(Collaborator.setExpirationDateCollaboratorButton, collaboratorRow))
.click()
])

await Collaborator.setExpirationDate(page, expirationDate)
}
Expand All @@ -258,14 +264,15 @@ export default class Collaborator {
{ newExpiryDate }
)

const date = page.locator(
util.format(
Collaborator.expirationDatepickerDaySelect,
newExpiryDate.toISOString().split('T')[0]
await page
.locator(
util.format(
Collaborator.expirationDatepickerDaySelect,
newExpiryDate.toISOString().split('T')[0]
)
)
)
await page.waitForTimeout(500)
await date.first().click()
.first()
.click()
}

static async removeExpirationDateFromCollaborator(
Expand Down

0 comments on commit 3eefbd8

Please sign in to comment.