Repository navigation
chore - stabilize and make e2e tests faster - part 2 - #43560
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis pull request refactors test infrastructure and improves component accessibility. The primary focus is updating test files ( Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎭 Playwright Test ResultsDetails
Flaky testsFeatures › database.spec.ts › Database › Triggers › CRUD operations works as expected Skipped testsFeatures › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@e2e/studio/features/api-access-toggle.spec.ts`:
- Around line 90-97: The setup/cleanup wrapper using withSetupCleanup currently
only drops the table in the cleanup callback, leaving stale pw_api_access_*
tables from aborted runs; modify each withSetupCleanup invocation (the one that
currently calls async () => { /* Nothing */ } and the cleanup that calls
dropTable(tableName)) to call dropTable(tableName) in the setup callback as well
as keep the existing dropTable(tableName) in the cleanup callback so pre-test
cleanup runs before the test and post-test cleanup still runs after; update all
occurrences that use withSetupCleanup, dropTable, and tableName (including the
other instances mentioned) accordingly.
In `@e2e/studio/features/queue-table-operations.spec.ts`:
- Around line 30-37: The setup function passed to withSetupCleanup currently
calls createTable(tableName, ...) without ensuring an existing pw_queue_table_*
is removed first, causing flaky tests when prior runs left rows; modify the
setup closures used with withSetupCleanup (the ones that call createTable and
reference tableName/columnName) to first call dropTable(tableName) (ignore
errors if it doesn’t exist) before calling createTable(...), leaving the current
async cleanup that calls dropTable(tableName) intact; apply the same pre-drop
change to all other withSetupCleanup blocks cited (the ones around lines
creating pw_queue_table_*) so every test starts from a clean table state.
In `@e2e/studio/features/rls-policies.spec.ts`:
- Around line 55-62: The setup closure passed to withSetupCleanup should
proactively drop any existing pw_rls_policy_* table before calling
createTableWithRLS to avoid collisions from previous runs; update the setup used
around createTableWithRLS(policyTableName, 'test') to call await
dropTable(policyTableName) (ignoring/not failing on missing table) immediately
before createTableWithRLS, and leave the existing teardown closure that calls
dropTable(policyTableName) intact; apply the same pre-drop change to every other
withSetupCleanup usage that wraps createTableWithRLS in this file (the blocks
around lines referencing createTableWithRLS, policyTableName and dropTable).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Repository UI (inherited), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 5adc742e-f1ea-4972-aa09-c4b561e1b734
📒 Files selected for processing (5)
apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/PolicyEditorPanelHeader.tsxe2e/studio/features/api-access-toggle.spec.tse2e/studio/features/queue-table-operations.spec.tse2e/studio/features/realtime-inspector.spec.tse2e/studio/features/rls-policies.spec.ts
| await using _ = await withSetupCleanup( | ||
| async () => { | ||
| // Nothing | ||
| }, | ||
| async () => { | ||
| await dropTable(tableName) | ||
| } | ||
| ) |
There was a problem hiding this comment.
Pre-test cleanup is missing from the new table-lifecycle wrapper.
withSetupCleanup() runs the first callback before the test body, and dropTable() here only runs when the await using scope exits. Because these tests reuse fixed pw_api_access_* names, an aborted prior run leaves stale tables/grants behind and the next rerun can fail on create or validate the wrong privileges. Add dropTable(tableName) to setup as well, and keep the existing cleanup after the test.
Suggested fix
await using _ = await withSetupCleanup(
async () => {
- // Nothing
+ await dropTable(tableName)
},
async () => {
await dropTable(tableName)
}
)Also applies to: 145-152, 203-210, 261-268
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@e2e/studio/features/api-access-toggle.spec.ts` around lines 90 - 97, The
setup/cleanup wrapper using withSetupCleanup currently only drops the table in
the cleanup callback, leaving stale pw_api_access_* tables from aborted runs;
modify each withSetupCleanup invocation (the one that currently calls async ()
=> { /* Nothing */ } and the cleanup that calls dropTable(tableName)) to call
dropTable(tableName) in the setup callback as well as keep the existing
dropTable(tableName) in the cleanup callback so pre-test cleanup runs before the
test and post-test cleanup still runs after; update all occurrences that use
withSetupCleanup, dropTable, and tableName (including the other instances
mentioned) accordingly.
| await using _ = await withSetupCleanup( | ||
| async () => { | ||
| await createTable(tableName, columnName, [{ name: 'original value' }]) | ||
| }, | ||
| async () => { | ||
| await dropTable(tableName) | ||
| } | ||
| ) |
There was a problem hiding this comment.
These queue tests can still start from dirty table state on reruns.
Each withSetupCleanup block creates a fixed pw_queue_table_* table in setup but never clears an existing table first. If a previous run was interrupted, the next run can reuse leftover rows and the queue assertions stop being deterministic. Pre-drop the table in setup before createTable(...), then keep the existing dispose-time cleanup.
Suggested fix
await using _ = await withSetupCleanup(
async () => {
+ await dropTable(tableName)
await createTable(tableName, columnName, [{ name: 'original value' }])
},
async () => {
await dropTable(tableName)
}
)Also applies to: 78-85, 118-125, 161-168, 206-213, 253-260, 292-299, 336-343, 369-379, 427-436
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@e2e/studio/features/queue-table-operations.spec.ts` around lines 30 - 37, The
setup function passed to withSetupCleanup currently calls createTable(tableName,
...) without ensuring an existing pw_queue_table_* is removed first, causing
flaky tests when prior runs left rows; modify the setup closures used with
withSetupCleanup (the ones that call createTable and reference
tableName/columnName) to first call dropTable(tableName) (ignore errors if it
doesn’t exist) before calling createTable(...), leaving the current async
cleanup that calls dropTable(tableName) intact; apply the same pre-drop change
to all other withSetupCleanup blocks cited (the ones around lines creating
pw_queue_table_*) so every test starts from a clean table state.
| await using _ = await withSetupCleanup( | ||
| async () => { | ||
| await createTableWithRLS(policyTableName, 'test') | ||
| }, | ||
| async () => { | ||
| await dropTable(policyTableName) | ||
| } | ||
| ) |
There was a problem hiding this comment.
The new per-test RLS setup does not clear stale tables before recreating them.
These withSetupCleanup blocks create fixed pw_rls_policy_* tables in setup, but only drop them on disposal. If a prior run leaves the table or an existing pw_test_* policy behind, the next rerun can fail when creating the policy or validate old state. Pre-drop the table in setup before createTableWithRLS(...), then keep the existing cleanup after the test.
Suggested fix
await using _ = await withSetupCleanup(
async () => {
+ await dropTable(policyTableName)
await createTableWithRLS(policyTableName, 'test')
},
async () => {
await dropTable(policyTableName)
}
)Also applies to: 83-90, 133-140, 203-210, 259-266, 314-321, 366-373, 417-424
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@e2e/studio/features/rls-policies.spec.ts` around lines 55 - 62, The setup
closure passed to withSetupCleanup should proactively drop any existing
pw_rls_policy_* table before calling createTableWithRLS to avoid collisions from
previous runs; update the setup used around createTableWithRLS(policyTableName,
'test') to call await dropTable(policyTableName) (ignoring/not failing on
missing table) immediately before createTableWithRLS, and leave the existing
teardown closure that calls dropTable(policyTableName) intact; apply the same
pre-drop change to every other withSetupCleanup usage that wraps
createTableWithRLS in this file (the blocks around lines referencing
createTableWithRLS, policyTableName and dropTable).
Braintrust eval report
|
Problem
This a follow up of #43547