Fix : Failing activity feed test (#21814)

* fix failing activity feed flaky test

* fix flaky emoji test

* fix flaky test

---------

Co-authored-by: Shailesh Parmar <shailesh.parmar.webdev@gmail.com>
This commit is contained in:
Shrushti Polekar 2025-06-20 20:45:36 +05:30 committed by GitHub
parent f696227ead
commit 3694bf48ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 26 deletions

View File

@ -38,7 +38,6 @@ import {
visitOwnProfilePage, visitOwnProfilePage,
} from '../../utils/common'; } from '../../utils/common';
import { addOwner, updateDescription } from '../../utils/entity'; import { addOwner, updateDescription } from '../../utils/entity';
import { clickOnLogo } from '../../utils/sidebar';
import { import {
checkTaskCountInActivityFeed, checkTaskCountInActivityFeed,
createDescriptionTask, createDescriptionTask,
@ -121,32 +120,34 @@ test.describe('Activity feed', () => {
test('Emoji reaction on feed should be working fine', async ({ page }) => { test('Emoji reaction on feed should be working fine', async ({ page }) => {
await removeLandingBanner(page); await removeLandingBanner(page);
await test.step('Add Emoji reaction', async () => { // Assign reaction for latest feed
// Assign reaction for latest feed await reactOnFeed(page, 1);
await reactOnFeed(page);
// Verify if reaction is working or not // Verify if reaction is working or not
for (const emoji of REACTION_EMOJIS) { for (const emoji of REACTION_EMOJIS) {
await expect( await expect(
page.locator( page.locator(
'[data-testid="activity-feed-widget"] [data-testid="message-container"]:first-child [data-testid="feed-reaction-container"]' '[data-testid="activity-feed-widget"] [data-testid="message-container"]:first-child [data-testid="feed-reaction-container"]'
) )
).toContainText(emoji); ).toContainText(emoji);
} }
}); });
await test.step('Remove Emoji reaction from feed', async () => { test('Remove Emoji reaction from feed', async ({ page }) => {
// Remove reaction for latest feed await removeLandingBanner(page);
await reactOnFeed(page); // Add reaction for latest feed
await reactOnFeed(page, 2);
// Verify if reaction is removed or not // Remove reaction for 2nd feed
const feedReactionContainer = page await reactOnFeed(page, 2);
.locator('[data-testid="message-container"]')
.nth(1)
.locator('[data-testid="feed-reaction-container"]');
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 }) => { test('Assigned task should appear to task tab', async ({ page }) => {
@ -170,7 +171,7 @@ test.describe('Activity feed', () => {
// create tag task // create tag task
await createTagTask(page, { ...value, tag: 'PII.None' }); await createTagTask(page, { ...value, tag: 'PII.None' });
await clickOnLogo(page); await redirectToHomePage(page);
const taskResponse = page.waitForResponse( const taskResponse = page.waitForResponse(
'/api/v1/feed?type=Task&filterType=OWNER&taskStatus=Open&userId=*' '/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 // create tag task
await createTagTask(page1, value, false); await createTagTask(page1, value, false);
await page1.waitForLoadState('networkidle');
// Should only see the close, add and comment button // Should only see the close, add and comment button
expect( expect(
page1.locator('[data-testid="comments-input-field"]') page1.locator('[data-testid="comments-input-field"]')

View File

@ -85,11 +85,11 @@ export const deleteFeedComments = async (page: Page, feed: Locator) => {
await deleteResponse; await deleteResponse;
}; };
export const reactOnFeed = async (page: Page) => { export const reactOnFeed = async (page: Page, feedNumber: number) => {
for (const reaction of FEED_REACTIONS) { for (const reaction of FEED_REACTIONS) {
await page await page
.locator( .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="feed-reaction-container"]')
.locator('[data-testid="add-reactions"]') .locator('[data-testid="add-reactions"]')