From 3694bf48ca07610d79df02debb7af3bc0d8f44c5 Mon Sep 17 00:00:00 2001 From: Shrushti Polekar Date: Fri, 20 Jun 2025 20:45:36 +0530 Subject: [PATCH] Fix : Failing activity feed test (#21814) * fix failing activity feed flaky test * fix flaky emoji test * fix flaky test --------- Co-authored-by: Shailesh Parmar --- .../e2e/Features/ActivityFeed.spec.ts | 51 ++++++++++--------- .../ui/playwright/utils/activityFeed.ts | 4 +- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ActivityFeed.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ActivityFeed.spec.ts index 62b284c533a..ff597c13a31 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ActivityFeed.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ActivityFeed.spec.ts @@ -38,7 +38,6 @@ import { visitOwnProfilePage, } from '../../utils/common'; import { addOwner, updateDescription } from '../../utils/entity'; -import { clickOnLogo } from '../../utils/sidebar'; import { checkTaskCountInActivityFeed, createDescriptionTask, @@ -121,32 +120,34 @@ test.describe('Activity feed', () => { test('Emoji reaction on feed should be working fine', async ({ page }) => { await removeLandingBanner(page); - await test.step('Add Emoji reaction', async () => { - // Assign reaction for latest feed - await reactOnFeed(page); + // Assign reaction for latest feed + await reactOnFeed(page, 1); - // Verify if reaction is working or not - for (const emoji of REACTION_EMOJIS) { - await expect( - page.locator( - '[data-testid="activity-feed-widget"] [data-testid="message-container"]:first-child [data-testid="feed-reaction-container"]' - ) - ).toContainText(emoji); - } - }); + // Verify if reaction is working or not + for (const emoji of REACTION_EMOJIS) { + await expect( + page.locator( + '[data-testid="activity-feed-widget"] [data-testid="message-container"]:first-child [data-testid="feed-reaction-container"]' + ) + ).toContainText(emoji); + } + }); - await test.step('Remove Emoji reaction from feed', async () => { - // Remove reaction for latest feed - await reactOnFeed(page); + test('Remove Emoji reaction from feed', async ({ page }) => { + await removeLandingBanner(page); + // Add reaction for latest feed + await reactOnFeed(page, 2); - // Verify if reaction is removed or not - const feedReactionContainer = page - .locator('[data-testid="message-container"]') - .nth(1) - .locator('[data-testid="feed-reaction-container"]'); + // Remove reaction for 2nd feed + await reactOnFeed(page, 2); - await expect(feedReactionContainer).toHaveCount(1); - }); + // Verify if reaction is removed or not + const feedReactionContainers = page + .locator('[data-testid="message-container"]') + .nth(2) + .locator('[data-testid="feed-reaction-container"]'); + + await expect(feedReactionContainers).toHaveCount(1); }); test('Assigned task should appear to task tab', async ({ page }) => { @@ -170,7 +171,7 @@ test.describe('Activity feed', () => { // create tag task await createTagTask(page, { ...value, tag: 'PII.None' }); - await clickOnLogo(page); + await redirectToHomePage(page); const taskResponse = page.waitForResponse( '/api/v1/feed?type=Task&filterType=OWNER&taskStatus=Open&userId=*' @@ -855,6 +856,8 @@ base.describe('Activity feed with Data Consumer User', () => { // create tag task await createTagTask(page1, value, false); + await page1.waitForLoadState('networkidle'); + // Should only see the close, add and comment button expect( page1.locator('[data-testid="comments-input-field"]') diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/activityFeed.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/activityFeed.ts index 30c5f2b40e5..d78885b7107 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/activityFeed.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/activityFeed.ts @@ -85,11 +85,11 @@ export const deleteFeedComments = async (page: Page, feed: Locator) => { await deleteResponse; }; -export const reactOnFeed = async (page: Page) => { +export const reactOnFeed = async (page: Page, feedNumber: number) => { for (const reaction of FEED_REACTIONS) { await page .locator( - '[data-testid="activity-feed-widget"] [data-testid="message-container"]:first-child' + `[data-testid="activity-feed-widget"] [data-testid="message-container"]:nth-child(${feedNumber})` ) .locator('[data-testid="feed-reaction-container"]') .locator('[data-testid="add-reactions"]')