The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: add E2E tests for simulating a drag and drop CSV (#42658)
Ali Waseem37748b5078cc
diff --git a/apps/studio/components/grid/components/grid/Grid.tsx b/apps/studio/components/grid/components/grid/Grid.tsxindex d57ac84322e..0ee375115af 100644--- a/apps/studio/components/grid/components/grid/Grid.tsx+++ b/apps/studio/components/grid/components/grid/Grid.tsx@@ -230,6 +230,7 @@ export const Grid = memo(return (<div+ data-testid="table-editor-grid-container"className={cn('flex flex-col relative transition-colors', containerClass)}style={{ width: width || '100%', height: height || '50vh' }}onDragOver={onDragOver}diff --git a/e2e/studio/features/files/table-editor-drag-drop.csv b/e2e/studio/features/files/table-editor-drag-drop.csvnew file mode 100644index 00000000000..cef853d61e7--- /dev/null+++ b/e2e/studio/features/files/table-editor-drag-drop.csv@@ -0,0 +1,4 @@+id,pw_column+1,drag drop value 1+2,drag drop value 2+3,drag drop value 3diff --git a/e2e/studio/features/table-editor.spec.ts b/e2e/studio/features/table-editor.spec.tsindex 662816d4563..61933ed6b56 100644--- a/e2e/studio/features/table-editor.spec.ts+++ b/e2e/studio/features/table-editor.spec.ts@@ -1,6 +1,7 @@import { expect, Page } from '@playwright/test'import fs from 'fs'import path from 'path'+import { createTable as dbCreateTable, dropTable } from '../utils/db/index.js'import { env } from '../env.config.js'import { releaseFileOnceCleanup, withFileOnceSetup } from '../utils/once-per-file.js'import { resetLocalStorage } from '../utils/reset-local-storage.js'@@ -1172,4 +1173,65 @@ testRunner('table editor', () => {await deleteTable(page, ref, sourceTableName)await deleteTable(page, ref, targetTableName)})++ test('CSV drag and drop imports data on empty table', async ({ page, ref }) => {+ const tableName = 'pw_table_csv_drag_drop'++ await dropTable(tableName)+ await dbCreateTable(tableName, columnName)++ const loadPromise = waitForTableToLoad(page, ref)+ await page.goto(toUrl(`/project/${ref}/editor?schema=public`))+ await loadPromise++ await page.getByRole('button', { name: `View ${tableName}`, exact: true }).click()+ await page.waitForURL(/\/editor\/\d+\?schema=public$/)++ await expect(+ page.getByText('or drag and drop a CSV file here'),+ 'Empty table should show drag and drop hint'+ ).toBeVisible()++ const csvFilePath = path.join(import.meta.dirname, 'files', 'table-editor-drag-drop.csv')+ const csvBuffer = fs.readFileSync(csvFilePath)++ // Synthesize a DataTransfer with the CSV file to simulate a browser file drag-and-drop+ const dataTransfer = await page.evaluateHandle((csvBase64: string) => {+ const dt = new DataTransfer()+ const bytes = Uint8Array.from(atob(csvBase64), (c) => c.charCodeAt(0))+ const file = new File([bytes], 'table-editor-drag-drop.csv', { type: 'text/csv' })+ dt.items.add(file)+ return dt+ }, csvBuffer.toString('base64'))++ const gridContainer = page.getByTestId('table-editor-grid-container')++ await gridContainer.dispatchEvent('dragover', { dataTransfer })+ await expect(+ page.getByText('Drop your CSV file here'),+ 'Drag feedback should show when CSV is dragged over'+ ).toBeVisible()++ await gridContainer.dispatchEvent('drop', { dataTransfer })++ await expect(+ page.getByText('A total of 3 rows will be'),+ 'Import dialog should show correct row count from CSV'+ ).toBeVisible({ timeout: 10_000 })++ const waitForCsvInsert = createApiResponseWaiter(page, 'pg-meta', ref, 'query?key=', {+ method: 'POST',+ })+ await page.getByRole('button', { name: 'Import data' }).click()+ await waitForCsvInsert+ await waitForGridDataToLoad(page, ref)++ await expect(+ page.getByText('3 records'),+ 'Table should show 3 records after drag and drop import'+ ).toBeVisible()+ await expect(page.getByRole('gridcell', { name: 'drag drop value 1' })).toBeVisible()++ await dropTable(tableName)+ })})