From 0dcf758b5aa577ee5366c66ba429f567cbaaabca Mon Sep 17 00:00:00 2001 From: anuj-kumary Date: Thu, 23 Apr 2026 11:34:40 +0530 Subject: [PATCH 1/2] test: resolve flaky CSVImportWithQuotesAndCommas test due to timeout race condition --- .../ui/playwright/utils/importUtils.ts | 4 ++-- .../src/components/UploadFile/UploadFile.tsx | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/importUtils.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/importUtils.ts index 5431420d3cfd..db1d9821c139 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/importUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/importUtils.ts @@ -538,9 +538,9 @@ export const uploadCSVAndWaitForGrid = async ( } await page.setInputFiles('[type="file"]', actualFilePath); - await page.getByTestId('upload-file-widget').waitFor({ state: 'hidden' }); + await page.getByTestId('upload-file-widget').waitFor({ state: 'hidden', timeout: 30000 }); - await expect(page.locator('.rdg-header-row')).toBeVisible(); + await page.locator('.rdg-header-row').waitFor({ state: 'visible', timeout: 30000 }); const rowCount = await page.locator('.rdg-row').count(); return { rowCount, tempFilePath }; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/UploadFile/UploadFile.tsx b/openmetadata-ui/src/main/resources/ui/src/components/UploadFile/UploadFile.tsx index 1ceb7eeeaf2c..b9a69089435f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/UploadFile/UploadFile.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/UploadFile/UploadFile.tsx @@ -35,20 +35,23 @@ const UploadFile: FC = ({ const handleUpload: UploadProps['customRequest'] = useCallback( (options: UploadRequestOption) => { setUploading(true); + const reader = new FileReader(); + reader.onload = (e) => { + setUploading(false); + onCSVUploaded(e); + }; + reader.onerror = () => { + setUploading(false); + showErrorToast(new Error(t('server.unexpected-error')) as AxiosError); + }; try { - const reader = new FileReader(); - reader.onload = onCSVUploaded; - reader.onerror = () => { - throw t('server.unexpected-error'); - }; reader.readAsText(options.file as Blob); } catch (error) { - showErrorToast(error as AxiosError); - } finally { setUploading(false); + showErrorToast(error as AxiosError); } }, - [onCSVUploaded] + [onCSVUploaded, t] ); return uploading ? ( From 671f12dc07f80dcc4818628825bb518bcd15c9be Mon Sep 17 00:00:00 2001 From: anuj-kumary Date: Thu, 23 Apr 2026 11:36:37 +0530 Subject: [PATCH 2/2] fix lint issue --- .../src/main/resources/ui/playwright/utils/importUtils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/importUtils.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/importUtils.ts index db1d9821c139..6427b438d32e 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/importUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/importUtils.ts @@ -538,9 +538,13 @@ export const uploadCSVAndWaitForGrid = async ( } await page.setInputFiles('[type="file"]', actualFilePath); - await page.getByTestId('upload-file-widget').waitFor({ state: 'hidden', timeout: 30000 }); + await page + .getByTestId('upload-file-widget') + .waitFor({ state: 'hidden', timeout: 30000 }); - await page.locator('.rdg-header-row').waitFor({ state: 'visible', timeout: 30000 }); + await page + .locator('.rdg-header-row') + .waitFor({ state: 'visible', timeout: 30000 }); const rowCount = await page.locator('.rdg-row').count(); return { rowCount, tempFilePath }; };