From 1c601af929da060b5339d9df9b5852e23a907a67 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Wed, 19 Jun 2024 14:57:47 +0545 Subject: [PATCH] test(e2e): wait for transition to end before action --- .../objects/app-files/share/actions.ts | 7 ++++- .../objects/app-files/share/collaborator.ts | 29 ++++++++++++------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/tests/e2e/support/objects/app-files/share/actions.ts b/tests/e2e/support/objects/app-files/share/actions.ts index 0337be7a79c..d90aa5a89df 100644 --- a/tests/e2e/support/objects/app-files/share/actions.ts +++ b/tests/e2e/support/objects/app-files/share/actions.ts @@ -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 = @@ -76,7 +78,10 @@ export const createShare = async (args: createShareArgs): Promise => { 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 }) diff --git a/tests/e2e/support/objects/app-files/share/collaborator.ts b/tests/e2e/support/objects/app-files/share/collaborator.ts index 8c44a4089d1..fcafb7b9730 100644 --- a/tests/e2e/support/objects/app-files/share/collaborator.ts +++ b/tests/e2e/support/objects/app-files/share/collaborator.ts @@ -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 @@ -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 = @@ -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) } @@ -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(