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 c2d660459de..5d21f324b98 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 @@ -13,7 +13,11 @@ import test, { expect } from '@playwright/test'; import { TableClass } from '../../support/entity/TableClass'; import { UserClass } from '../../support/user/UserClass'; -import { createNewPage, redirectToHomePage } from '../../utils/common'; +import { + createNewPage, + redirectToHomePage, + toastNotification, +} from '../../utils/common'; import { clickOnLogo } from '../../utils/sidebar'; import { createDescriptionTask, @@ -110,21 +114,13 @@ test.describe('Activity feed', () => { await page.getByText('Accept Suggestion').click(); - await expect(page.getByRole('alert').first()).toHaveText( - /Task resolved successfully/ - ); - - await page.getByLabel('close').first().click(); + await toastNotification(page, /Task resolved successfully/); // Task 1 - Request to update tag to be resolved await page.getByText('Accept Suggestion').click(); - await expect(page.getByRole('alert').first()).toHaveText( - /Task resolved successfully/ - ); - - await page.getByLabel('close').first().click(); + await toastNotification(page, /Task resolved successfully/); const closedTask = await page.getByTestId('closed-task').textContent(); diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Glossary.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Glossary.spec.ts index 28c69f86de4..3adb09e6b53 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Glossary.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Glossary.spec.ts @@ -21,6 +21,7 @@ import { performAdminLogin, performUserLogin, redirectToHomePage, + toastNotification, } from '../../utils/common'; import { approveGlossaryTermTask, @@ -228,12 +229,11 @@ test.describe('Glossary tests', () => { await page.getByTestId('saveAssociatedTag').click(); await patchRequest; - await expect(page.getByRole('alert').first()).toContainText( - "mutually exclusive and can't be assigned together" + await toastNotification( + page, + /mutually exclusive and can't be assigned together/ ); - await page.getByLabel('close').first().click(); - // Add non mutually exclusive tags await page.click( '[data-testid="entity-right-panel"] [data-testid="glossary-container"] [data-testid="add-tag"]' diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/SearchIndexApplication.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/SearchIndexApplication.spec.ts index 2674df20302..d3487f5373b 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/SearchIndexApplication.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/SearchIndexApplication.spec.ts @@ -12,20 +12,16 @@ */ import test, { expect, Page } from '@playwright/test'; import { GlobalSettingOptions } from '../../constant/settings'; -import { getApiContext, redirectToHomePage } from '../../utils/common'; +import { + getApiContext, + redirectToHomePage, + toastNotification, +} from '../../utils/common'; import { settingClick } from '../../utils/sidebar'; // use the admin user to login test.use({ storageState: 'playwright/.auth/admin.json' }); -const verifyApplicationTriggerToastData = async (page: Page) => { - await expect(page.getByRole('alert').first()).toHaveText( - /Application triggered successfully/ - ); - - await page.getByLabel('close').first().click(); -}; - const verifyLastExecutionStatus = async (page: Page) => { const { apiContext } = await getApiContext(page); @@ -100,11 +96,7 @@ test('Search Index Application', async ({ page }) => { await page.click('.ant-modal-body [data-testid="deploy-button"]'); await deployResponse; - await expect(page.getByRole('alert').first()).toHaveText( - /Schedule saved successfully/ - ); - - await page.getByLabel('close').first().click(); + await toastNotification(page, 'Schedule saved successfully'); expect(await page.innerText('[data-testid="schedule-type"]')).toContain( 'None' @@ -124,11 +116,7 @@ test('Search Index Application', async ({ page }) => { await page.click('[data-testid="submit-btn"]'); await responseAfterSubmit; - await expect(page.getByRole('alert').first()).toHaveText( - /Configuration saved successfully/ - ); - - await page.getByLabel('close').first().click(); + await toastNotification(page, 'Configuration saved successfully'); }); await test.step('Uninstall application', async () => { @@ -141,11 +129,7 @@ test('Search Index Application', async ({ page }) => { await page.click('[data-testid="save-button"]'); await deleteRequest; - await expect(page.getByRole('alert').first()).toHaveText( - /Application uninstalled/ - ); - - await page.getByLabel('close').first().click(); + await toastNotification(page, 'Application uninstalled successfully'); const card1 = page.locator( '[data-testid="search-indexing-application-card"]' @@ -179,11 +163,7 @@ test('Search Index Application', async ({ page }) => { await page.click('[data-testid="deploy-button"]'); await installApplicationResponse; - await expect(page.getByRole('alert').first()).toHaveText( - /Application installed successfully/ - ); - - await page.getByLabel('close').first().click(); + await toastNotification(page, 'Application installed successfully'); const card = page.locator( '[data-testid="search-indexing-application-card"]' @@ -207,7 +187,7 @@ test('Search Index Application', async ({ page }) => { await triggerPipelineResponse; - await verifyApplicationTriggerToastData(page); + await toastNotification(page, 'Application triggered successfully'); await page.reload(); diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/common.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/common.ts index 8836a4f489c..93ff6c97ed7 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/common.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/common.ts @@ -10,7 +10,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Browser, Page, request } from '@playwright/test'; +import { Browser, expect, Page, request } from '@playwright/test'; import { randomUUID } from 'crypto'; import { AdminClass } from '../support/user/AdminClass'; import { UserClass } from '../support/user/UserClass'; @@ -129,6 +129,15 @@ export const performUserLogin = async (browser, user: UserClass) => { return { page, apiContext, afterAction }; }; +export const toastNotification = async ( + page: Page, + message: string | RegExp +) => { + await expect(page.getByRole('alert').first()).toHaveText(message); + + await page.getByLabel('close').first().click(); +}; + export const clickOutside = async (page: Page) => { await page.locator('body').click({ position: { diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/task.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/task.ts index e1d01b231fc..566bebabf50 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/task.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/task.ts @@ -12,7 +12,7 @@ */ import { expect, Page } from '@playwright/test'; import { isUndefined } from 'lodash'; -import { descriptionBox } from './common'; +import { descriptionBox, toastNotification } from './common'; export type TaskDetails = { term: string; @@ -65,11 +65,7 @@ export const createDescriptionTask = async ( await page.locator(descriptionBox).fill('Updated description'); await page.click('button[type="submit"]'); - await expect(page.getByRole('alert').first()).toHaveText( - /Task created successfully./ - ); - - await page.getByLabel('close').first().click(); + await toastNotification(page, /Task created successfully./); }; export const createTagTask = async ( @@ -133,9 +129,5 @@ export const createTagTask = async ( await page.click('button[type="submit"]'); - await expect(page.getByRole('alert').first()).toHaveText( - /Task created successfully./ - ); - - await page.getByLabel('close').first().click(); + await toastNotification(page, /Task created successfully./); }; diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/user.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/user.ts index a0cd98f71f7..282ee699583 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/user.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/user.ts @@ -13,7 +13,7 @@ import { expect, Page } from '@playwright/test'; import { adjectives, nouns } from '../constant/user'; -import { uuid } from './common'; +import { toastNotification, uuid } from './common'; export const getRandomFirstName = () => { return `${ @@ -143,11 +143,7 @@ export const restoreUserProfilePage = async (page: Page, fqn: string) => { await restoreResponse; - await expect(page.getByRole('alert').first()).toHaveText( - /User restored successfully/ - ); - - await page.getByLabel('close').first().click(); + await toastNotification(page, /User restored successfully/); await nonDeletedUserChecks(page); }; @@ -175,9 +171,5 @@ export const hardDeleteUserProfilePage = async ( await deleteResponse; - await expect(page.getByRole('alert').first()).toHaveText( - /deleted successfully!/ - ); - - await page.getByLabel('close').first().click(); + await toastNotification(page, /deleted successfully!/); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/styles/app.less b/openmetadata-ui/src/main/resources/ui/src/styles/app.less index ef87700ba8d..36bb7a52387 100644 --- a/openmetadata-ui/src/main/resources/ui/src/styles/app.less +++ b/openmetadata-ui/src/main/resources/ui/src/styles/app.less @@ -533,6 +533,7 @@ a[href].link-text-grey, // beta tag for service page .service-beta-tag { sup { + height: auto; padding: 0 4px; margin-left: 2px; font-size: 10px;