chore: add E2E tests for simulating a drag and drop CSV (#42658)

## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Chore: test drag and drop on table editor 

follow up for https://github.com/supabase/supabase/issues/42655

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Tests**
* Added comprehensive end-to-end test for CSV drag-and-drop import
functionality that validates the complete import workflow: drag-drop
detection on empty tables, import dialog display with accurate row
counts, and successful data import to the grid.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Ali Waseem authored and GitHub committed 2026-02-10 20:39:06 +00:00
1 parent 997d2c365a
commit 37748b5078
3 files changed
+67

No files matched your search

@@ -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}
@@ -0,0 +1,4 @@
id,pw_column
1,drag drop value 1
2,drag drop value 2
3,drag drop value 3
1 id pw_column
2 1 drag drop value 1
3 2 drag drop value 2
4 3 drag drop value 3
+62
View File
@@ -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)
})
})