Skip to content

Commit 312e9fd

Browse files
authored
chore: add additional playwright tests for table editor (supabase#37972)
1 parent 112cc89 commit 312e9fd

File tree

10 files changed

+627
-369
lines changed

10 files changed

+627
-369
lines changed

apps/studio/components/grid/components/footer/pagination/Pagination.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ const Pagination = () => {
149149
<>
150150
<div className="flex items-center gap-x-2">
151151
<Button
152+
aria-label="Previous page"
152153
icon={<ArrowLeft />}
153154
type="outline"
154155
className="px-1.5"
@@ -179,6 +180,7 @@ const Pagination = () => {
179180
<p className="text-xs text-foreground-light">of {totalPages.toLocaleString()}</p>
180181

181182
<Button
183+
aria-label="Next page"
182184
icon={<ArrowRight />}
183185
type="outline"
184186
className="px-1.5"

apps/studio/components/ui/GridFooter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { cn } from 'ui'
44
export const GridFooter = ({ children, className }: PropsWithChildren<{ className?: string }>) => {
55
return (
66
<div
7+
aria-label="Table grid footer"
78
className={cn(
89
'flex min-h-9 h-9 overflow-hidden overflow-x-auto items-center px-2 w-full border-t',
910
className

e2e/studio/features/database.spec.ts

Lines changed: 10 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, Page } from '@playwright/test'
22
import { env } from '../env.config'
33
import { test } from '../utils/test'
44
import { toUrl } from '../utils/to-url'
5-
import { waitForApiResponse } from '../utils/wait-for-response'
5+
import { waitForApiResponse, waitForDatabaseToLoad } from '../utils/wait-for-response'
66

77
const databaseTableName = 'pw_database_table'
88
const databaseTableNameNew = 'pw_database_table_new'
@@ -89,12 +89,7 @@ test.describe('Database', () => {
8989
await page.goto(toUrl(`/project/${env.PROJECT_REF}/database/schemas?schema=public`))
9090

9191
// Wait for schema visualizer to load
92-
await waitForApiResponse(
93-
page,
94-
'pg-meta',
95-
ref,
96-
'tables?include_columns=true&included_schemas=public'
97-
)
92+
await waitForDatabaseToLoad(page, ref)
9893

9994
// validates table and column exists
10095
await page.waitForTimeout(500)
@@ -122,12 +117,7 @@ test.describe('Database', () => {
122117
// changing schema -> auth
123118
await page.getByTestId('schema-selector').click()
124119
await page.getByRole('option', { name: 'auth' }).click()
125-
await waitForApiResponse(
126-
page,
127-
'pg-meta',
128-
ref,
129-
'tables?include_columns=true&included_schemas=auth'
130-
)
120+
await waitForDatabaseToLoad(page, ref, 'auth')
131121
await expect(page.getByText('users')).toBeVisible()
132122
await expect(page.getByText('sso_providers')).toBeVisible()
133123
await expect(page.getByText('saml_providers')).toBeVisible()
@@ -145,12 +135,7 @@ test.describe('Database', () => {
145135
await page.goto(toUrl(`/project/${env.PROJECT_REF}/database/tables?schema=public`))
146136

147137
// Wait for database tables to be populated
148-
await waitForApiResponse(
149-
page,
150-
'pg-meta',
151-
ref,
152-
'tables?include_columns=true&included_schemas=public'
153-
)
138+
await waitForDatabaseToLoad(page, ref)
154139

155140
// check new table button is present in public schema
156141
await expect(page.getByRole('button', { name: 'New table' })).toBeVisible()
@@ -166,12 +151,7 @@ test.describe('Database', () => {
166151
await page.getByTestId('schema-selector').click()
167152
await page.getByPlaceholder('Find schema...').fill('auth')
168153
await page.getByRole('option', { name: 'auth' }).click()
169-
await waitForApiResponse(
170-
page,
171-
'pg-meta',
172-
ref,
173-
'tables?include_columns=true&included_schemas=auth'
174-
)
154+
await waitForDatabaseToLoad(page, ref, 'auth')
175155
await expect(page.getByText('sso_providers')).toBeVisible()
176156
// check new table button is not present in other schemas
177157
await expect(page.getByRole('button', { name: 'New table' })).not.toBeVisible()
@@ -187,12 +167,7 @@ test.describe('Database', () => {
187167
await page.goto(toUrl(`/project/${env.PROJECT_REF}/database/tables?schema=public`))
188168

189169
// Wait for database tables to be populated
190-
await waitForApiResponse(
191-
page,
192-
'pg-meta',
193-
ref,
194-
'tables?include_columns=true&included_schemas=public'
195-
)
170+
await waitForDatabaseToLoad(page, ref)
196171

197172
// drop database tables if exists
198173
if ((await page.getByText(databaseTableNameNew, { exact: true }).count()) > 0) {
@@ -229,12 +204,7 @@ test.describe('Database', () => {
229204

230205
// validate table creation
231206
await waitForApiResponse(page, 'pg-meta', ref, 'query?key=table-create')
232-
await waitForApiResponse(
233-
page,
234-
'pg-meta',
235-
ref,
236-
'tables?include_columns=true&included_schemas=public'
237-
)
207+
await waitForDatabaseToLoad(page, ref)
238208
await expect(page.getByText(databaseTableNameNew, { exact: true })).toBeVisible()
239209

240210
// edit a new table
@@ -245,12 +215,7 @@ test.describe('Database', () => {
245215

246216
// validate table update
247217
await waitForApiResponse(page, 'pg-meta', ref, 'query?key=table-update')
248-
await waitForApiResponse(
249-
page,
250-
'pg-meta',
251-
ref,
252-
'tables?include_columns=true&included_schemas=public'
253-
)
218+
await waitForDatabaseToLoad(page, ref)
254219
await expect(page.getByText(databaseTableNameUpdated, { exact: true })).toBeVisible()
255220

256221
// duplicate table
@@ -262,12 +227,7 @@ test.describe('Database', () => {
262227

263228
// validate table duplicate
264229
await waitForApiResponse(page, 'pg-meta', ref, 'query?key=')
265-
await waitForApiResponse(
266-
page,
267-
'pg-meta',
268-
ref,
269-
'tables?include_columns=true&included_schemas=public'
270-
)
230+
await waitForDatabaseToLoad(page, ref)
271231
await expect(page.getByText(databaseTableNameDuplicate, { exact: true })).toBeVisible()
272232

273233
// delete tables
@@ -302,12 +262,7 @@ test.describe('Database', () => {
302262
await page.goto(toUrl(`/project/${env.PROJECT_REF}/database/tables?schema=public`))
303263

304264
// Wait for database tables to be populated
305-
await waitForApiResponse(
306-
page,
307-
'pg-meta',
308-
ref,
309-
'tables?include_columns=true&included_schemas=public'
310-
)
265+
await waitForDatabaseToLoad(page, ref)
311266

312267
// navigate to table columns
313268
const databaseRow = page.getByRole('row', { name: databaseTableName })
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
id,created_at,pw_column
2+
1,2025-01-01 12:00:00.000000+00,value 1 to delete
3+
2,2025-01-01 12:00:00.000000+00,value 2 to delete
4+
3,2025-01-01 12:00:00.000000+00,value 3 to delete
5+
4,2025-01-01 12:00:00.000000+00,value 4 to export
6+
5,2025-01-01 12:00:00.000000+00,value 5 to export
7+
6,2025-01-01 12:00:00.000000+00,value 6 to export
8+
7,2025-01-01 12:00:00.000000+00,value 7
9+
8,2025-01-01 12:00:00.000000+00,value 8
10+
9,2025-01-01 12:00:00.000000+00,value 9
11+
10,2025-01-01 12:00:00.000000+00,value 10
12+
11,2025-01-01 12:00:00.000000+00,value 11
13+
12,2025-01-01 12:00:00.000000+00,value 12
14+
13,2025-01-01 12:00:00.000000+00,value 13
15+
14,2025-01-01 12:00:00.000000+00,value 14
16+
15,2025-01-01 12:00:00.000000+00,value 15
17+
16,2025-01-01 12:00:00.000000+00,value 16
18+
17,2025-01-01 12:00:00.000000+00,value 17
19+
18,2025-01-01 12:00:00.000000+00,value 18
20+
19,2025-01-01 12:00:00.000000+00,value 19
21+
20,2025-01-01 12:00:00.000000+00,value 20
22+
21,2025-01-01 12:00:00.000000+00,value 21
23+
22,2025-01-01 12:00:00.000000+00,value 22
24+
23,2025-01-01 12:00:00.000000+00,value 23
25+
24,2025-01-01 12:00:00.000000+00,value 24
26+
25,2025-01-01 12:00:00.000000+00,value 25
27+
26,2025-01-01 12:00:00.000000+00,value 26
28+
27,2025-01-01 12:00:00.000000+00,value 27
29+
28,2025-01-01 12:00:00.000000+00,value 28
30+
29,2025-01-01 12:00:00.000000+00,value 29
31+
30,2025-01-01 12:00:00.000000+00,value 30
32+
31,2025-01-01 12:00:00.000000+00,value 31
33+
32,2025-01-01 12:00:00.000000+00,value 32
34+
33,2025-01-01 12:00:00.000000+00,value 33
35+
34,2025-01-01 12:00:00.000000+00,value 34
36+
35,2025-01-01 12:00:00.000000+00,value 35
37+
36,2025-01-01 12:00:00.000000+00,value 36
38+
37,2025-01-01 12:00:00.000000+00,value 37
39+
38,2025-01-01 12:00:00.000000+00,value 38
40+
39,2025-01-01 12:00:00.000000+00,value 39
41+
40,2025-01-01 12:00:00.000000+00,value 40
42+
41,2025-01-01 12:00:00.000000+00,value 41
43+
42,2025-01-01 12:00:00.000000+00,value 42
44+
43,2025-01-01 12:00:00.000000+00,value 43
45+
44,2025-01-01 12:00:00.000000+00,value 44
46+
45,2025-01-01 12:00:00.000000+00,value 45
47+
46,2025-01-01 12:00:00.000000+00,value 46
48+
47,2025-01-01 12:00:00.000000+00,value 47
49+
48,2025-01-01 12:00:00.000000+00,value 48
50+
49,2025-01-01 12:00:00.000000+00,value 49
51+
50,2025-01-01 12:00:00.000000+00,value 50
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
id,created_at,pw_column
2+
51,2025-01-01 12:00:00.000000+00,value 51
3+
52,2025-01-01 12:00:00.000000+00,value 52
4+
53,2025-01-01 12:00:00.000000+00,value 53
5+
54,2025-01-01 12:00:00.000000+00,value 54
6+
55,2025-01-01 12:00:00.000000+00,value 55
7+
56,2025-01-01 12:00:00.000000+00,value 56
8+
57,2025-01-01 12:00:00.000000+00,value 57
9+
58,2025-01-01 12:00:00.000000+00,value 58
10+
59,2025-01-01 12:00:00.000000+00,value 59
11+
60,2025-01-01 12:00:00.000000+00,value 60
12+
61,2025-01-01 12:00:00.000000+00,value 61
13+
62,2025-01-01 12:00:00.000000+00,value 62
14+
63,2025-01-01 12:00:00.000000+00,value 63
15+
64,2025-01-01 12:00:00.000000+00,value 64
16+
65,2025-01-01 12:00:00.000000+00,value 65
17+
66,2025-01-01 12:00:00.000000+00,value 66
18+
67,2025-01-01 12:00:00.000000+00,value 67
19+
68,2025-01-01 12:00:00.000000+00,value 68
20+
69,2025-01-01 12:00:00.000000+00,value 69
21+
70,2025-01-01 12:00:00.000000+00,value 70
22+
71,2025-01-01 12:00:00.000000+00,value 71
23+
72,2025-01-01 12:00:00.000000+00,value 72
24+
73,2025-01-01 12:00:00.000000+00,value 73
25+
74,2025-01-01 12:00:00.000000+00,value 74
26+
75,2025-01-01 12:00:00.000000+00,value 75
27+
76,2025-01-01 12:00:00.000000+00,value 76
28+
77,2025-01-01 12:00:00.000000+00,value 77
29+
78,2025-01-01 12:00:00.000000+00,value 78
30+
79,2025-01-01 12:00:00.000000+00,value 79
31+
80,2025-01-01 12:00:00.000000+00,value 80
32+
81,2025-01-01 12:00:00.000000+00,value 81
33+
82,2025-01-01 12:00:00.000000+00,value 82
34+
83,2025-01-01 12:00:00.000000+00,value 83
35+
84,2025-01-01 12:00:00.000000+00,value 84
36+
85,2025-01-01 12:00:00.000000+00,value 85
37+
86,2025-01-01 12:00:00.000000+00,value 86
38+
87,2025-01-01 12:00:00.000000+00,value 87
39+
88,2025-01-01 12:00:00.000000+00,value 88
40+
89,2025-01-01 12:00:00.000000+00,value 89
41+
90,2025-01-01 12:00:00.000000+00,value 90
42+
91,2025-01-01 12:00:00.000000+00,value 91
43+
92,2025-01-01 12:00:00.000000+00,value 92
44+
93,2025-01-01 12:00:00.000000+00,value 93
45+
94,2025-01-01 12:00:00.000000+00,value 94
46+
95,2025-01-01 12:00:00.000000+00,value 95
47+
96,2025-01-01 12:00:00.000000+00,value 96
48+
97,2025-01-01 12:00:00.000000+00,value 97
49+
98,2025-01-01 12:00:00.000000+00,value 98
50+
99,2025-01-01 12:00:00.000000+00,value 99
51+
100,2025-01-01 12:00:00.000000+00,value 100
52+
101,2025-01-01 12:00:00.000000+00,value 101

e2e/studio/features/sql-editor.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { test } from '../utils/test'
55
import { toUrl } from '../utils/to-url'
66
import { waitForApiResponse } from '../utils/wait-for-response'
77
import { waitForApiResponseWithTimeout } from '../utils/wait-for-response-with-timeout'
8+
import { resetLocalStorage } from '../utils/reset-local-storage'
89

910
const sqlSnippetName = 'pw_sql_snippet'
1011
const sqlSnippetNameDuplicate = 'pw_sql_snippet (Duplicate)'
@@ -58,10 +59,7 @@ test.describe('SQL Editor', () => {
5859
page = await browser.newPage()
5960
await page.goto(toUrl(`/project/${ref}/sql/new?skip=true`))
6061

61-
await page.evaluate((ref) => {
62-
localStorage.removeItem('dashboard-history-default')
63-
localStorage.removeItem(`dashboard-history-${ref}`)
64-
}, ref)
62+
await resetLocalStorage(page, ref)
6563

6664
// intercept AI title generation to prevent flaky tests
6765
await page.route('**/dashboard/api/ai/sql/title-v2', async (route) => {

0 commit comments

Comments
 (0)