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 263a7315688c..4c5b722437a0 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 @@ -33,18 +33,24 @@ import { editDisplayName } from '../../utils/user'; const test = base; -const adminUser = new UserClass(); -const user1 = new UserClass(); -const entity = new TableClass(); -const extraEntity = new TableClass(); -const testPersona = new PersonaClass(); - test.describe('FeedWidget on landing page', () => { + let adminUser: UserClass; + let user1: UserClass; + let entity: TableClass; + let extraEntity: TableClass; + let testPersona: PersonaClass; + test.beforeAll( 'setup: seed entities, users, create persona, and customize widget', async ({ browser }) => { test.slow(true); + adminUser = new UserClass(); + user1 = new UserClass(); + entity = new TableClass(); + extraEntity = new TableClass(); + testPersona = new PersonaClass(); + const { apiContext, afterAction } = await performAdminLogin(browser); try { @@ -369,9 +375,9 @@ test.describe('FeedWidget on landing page', () => { }); test.describe('Mention notifications in Notification Box', () => { - const adminUser = new UserClass(); - const user1 = new UserClass(); - const entity = new TableClass(); + let adminUser: UserClass; + let user1: UserClass; + let entity: TableClass; const test = base.extend<{ adminPage: Page; @@ -392,12 +398,26 @@ test.describe('Mention notifications in Notification Box', () => { }); test.beforeAll('Setup entities and users', async ({ browser }) => { + adminUser = new UserClass(); + user1 = new UserClass(); + entity = new TableClass(); + const { apiContext, afterAction } = await performAdminLogin(browser); await adminUser.create(apiContext); await adminUser.setAdminRole(apiContext); await user1.create(apiContext); await entity.create(apiContext); + + await apiContext.post('/api/v1/feed', { + data: { + from: adminUser.responseData.name, + message: 'Initial conversation thread for mention test', + about: `<#E::table::${entity.entityResponseData.fullyQualifiedName}>`, + type: 'Conversation', + }, + }); + await afterAction(); }); @@ -407,53 +427,6 @@ test.describe('Mention notifications in Notification Box', () => { }) => { test.slow(); - await test.step('Admin user creates a conversation on an entity', async () => { - await entity.visitEntityPage(adminPage); - // Added a safety check on waiting for activity feed count to avoid missing feed - // Poll the activity feed tab count from the page until it's a valid non-negative number - let count = NaN; - const maxRetries = 30; - for (let i = 0; i < maxRetries && (isNaN(count) || count <= 0); i++) { - const countText = await adminPage - .getByRole('tab', { name: 'Activity Feeds & Tasks' }) - .getByTestId('count') - .textContent(); - count = Number(countText ?? '0'); - if (isNaN(count) || count <= 0) { - await adminPage.reload(); - await waitForAllLoadersToDisappear(adminPage); - } - } - - await adminPage.getByTestId('activity_feed').click(); - - await waitForAllLoadersToDisappear(adminPage); - - await adminPage.getByTestId('comments-input-field').click(); - - await adminPage - .locator( - '[data-testid="editor-wrapper"] [contenteditable="true"].ql-editor' - ) - .fill('Initial conversation thread for mention test'); - - await expect( - adminPage.locator('[data-testid="send-button"]') - ).toBeVisible(); - await expect( - adminPage.locator('[data-testid="send-button"]') - ).not.toBeDisabled(); - - const postConversation = adminPage.waitForResponse( - (response) => - response.url().includes('/api/v1/feed') && - response.request().method() === 'POST' && - response.url().includes('/posts') - ); - await adminPage.locator('[data-testid="send-button"]').click(); - await postConversation; - }); - await test.step('User1 mentions admin user in a reply', async () => { await entity.visitEntityPage(user1Page); @@ -461,6 +434,16 @@ test.describe('Mention notifications in Notification Box', () => { await waitForAllLoadersToDisappear(user1Page); + const seededThread = user1Page + .locator('[data-testid="message-container"]') + .filter({ hasText: 'Initial conversation thread for mention test' }) + .first(); + + await expect(seededThread).toBeVisible({ timeout: 30_000 }); + await seededThread.click(); + + await waitForAllLoadersToDisappear(user1Page); + await user1Page.getByTestId('comments-input-field').click(); const editorLocator = user1Page.locator( @@ -616,15 +599,21 @@ test.describe('Mention notifications in Notification Box', () => { }); test.describe('Mentions: Chinese character encoding in activity feed', () => { - const database = new DatabaseClass(); - const endpointName = `测试Endpoint-${uuid()}`; - const apiEndpoint = new ApiEndpointClass(undefined, endpointName); + let adminUser: UserClass; + let database: DatabaseClass; + let apiEndpoint: ApiEndpointClass; let schemaFqn: string; - const userName = `测试-${uuid()}`; + let userName: string; test.beforeAll( 'Create database, schema, and user with Chinese name', async ({ browser }) => { + adminUser = new UserClass(); + database = new DatabaseClass(); + userName = `测试-${uuid()}`; + const endpointName = `测试Endpoint-${uuid()}`; + apiEndpoint = new ApiEndpointClass(undefined, endpointName); + const { apiContext, afterAction } = await performAdminLogin(browser); await database.create(apiContext); @@ -798,15 +787,15 @@ test.describe('Mentions: Chinese character encoding in activity feed', () => { const url = response.url(); return ( url.includes('/api/v1/search/query') && - url.includes(encodeURIComponent(endpointName)) + url.includes(encodeURIComponent(apiEndpoint.entity.name)) ); }); - await editorLocator.pressSequentially(endpointName); + await editorLocator.pressSequentially(apiEndpoint.entity.name); await endpointSuggestionsResponse; await page - .locator(`[data-value="#apiEndpoint/${endpointName}"]`) + .locator(`[data-value="#apiEndpoint/${apiEndpoint.entity.name}"]`) .first() .click(); @@ -852,7 +841,7 @@ test.describe('Mentions: Chinese character encoding in activity feed', () => { await waitForAllLoadersToDisappear(newPage); await expect(newPage.getByTestId('entity-header-display-name')).toHaveText( - endpointName + apiEndpoint.entity.name ); }); });