The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: add test for undo feature for queue operations (#43984)
Ali Waseemb13ee5424c28
diff --git a/e2e/studio/features/queue-table-operations.spec.ts b/e2e/studio/features/queue-table-operations.spec.tsindex abe8c4ce167..9a0fd34281a 100644--- a/e2e/studio/features/queue-table-operations.spec.ts+++ b/e2e/studio/features/queue-table-operations.spec.ts@@ -285,6 +285,164 @@ test.describe('Queue Table Operations', () => {await expect(page.getByRole('gridcell', { name: 'shortcut test' })).toBeVisible()})+ test('undo reverts the latest operation from the queue', async ({ page, ref }) => {+ const tableName = `${tableNamePrefix}_undo`+ const columnName = 'name'++ await using _ = await withSetupCleanup(+ async () => {+ await createTable(tableName, columnName, [{ name: 'existing row' }])+ },+ async () => {+ await dropTable(tableName)+ }+ )++ await page.goto(toUrl(`/project/${ref}/editor?schema=public`))+ await enableQueueOperations(page)+ await page.reload()+ await waitForTableToLoad(page, ref)++ await page.getByRole('button', { name: `View ${tableName}`, exact: true }).click()+ await page.waitForURL(/\/editor\/\d+\?schema=public$/)++ await expect(page.getByRole('gridcell', { name: 'existing row' })).toBeVisible()++ await page.getByTestId('table-editor-insert-new-row').click()+ await page.getByRole('menuitem', { name: 'Insert row Insert a new row' }).click()+ await page.getByTestId(`${columnName}-input`).fill('undo this row')+ await page.getByTestId('action-bar-save-row').click()++ await expect(page.getByText('1 pending change')).toBeVisible()+ await expect(page.getByRole('gridcell', { name: 'undo this row' })).toBeVisible()++ await page.keyboard.press('ControlOrMeta+z')++ await expect(page.getByText('pending change')).not.toBeVisible()+ await expect(page.getByRole('gridcell', { name: 'undo this row' })).not.toBeVisible()+ await expect(page.getByRole('gridcell', { name: 'existing row' })).toBeVisible()+ })++ test('undo reverts operations one at a time', async ({ page, ref }) => {+ const tableName = `${tableNamePrefix}_undo_multi`+ const columnName = 'name'++ await using _ = await withSetupCleanup(+ async () => {+ await createTable(tableName, columnName)+ },+ async () => {+ await dropTable(tableName)+ }+ )++ await page.goto(toUrl(`/project/${ref}/editor?schema=public`))+ await enableQueueOperations(page)+ await page.reload()+ await waitForTableToLoad(page, ref)++ await page.getByRole('button', { name: `View ${tableName}`, exact: true }).click()+ await page.waitForURL(/\/editor\/\d+\?schema=public$/)++ await page.getByTestId('table-editor-insert-new-row').click()+ await page.getByRole('menuitem', { name: 'Insert row Insert a new row' }).click()+ await page.getByTestId(`${columnName}-input`).fill('first row')+ await page.getByTestId('action-bar-save-row').click()++ await page.getByTestId('table-editor-insert-new-row').click()+ await page.getByRole('menuitem', { name: 'Insert row Insert a new row' }).click()+ await page.getByTestId(`${columnName}-input`).fill('second row')+ await page.getByTestId('action-bar-save-row').click()++ await expect(page.getByText('2 pending changes')).toBeVisible()++ await page.keyboard.press('ControlOrMeta+z')++ await expect(page.getByText('1 pending change')).toBeVisible()+ await expect(page.getByRole('gridcell', { name: 'first row' })).toBeVisible()+ await expect(page.getByRole('gridcell', { name: 'second row' })).not.toBeVisible()++ await page.keyboard.press('ControlOrMeta+z')++ await expect(page.getByText('pending change')).not.toBeVisible()+ await expect(page.getByRole('gridcell', { name: 'first row' })).not.toBeVisible()+ })++ test('undo works for cell edits', async ({ page, ref }) => {+ const tableName = `${tableNamePrefix}_undo_edit`+ const columnName = 'name'++ await using _ = await withSetupCleanup(+ async () => {+ await createTable(tableName, columnName, [{ name: 'original value' }])+ },+ async () => {+ await dropTable(tableName)+ }+ )++ await page.goto(toUrl(`/project/${ref}/editor?schema=public`))+ await enableQueueOperations(page)+ await page.reload()+ await waitForTableToLoad(page, ref)++ await page.getByRole('button', { name: `View ${tableName}`, exact: true }).click()+ await page.waitForURL(/\/editor\/\d+\?schema=public$/)++ await expect(page.getByRole('gridcell', { name: 'original value' })).toBeVisible()++ const cell = page.getByRole('gridcell', { name: 'original value' })+ await cell.dblclick()++ const editor = page.getByRole('textbox', { name: /Editor content/ })+ await expect(editor).toBeVisible()+ await editor.fill('edited value')+ await page.keyboard.press('Enter')++ await expect(page.getByText('1 pending change')).toBeVisible()++ await page.keyboard.press('ControlOrMeta+z')++ await expect(page.getByText('pending change')).not.toBeVisible()+ await expect(page.getByRole('gridcell', { name: 'original value' })).toBeVisible()+ await expect(page.getByRole('gridcell', { name: 'edited value' })).not.toBeVisible()+ })++ test('undo works for row deletes', async ({ page, ref }) => {+ const tableName = `${tableNamePrefix}_undo_del`+ const columnName = 'name'++ await using _ = await withSetupCleanup(+ async () => {+ await createTable(tableName, columnName, [{ name: 'row to keep' }])+ },+ async () => {+ await dropTable(tableName)+ }+ )++ await page.goto(toUrl(`/project/${ref}/editor?schema=public`))+ await enableQueueOperations(page)+ await page.reload()+ await waitForTableToLoad(page, ref)++ await page.getByRole('button', { name: `View ${tableName}`, exact: true }).click()+ await page.waitForURL(/\/editor\/\d+\?schema=public$/)++ await expect(page.getByRole('gridcell', { name: 'row to keep' })).toBeVisible()++ const cell = page.getByRole('gridcell', { name: 'row to keep' })+ await cell.click({ button: 'right' })+ await page.getByRole('menuitem', { name: 'Delete row' }).click()++ await expect(page.getByText('1 pending change')).toBeVisible()++ await page.keyboard.press('ControlOrMeta+z')++ await expect(page.getByText('pending change')).not.toBeVisible()+ await expect(page.getByRole('gridcell', { name: 'row to keep' })).toBeVisible()+ })+test('row deletes via context menu are queued', async ({ page, ref }) => {const tableName = `${tableNamePrefix}_row_delete`const columnName = 'name'