diff --git a/.github/playwright/impact-map.json b/.github/playwright/impact-map.json index e3c21da64d08..8aad38f536b2 100644 --- a/.github/playwright/impact-map.json +++ b/.github/playwright/impact-map.json @@ -7,11 +7,15 @@ "playwright/e2e/Features/KnowledgeGraph.spec.ts", "playwright/e2e/Features/OntologyExplorerRdf.spec.ts", "playwright/e2e/Features/OntologyImportRdf.spec.ts", - "playwright/e2e/VisualRegression/**" + "playwright/e2e/VisualRegression/**", + "playwright/e2e/Features/EntityExportJobsTray.spec.ts", + "playwright/e2e/Features/CsvJobsTray.spec.ts" ], "smoke": [ { - "projects": ["Basic"], + "projects": [ + "Basic" + ], "specs": [ "playwright/e2e/Pages/Login.spec.ts", "playwright/e2e/Flow/Navbar.spec.ts", @@ -24,48 +28,92 @@ ], "canary": [ { - "projects": ["chromium"], - "specs": ["playwright/e2e/Pages/Entity.spec.ts"] + "projects": [ + "chromium" + ], + "specs": [ + "playwright/e2e/Pages/Entity.spec.ts" + ] }, { - "projects": ["Ingestion"], - "specs": ["playwright/e2e/Pages/HealthCheck.spec.ts"] + "projects": [ + "Ingestion" + ], + "specs": [ + "playwright/e2e/Pages/HealthCheck.spec.ts" + ] }, { - "projects": ["DataAssetRulesEnabled"], - "specs": ["playwright/e2e/Features/DataAssetRulesEnabled.spec.ts"] + "projects": [ + "DataAssetRulesEnabled" + ], + "specs": [ + "playwright/e2e/Features/DataAssetRulesEnabled.spec.ts" + ] }, { - "projects": ["DataAssetRulesDisabled"], - "specs": ["playwright/e2e/Features/DataAssetRulesDisabled.spec.ts"] + "projects": [ + "DataAssetRulesDisabled" + ], + "specs": [ + "playwright/e2e/Features/DataAssetRulesDisabled.spec.ts" + ] }, { - "projects": ["SearchRBAC"], - "specs": ["playwright/e2e/Flow/SearchRBAC.spec.ts"] + "projects": [ + "SearchRBAC" + ], + "specs": [ + "playwright/e2e/Flow/SearchRBAC.spec.ts" + ] }, { - "projects": ["DomainIsolation"], - "specs": ["playwright/e2e/Features/DomainIsolation/**/*.spec.ts"] + "projects": [ + "DomainIsolation" + ], + "specs": [ + "playwright/e2e/Features/DomainIsolation/**/*.spec.ts" + ] }, { - "projects": ["search-nightly"], - "specs": ["playwright/e2e/Search/SearchRelevance.spec.ts"] + "projects": [ + "search-nightly" + ], + "specs": [ + "playwright/e2e/Search/SearchRelevance.spec.ts" + ] }, { - "projects": ["Reindex"], - "specs": ["playwright/e2e/Features/SearchSeparation/ExploreFilterSeparation.spec.ts"] + "projects": [ + "Reindex" + ], + "specs": [ + "playwright/e2e/Features/SearchSeparation/ExploreFilterSeparation.spec.ts" + ] }, { - "projects": ["GlobalSettings"], - "specs": ["playwright/e2e/Pages/SearchSettings.spec.ts"] + "projects": [ + "GlobalSettings" + ], + "specs": [ + "playwright/e2e/Pages/SearchSettings.spec.ts" + ] }, { - "projects": ["SystemCertificationTags"], - "specs": ["playwright/e2e/Features/SystemCertificationTags.spec.ts"] + "projects": [ + "SystemCertificationTags" + ], + "specs": [ + "playwright/e2e/Features/SystemCertificationTags.spec.ts" + ] }, { - "projects": ["IntakeForm"], - "specs": ["playwright/e2e/Pages/IntakeForm.spec.ts"] + "projects": [ + "IntakeForm" + ], + "specs": [ + "playwright/e2e/Pages/IntakeForm.spec.ts" + ] } ], "sharedInfrastructure": [ @@ -92,15 +140,22 @@ "openmetadata-ui/src/main/resources/ui/playwright/e2e/search-rbac.setup.ts", "openmetadata-ui/src/main/resources/ui/playwright/e2e/search-rbac.teardown.ts" ], - "projects": ["SearchRBAC"], - "specs": ["playwright/e2e/Flow/SearchRBAC.spec.ts"] + "projects": [ + "SearchRBAC" + ], + "specs": [ + "playwright/e2e/Flow/SearchRBAC.spec.ts" + ] }, { "sources": [ "openmetadata-ui/src/main/resources/ui/src/components/Lineage/**", "openmetadata-ui/src/main/resources/ui/src/pages/Lineage/**" ], - "projects": ["chromium", "Basic"], + "projects": [ + "chromium", + "Basic" + ], "specs": [ "playwright/e2e/Pages/Lineage/**/*.spec.ts", "playwright/e2e/Flow/*Lineage*.spec.ts" @@ -163,7 +218,13 @@ "openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestDefinitionRepository.java", "openmetadata-spec/src/main/resources/json/schema/tests/**" ], - "projects": ["chromium", "Basic", "Ingestion", "Reindex", "ImportExport"], + "projects": [ + "chromium", + "Basic", + "Ingestion", + "Reindex", + "ImportExport" + ], "specs": [ "playwright/e2e/Features/DataQuality/**/*.spec.ts", "playwright/e2e/Features/IncidentManager.spec.ts", @@ -186,7 +247,9 @@ "openmetadata-ui/src/main/resources/ui/src/pages/ServiceDetailsPage/**", "openmetadata-ui/src/main/resources/ui/src/pages/TestSuiteIngestionPage/**" ], - "projects": ["Ingestion"], + "projects": [ + "Ingestion" + ], "specs": [ "playwright/e2e/Features/AutoPilot.spec.ts", "playwright/e2e/Features/DataQuality/AddTestCaseNewFlow.spec.ts", @@ -210,7 +273,11 @@ "openmetadata-ui/src/main/resources/ui/src/pages/Glossary/**", "openmetadata-service/src/main/java/org/openmetadata/service/resources/glossary/**" ], - "projects": ["chromium", "Basic", "ImportExport"], + "projects": [ + "chromium", + "Basic", + "ImportExport" + ], "specs": [ "playwright/e2e/Features/Glossary/**/*.spec.ts", "playwright/e2e/Pages/*Glossary*.spec.ts", @@ -224,7 +291,12 @@ "openmetadata-ui/src/main/resources/ui/src/pages/Domain/**", "openmetadata-ui/src/main/resources/ui/src/pages/DataProduct/**" ], - "projects": ["chromium", "Basic", "DomainIsolation", "Reindex"], + "projects": [ + "chromium", + "Basic", + "DomainIsolation", + "Reindex" + ], "specs": [ "playwright/e2e/**/*Domain*.spec.ts", "playwright/e2e/**/*DataProduct*.spec.ts", @@ -236,7 +308,11 @@ "openmetadata-ui/src/main/resources/ui/src/components/Settings/**", "openmetadata-ui/src/main/resources/ui/src/pages/Settings/**" ], - "projects": ["chromium", "Basic", "GlobalSettings"], + "projects": [ + "chromium", + "Basic", + "GlobalSettings" + ], "specs": [ "playwright/e2e/Features/SettingsNavigationPage.spec.ts", "playwright/e2e/Flow/LineageSettings.spec.ts", @@ -256,7 +332,12 @@ "openmetadata-ui/src/main/resources/ui/src/components/Auth/**", "openmetadata-ui/src/main/resources/ui/src/pages/Login/**" ], - "projects": ["chromium", "Basic", "SearchRBAC", "ImportExport"], + "projects": [ + "chromium", + "Basic", + "SearchRBAC", + "ImportExport" + ], "specs": [ "playwright/e2e/**/*Permission*.spec.ts", "playwright/e2e/Pages/Login*.spec.ts", @@ -268,7 +349,10 @@ "openmetadata-service/src/main/java/org/openmetadata/service/TypeRegistry.java", "openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TypeRepository.java" ], - "projects": ["chromium", "Basic"], + "projects": [ + "chromium", + "Basic" + ], "specs": [ "playwright/e2e/Pages/CustomPropertiesApiContract.spec.ts", "playwright/e2e/Pages/CustomProperties.spec.ts" @@ -280,7 +364,10 @@ "openmetadata-ui/src/main/resources/ui/src/generated/**", "openmetadata-service/src/main/java/org/openmetadata/service/resources/**" ], - "projects": ["chromium", "Basic"], + "projects": [ + "chromium", + "Basic" + ], "specs": [ "playwright/e2e/Pages/Entity.spec.ts", "playwright/e2e/Pages/CustomPropertiesApiContract.spec.ts", @@ -290,8 +377,13 @@ ] }, { - "sources": ["openmetadata-ui-core-components/**"], - "projects": ["chromium", "Basic"], + "sources": [ + "openmetadata-ui-core-components/**" + ], + "projects": [ + "chromium", + "Basic" + ], "specs": [ "playwright/e2e/Flow/Navbar.spec.ts", "playwright/e2e/Pages/EntityHeaderBreadcrumb.spec.ts", @@ -326,7 +418,9 @@ "openmetadata-spec/src/main/resources/json/schema/api/data/createContextFile.json", "openmetadata-spec/src/main/resources/json/schema/api/data/moveContextFileRequest.json" ], - "projects": ["chromium"], + "projects": [ + "chromium" + ], "specs": [ "playwright/e2e/Features/ContextCenterArticles.spec.ts", "playwright/e2e/Features/ContextCenterMemories.spec.ts", @@ -354,8 +448,12 @@ "openmetadata-spec/src/main/resources/json/schema/governance/workflows/**", "openmetadata-spec/src/main/resources/json/schema/api/governance/**" ], - "projects": ["chromium"], - "specs": ["playwright/e2e/Features/Workflows/**/*.spec.ts"] + "projects": [ + "chromium" + ], + "specs": [ + "playwright/e2e/Features/Workflows/**/*.spec.ts" + ] }, { "sources": [ @@ -368,8 +466,12 @@ "openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/**", "openmetadata-spec/src/main/resources/json/schema/api/rdf/**" ], - "projects": ["chromium"], - "specs": ["playwright/e2e/Features/OntologyExplorer*.spec.ts"] + "projects": [ + "chromium" + ], + "specs": [ + "playwright/e2e/Features/OntologyExplorer*.spec.ts" + ] }, { "sources": [ @@ -387,7 +489,10 @@ "openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ServicesOverview*.java", "openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ServiceHealthProvider.java" ], - "projects": ["chromium", "Basic"], + "projects": [ + "chromium", + "Basic" + ], "specs": [ "playwright/e2e/Pages/ServiceEntity.spec.ts", "playwright/e2e/Pages/ServiceListing.spec.ts", @@ -414,7 +519,9 @@ "openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ServicesOverview*.java", "openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ServiceHealthProvider.java" ], - "projects": ["Ingestion"], + "projects": [ + "Ingestion" + ], "specs": [ "playwright/e2e/Flow/ServiceForm.spec.ts", "playwright/e2e/Flow/ApiServiceRest.spec.ts" @@ -425,7 +532,10 @@ "openmetadata-ui/src/main/resources/ui/src/components/Tag/**", "openmetadata-ui/src/main/resources/ui/src/utils/InteractiveTargetUtils.ts" ], - "projects": ["chromium", "Basic"], + "projects": [ + "chromium", + "Basic" + ], "specs": [ "playwright/e2e/Pages/Tag.spec.ts", "playwright/e2e/Pages/Tags.spec.ts", @@ -435,6 +545,20 @@ "playwright/e2e/Features/MutuallyExclusiveColumnTags.spec.ts", "playwright/e2e/Features/ColumnBulkOperationsTagsGlossary.spec.ts" ] + }, + { + "sources": [ + "openmetadata-ui/src/main/resources/ui/src/components/common/EntityImport/CsvJobsTray/**", + "openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityExportModalProvider/**", + "openmetadata-ui/src/main/resources/ui/src/rest/csvAPI.ts" + ], + "projects": [ + "chromium" + ], + "specs": [ + "playwright/e2e/Features/CsvJobsTray.spec.ts", + "playwright/e2e/Features/EntityExportJobsTray.spec.ts" + ] } ] } diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/CsvJobsTray.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/CsvJobsTray.spec.ts index 4b20832bc7f8..4702461ca931 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/CsvJobsTray.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/CsvJobsTray.spec.ts @@ -11,232 +11,253 @@ * limitations under the License. */ -import { expect, Page, Route } from '@playwright/test'; +import { APIRequestContext, expect, Page } from '@playwright/test'; -import { redirectToHomePage } from '../../utils/common'; +import { performAdminLogin } from '../../utils/admin'; +import { + getExportModalContent, + openExportScopeModal, +} from '../../utils/explore'; import { test } from '../fixtures/pages'; test.use({ storageState: 'playwright/.auth/admin.json' }); -const JOB_ID_EXPORT = 'pw-tray-export-running'; -const JOB_ID_IMPORT = 'pw-tray-import-running'; - -const RUNNING_EXPORT_JOB = { - jobId: JOB_ID_EXPORT, - operation: 'EXPORT', - entityType: 'metric', - createdBy: 'admin', - status: 'RUNNING', - progress: 5, - total: 18, -}; +// ── helpers ────────────────────────────────────────────────────────────────── -const RUNNING_IMPORT_JOB = { - jobId: JOB_ID_IMPORT, - operation: 'IMPORT', - entityType: 'metric', - createdBy: 'admin', - status: 'RUNNING', - progress: 3, - total: 10, -}; +const startAsyncExport = async (page: Page): Promise => { + const asyncResponse = page.waitForResponse( + (res) => + res.url().includes('/api/v1/search/export/async') && res.status() === 202 + ); -const fulfillJobsRoute = (route: Route, jobs: Record[]) => - route.fulfill({ contentType: 'application/json', json: jobs }); + await getExportModalContent(page) + .getByRole('button', { name: 'Export' }) + .click(); -const mockJobsApi = (page: Page, jobs: Record[]) => - page.route('**/api/v1/csvAsyncJobs**', (route) => - fulfillJobsRoute(route, jobs) - ); + const { jobId } = (await (await asyncResponse).json()) as { jobId: string }; -const triggerJobsRefresh = async (page: Page) => { - await page.evaluate(() => - window.dispatchEvent(new Event('csv-jobs-refresh')) - ); + await expect(page.getByText('Export started')).toBeVisible(); + await expect(getExportModalContent(page)).not.toBeVisible(); + + return jobId; }; -const activateJobsTray = async (page: Page) => { +const waitForJobCompleted = async ( + apiContext: APIRequestContext, + jobId: string +): Promise => { await expect .poll( async () => { - await triggerJobsRefresh(page); - - return page.locator('.csv-jobs-tray').count(); + const res = await apiContext.get('/api/v1/csvAsyncJobs?limit=50'); + const jobs = (await res.json()) as Array<{ + jobId: string; + status: string; + }>; + + if (!Array.isArray(jobs)) { + throw new Error( + `Unexpected response ${res.status()}: ${JSON.stringify(jobs).slice( + 0, + 200 + )}` + ); + } + + return jobs.find((j) => j.jobId === jobId)?.status; }, - { timeout: 10_000 } + { timeout: 90_000 } ) - .toBeGreaterThan(0); + .toBe('COMPLETED'); }; -const openTray = async (page: Page) => { - await page.locator('.csv-jobs-tray-launcher').click(); - await expect(page.locator('.csv-jobs-tray-popover')).toBeVisible(); -}; +const triggerJobsRefresh = (page: Page) => + page.evaluate(() => window.dispatchEvent(new Event('csv-jobs-refresh'))); -test.describe('CsvJobsTray', () => { - test.beforeEach(async ({ page }) => { - await redirectToHomePage(page); - await page.goto('/metrics'); - await page.waitForURL(/\/metrics/); - }); +// Scope all assertions to the tray item that belongs to the specific job +// created by this test — other jobs from parallel workers are ignored. +const jobItem = (page: Page, jobId: string) => + page.locator(`[data-testid="csv-jobs-tray-item-${jobId}"]`); - test('shows a running export job and its progress text', async ({ page }) => { - await mockJobsApi(page, [RUNNING_EXPORT_JOB]); - await activateJobsTray(page); +// ── suite ───────────────────────────────────────────────────────────────────── - await expect(page.locator('.csv-jobs-tray-launcher')).toBeVisible(); - await openTray(page); - - await expect(page.locator('.csv-jobs-tray-item-running')).toHaveCount(1); - await expect(page.getByText(/Exporting Metrics/i)).toBeVisible(); +// Serial mode prevents the shared admin user's job list from being polluted by +// jobs that the previous test left in RUNNING state (clear-completed only +// dismisses terminal jobs). Cross-file parallel workers are less of a concern +// because assertions are scoped to the specific jobId created by each test. +test.describe.serial('CsvJobsTray', () => { + test.beforeEach(async ({ page }) => { + const searchResponse = page.waitForResponse( + (res) => + res.url().includes('/api/v1/search/query') && res.status() === 200 + ); + await page.goto('/explore/tables?search=sample_data'); + await expect(page.getByTestId('explore-page')).toBeVisible(); + await searchResponse; }); - test('shows an import job in the tray', async ({ page }) => { - await mockJobsApi(page, [RUNNING_IMPORT_JOB]); - await activateJobsTray(page); + test.afterEach(async ({ page }) => { + // Best-effort: dismiss terminal jobs so they don't accumulate across tests. + try { + const clearButton = page.locator('.csv-jobs-tray-clear'); + if (await clearButton.isVisible({ timeout: 2_000 })) { + await clearButton.click(); - await expect(page.locator('.csv-jobs-tray-launcher')).toBeVisible(); - await openTray(page); + return; + } + for (const btn of await page.locator('.csv-jobs-tray-dismiss').all()) { + if (await btn.isVisible()) { + await btn.click(); + } + } + } catch { + // tray may already be hidden — ignore + } + }); - await expect(page.getByText(/Importing Metrics/i)).toBeVisible(); + test('tray surfaces an export job after export starts', async ({ + page, + browser, + }) => { + test.slow(); + + await openExportScopeModal(page); + const jobId = await startAsyncExport(page); + + // The export modal fires csv-jobs-refresh internally; the tray renders once + // the component picks up the new job from the first poll. + await expect(page.locator('.csv-jobs-tray')).toBeVisible({ + timeout: 30_000, + }); + await expect(jobItem(page, jobId)).toBeVisible({ timeout: 30_000 }); + + // Wait for completion so afterEach can clear the item via clear-completed. + const { apiContext, afterAction } = await performAdminLogin(browser); + await waitForJobCompleted(apiContext, jobId); + await afterAction(); }); - test('can cancel a running job from the tray', async ({ page }) => { - await mockJobsApi(page, [RUNNING_EXPORT_JOB]); - await activateJobsTray(page); - - let cancelCalled = false; - await page.route( - `**/api/v1/csvAsyncJobs/${JOB_ID_EXPORT}/cancel`, - async (route) => { - cancelCalled = true; - await route.fulfill({ - contentType: 'application/json', - json: { ...RUNNING_EXPORT_JOB, status: 'CANCELLING' }, - }); - } - ); + test('auto-opens the tray when an export job completes', async ({ + page, + browser, + }) => { + test.slow(); - await expect(page.locator('.csv-jobs-tray-launcher')).toBeVisible(); - await openTray(page); + await openExportScopeModal(page); + const jobId = await startAsyncExport(page); - await page - .locator('.csv-jobs-tray-action') - .filter({ hasText: 'Cancel' }) - .click(); + // Tray auto-opens once the component polls and sees the RUNNING→COMPLETED + // transition for a job that was not already terminal on initial load. + await expect(page.locator('.csv-jobs-tray-popover')).toBeVisible({ + timeout: 90_000, + }); + await expect(jobItem(page, jobId)).toBeVisible({ timeout: 30_000 }); - await expect.poll(() => cancelCalled, { timeout: 10_000 }).toBe(true); + const { apiContext, afterAction } = await performAdminLogin(browser); + await waitForJobCompleted(apiContext, jobId); + await afterAction(); }); - test('shows Download button for a completed export job', async ({ page }) => { - await mockJobsApi(page, [RUNNING_EXPORT_JOB]); - await activateJobsTray(page); + test('shows Download button for a completed job and triggers file download', async ({ + page, + browser, + }) => { + test.slow(); - await expect(page.locator('.csv-jobs-tray-launcher')).toBeVisible(); - await openTray(page); + await openExportScopeModal(page); + const jobId = await startAsyncExport(page); - await mockJobsApi(page, [ - { ...RUNNING_EXPORT_JOB, status: 'COMPLETED', progress: 18 }, - ]); - await triggerJobsRefresh(page); + // Poll the backend until done before asserting the Download button so that a + // slow job doesn't exhaust the assertion timeout. + const { apiContext, afterAction } = await performAdminLogin(browser); + await waitForJobCompleted(apiContext, jobId); + await afterAction(); - await expect(page.locator('.csv-jobs-tray-item-success')).toHaveCount(1); - - let downloadCalled = false; - await page.route( - `**/api/v1/csvAsyncJobs/${JOB_ID_EXPORT}/result`, - async (route) => { - downloadCalled = true; - await route.fulfill({ - contentType: 'text/csv', - body: 'name,displayName\ntest_metric,Test Metric', - }); - } - ); + await triggerJobsRefresh(page); - await page - .locator('.csv-jobs-tray-action') - .filter({ hasText: 'Download' }) - .click(); + await expect(page.locator('.csv-jobs-tray-popover')).toBeVisible({ + timeout: 30_000, + }); - await expect.poll(() => downloadCalled, { timeout: 10_000 }).toBe(true); - }); + const downloadButton = jobItem(page, jobId).getByRole('button', { + name: 'Download', + }); + await expect(downloadButton).toBeVisible({ timeout: 30_000 }); - test('FAILED import job shows error styling and dismiss button', async ({ - page, - }) => { - await mockJobsApi(page, [RUNNING_IMPORT_JOB]); - await activateJobsTray(page); + const resultResponse = page.waitForResponse( + (res) => + res.url().includes(`/api/v1/csvAsyncJobs/${jobId}/result`) && + res.status() === 200 + ); + const downloadEvent = page.waitForEvent('download'); - await expect(page.locator('.csv-jobs-tray-launcher')).toBeVisible(); - await openTray(page); - - await mockJobsApi(page, [ - { - ...RUNNING_IMPORT_JOB, - status: 'FAILED', - error: 'Invalid CSV format', - progress: 0, - total: 0, - }, - ]); - await triggerJobsRefresh(page); + await downloadButton.click(); + await resultResponse; - await expect(page.locator('.csv-jobs-tray-item-error')).toHaveCount(1); - await expect(page.locator('.csv-jobs-tray-dismiss')).toBeVisible(); + const download = await downloadEvent; + expect(download.suggestedFilename()).toContain(jobId); + expect(download.suggestedFilename()).toContain('.csv'); }); - test('dismiss button removes a completed import job and hides the tray', async ({ + test('Clear completed removes terminal jobs and hides the tray', async ({ page, + browser, }) => { - // COMPLETED EXPORT shows Download; COMPLETED IMPORT shows the dismiss (XClose) button - await mockJobsApi(page, [RUNNING_IMPORT_JOB]); - await activateJobsTray(page); + test.slow(); - await expect(page.locator('.csv-jobs-tray-launcher')).toBeVisible(); - await openTray(page); + await openExportScopeModal(page); + const jobId = await startAsyncExport(page); + + const { apiContext, afterAction } = await performAdminLogin(browser); + await waitForJobCompleted(apiContext, jobId); + await afterAction(); - await mockJobsApi(page, [ - { ...RUNNING_IMPORT_JOB, status: 'COMPLETED', progress: 10 }, - ]); await triggerJobsRefresh(page); - await expect(page.locator('.csv-jobs-tray-item-success')).toHaveCount(1); - await expect(page.locator('.csv-jobs-tray-dismiss')).toBeVisible(); - await page.locator('.csv-jobs-tray-dismiss').click(); + await expect(page.locator('.csv-jobs-tray-popover')).toBeVisible({ + timeout: 30_000, + }); + await expect( + jobItem(page, jobId).filter({ + has: page.locator('.csv-jobs-tray-item-success'), + }) + ).toBeVisible({ timeout: 30_000 }); + + await page.locator('.csv-jobs-tray-clear').click(); await expect(page.locator('.csv-jobs-tray')).not.toBeVisible(); }); - test('multiple jobs co-exist in the tray', async ({ page }) => { - await mockJobsApi(page, [RUNNING_EXPORT_JOB, RUNNING_IMPORT_JOB]); - await activateJobsTray(page); + test('does not re-open the tray after the user minimizes it', async ({ + page, + browser, + }) => { + test.slow(); - await expect(page.locator('.csv-jobs-tray-launcher')).toContainText('2'); - await openTray(page); + await openExportScopeModal(page); + const jobId = await startAsyncExport(page); - await expect(page.locator('.csv-jobs-tray-item')).toHaveCount(2); - await expect(page.getByText(/Exporting Metrics/i)).toBeVisible(); - await expect(page.getByText(/Importing Metrics/i)).toBeVisible(); - }); + const { apiContext, afterAction } = await performAdminLogin(browser); + await waitForJobCompleted(apiContext, jobId); + await afterAction(); - test('Clear completed removes all terminal jobs and hides the tray', async ({ - page, - }) => { - await mockJobsApi(page, [RUNNING_EXPORT_JOB]); - await activateJobsTray(page); + await triggerJobsRefresh(page); + + // Tray auto-opens on completion. + await expect(page.locator('.csv-jobs-tray-popover')).toBeVisible({ + timeout: 30_000, + }); + // User closes the tray. + await page.locator('.csv-jobs-tray-close').click(); + await expect(page.locator('.csv-jobs-tray-popover')).toBeHidden(); await expect(page.locator('.csv-jobs-tray-launcher')).toBeVisible(); - await openTray(page); - await mockJobsApi(page, [ - { ...RUNNING_EXPORT_JOB, status: 'COMPLETED', progress: 18 }, - ]); + // Next poll must not re-open it (autoOpenedJobIds prevents it). + const reFetch = page.waitForResponse('**/api/v1/csvAsyncJobs**'); await triggerJobsRefresh(page); + await reFetch; - await expect(page.locator('.csv-jobs-tray-item-success')).toHaveCount(1); - await page.locator('.csv-jobs-tray-clear').click(); - - await expect(page.locator('.csv-jobs-tray')).not.toBeVisible(); + await expect(page.locator('.csv-jobs-tray-popover')).toBeHidden(); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/EntityExportJobsTray.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/EntityExportJobsTray.spec.ts new file mode 100644 index 000000000000..943660fb378a --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/EntityExportJobsTray.spec.ts @@ -0,0 +1,178 @@ +/* + * Copyright 2026 Collate. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { expect, Page, test } from '@playwright/test'; + +import { DatabaseClass } from '../../support/entity/DatabaseClass'; +import { DatabaseSchemaClass } from '../../support/entity/DatabaseSchemaClass'; +import { DatabaseServiceClass } from '../../support/entity/service/DatabaseServiceClass'; +import { TableClass } from '../../support/entity/TableClass'; +import { Glossary } from '../../support/glossary/Glossary'; +import { getApiContext, redirectToHomePage } from '../../utils/common'; + +test.use({ storageState: 'playwright/.auth/admin.json' }); + +// ── helpers ────────────────────────────────────────────────────────────────── + +// Trigger export from a data asset's Manage menu and return the real jobId. +const triggerDataAssetExport = async (page: Page): Promise => { + const exportResponse = page.waitForResponse( + (response) => + response.url().includes('/exportAsync') && + response.request().method() === 'GET' && + response.ok() + ); + + await page.getByTestId('manage-button').click(); + await page + .getByTestId('manage-dropdown-list-container') + .waitFor({ state: 'visible' }); + await page.getByTestId('export-button-title').click(); + + const { jobId } = (await (await exportResponse).json()) as { jobId: string }; + + return jobId; +}; + +// Glossary uses its own Manage dropdown container and export button test id. +const triggerGlossaryExport = async (page: Page): Promise => { + const exportResponse = page.waitForResponse( + (response) => + response.url().includes('/api/v1/glossaries/name/') && + response.url().includes('/exportAsync') && + response.request().method() === 'GET' && + response.ok() + ); + + await page.getByTestId('manage-button').click(); + const manageDropdown = page + .locator('.glossary-manage-dropdown-list-container') + .last(); + await expect(manageDropdown).toBeVisible(); + await manageDropdown.getByTestId('export-button').click(); + + const { jobId } = (await (await exportResponse).json()) as { jobId: string }; + + return jobId; +}; + +// Assert that the specific job surfaces in the tray. Scoped by jobId via +// data-testid so parallel workers sharing the admin user cannot interfere. +const assertExportJobInTray = async (page: Page, jobId: string) => { + // Tray renders once the component picks up the job from its first poll + // (triggered by the csv-jobs-refresh event the export button fires). + await expect(page.locator('.csv-jobs-tray')).toBeVisible({ timeout: 30_000 }); + + // If the tray hasn't auto-opened yet (job still active), open it manually. + if (!(await page.locator('.csv-jobs-tray-popover').isVisible())) { + await page.locator('.csv-jobs-tray-launcher').click(); + } + + await expect(page.locator('.csv-jobs-tray-popover')).toBeVisible(); + + await expect( + page.locator(`[data-testid="csv-jobs-tray-item-${jobId}"]`) + ).toBeVisible({ timeout: 30_000 }); + + await expect(page.getByText(/Exporting/i).first()).toBeVisible(); +}; + +// ── suite ───────────────────────────────────────────────────────────────────── + +test.describe('Export jobs tray surfaces entity exports', () => { + test.slow(); + + test.beforeEach(async ({ page }) => { + await redirectToHomePage(page); + }); + + test('Database service export appears in the jobs tray', async ({ page }) => { + const { apiContext, afterAction } = await getApiContext(page); + const dbService = new DatabaseServiceClass(); + + try { + await dbService.create(apiContext); + await dbService.visitEntityPage(page); + + const jobId = await triggerDataAssetExport(page); + await assertExportJobInTray(page, jobId); + } finally { + await dbService.delete(apiContext); + await afterAction(); + } + }); + + test('Database export appears in the jobs tray', async ({ page }) => { + const { apiContext, afterAction } = await getApiContext(page); + const database = new DatabaseClass(); + + try { + await database.create(apiContext); + await database.visitEntityPage(page); + + const jobId = await triggerDataAssetExport(page); + await assertExportJobInTray(page, jobId); + } finally { + await database.delete(apiContext); + await afterAction(); + } + }); + + test('Database schema export appears in the jobs tray', async ({ page }) => { + const { apiContext, afterAction } = await getApiContext(page); + const schema = new DatabaseSchemaClass(); + + try { + await schema.create(apiContext); + await schema.visitEntityPage(page); + + const jobId = await triggerDataAssetExport(page); + await assertExportJobInTray(page, jobId); + } finally { + await schema.delete(apiContext); + await afterAction(); + } + }); + + test('Table export appears in the jobs tray', async ({ page }) => { + const { apiContext, afterAction } = await getApiContext(page); + const table = new TableClass(); + + try { + await table.create(apiContext); + await table.visitEntityPage(page); + + const jobId = await triggerDataAssetExport(page); + await assertExportJobInTray(page, jobId); + } finally { + await table.delete(apiContext); + await afterAction(); + } + }); + + test('Glossary export appears in the jobs tray', async ({ page }) => { + const { apiContext, afterAction } = await getApiContext(page); + const glossary = new Glossary(); + + try { + await glossary.create(apiContext); + await glossary.visitEntityPage(page); + + const jobId = await triggerGlossaryExport(page); + await assertExportJobInTray(page, jobId); + } finally { + await glossary.delete(apiContext); + await afterAction(); + } + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/EntityImport/CsvJobsTray/CsvJobsTray.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/EntityImport/CsvJobsTray/CsvJobsTray.component.tsx index c0919e2c99ca..99fb012f891b 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/EntityImport/CsvJobsTray/CsvJobsTray.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/EntityImport/CsvJobsTray/CsvJobsTray.component.tsx @@ -387,6 +387,7 @@ export const CsvJobsTray = () => { return (