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..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' }); + 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 ? (