Skip to content

chore - stabilize and make e2e tests faster - part 2 - #43560

Merged
djhi merged 10 commits into
masterfrom
e2e-optimize-1
Mar 9, 2026
Merged

djhi merged 10 commits into
masterfrom
e2e-optimize-1

Conversation

@djhi

@djhi djhi commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Problem

  • Some tests don't always cleanup after themselves or don't do it consistently which make it hard to work on them locally
  • Some test suites don't allow parallel execution of their tests
  • Some tests are flaky

This a follow up of #43547

@djhi
djhi requested a review from a team as a code owner March 9, 2026 13:53
@vercel

vercel Bot commented Mar 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview, Comment Mar 9, 2026 2:46pm
docs Ready Ready Preview, Comment, Open in v0 Mar 9, 2026 2:46pm
learn Ready Ready Preview, Comment Mar 9, 2026 2:46pm
studio-self-hosted Ready Ready Preview, Comment Mar 9, 2026 2:46pm
studio-staging Ready Ready Preview, Comment Mar 9, 2026 2:46pm
ui-library Ready Ready Preview, Comment Mar 9, 2026 2:46pm
zone-www-dot-com Ready Ready Preview, Comment, Open in v0 Mar 9, 2026 2:46pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
cms Ignored Ignored Mar 9, 2026 2:46pm
studio Ignored Ignored Mar 9, 2026 2:46pm

Request Review

@supabase

supabase Bot commented Mar 9, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Summary by CodeRabbit

  • Improvements
    • Enhanced accessibility for the policy editor panel with improved screen reader announcements for the tools button visibility toggle.

Walkthrough

This pull request refactors test infrastructure and improves component accessibility. The primary focus is updating test files (api-access-toggle.spec.ts, queue-table-operations.spec.ts, realtime-inspector.spec.ts, and rls-policies.spec.ts) to use a new withSetupCleanup pattern that provides per-test resource management instead of global beforeAll/afterAll hooks. This includes improved test isolation through per-test table creation, cleanup, and unique identifiers (such as per-test channel names in realtime tests). Additionally, PolicyEditorPanelHeader.tsx adds screen-reader-only announcement text and reorganizes imports.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  153 passed
flaky  2 flaky
skipped  4 skipped

Details

stats  159 tests across 20 suites
duration  11 minutes, 12 seconds
commit  8813ce4

Flaky tests

Features › database.spec.ts › Database › Triggers › CRUD operations works as expected
Features › realtime-inspector.spec.ts › Realtime Inspector › Broadcast Messages › broadcast modal validates JSON payload

Skipped tests

Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

@awaseem awaseem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from e2e-general-improvements to master March 9, 2026 14:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4d37a5f and 8813ce4.

📒 Files selected for processing (5)
  • apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/PolicyEditorPanelHeader.tsx
  • e2e/studio/features/api-access-toggle.spec.ts
  • e2e/studio/features/queue-table-operations.spec.ts
  • e2e/studio/features/realtime-inspector.spec.ts
  • e2e/studio/features/rls-policies.spec.ts

Comment on lines +90 to +97
await using _ = await withSetupCleanup(
async () => {
// Nothing
},
async () => {
await dropTable(tableName)
}
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Comment on lines +30 to +37
await using _ = await withSetupCleanup(
async () => {
await createTable(tableName, columnName, [{ name: 'original value' }])
},
async () => {
await dropTable(tableName)
}
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Comment on lines +55 to +62
await using _ = await withSetupCleanup(
async () => {
await createTableWithRLS(policyTableName, 'test')
},
async () => {
await dropTable(policyTableName)
}
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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).

@djhi
djhi merged commit d004d13 into master Mar 9, 2026
23 checks passed
@djhi
djhi deleted the e2e-optimize-1 branch March 9, 2026 15:10
@github-actions

github-actions Bot commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1773069271)

Score Average Improvements Regressions
Completeness 88.9% (-8pp) - 2 🔴
Conciseness 0% (-1pp) - 1 🔴
Goal Completion 91.7% (-5pp) - 3 🔴
SQL Identifier Quoting 93.3% (-7.000000000000001pp) - 1 🔴
SQL Validity 100% (+0pp) - -
Tool Usage 97% (-3pp) - 1 🔴
Correctness 79.2% (-21pp) - 2 🔴
Docs Faithfulness 58.3% (-3pp) - 1 🔴
URL Validity 100% (+17pp) - -
Time_to_first_token 0.2tok (-0.06tok) 8 🟢 4 🔴
Llm_calls 8.53 (+0.08) 5 🟢 4 🔴
Tool_calls 3.25 (+0.06) 4 🟢 5 🔴
Errors 0 (+0) - -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 46127.42tok (-272.36tok) 5 🟢 7 🔴
Prompt_cached_tokens 27712tok (+298.67tok) 6 🟢 4 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Completion_tokens 2684.61tok (+110.28tok) 5 🟢 7 🔴
Completion_reasoning_tokens 1952tok (+94.22tok) 7 🟢 5 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 48812.03tok (-162.08tok) 5 🟢 7 🔴
Estimated_cost 0.01$ (+0$) 4 🟢 7 🔴
Duration 40.74s (-13.8s) 12 🟢 -
Llm_duration 79.92s (-27.47s) 12 🟢 -

djhi added a commit that referenced this pull request Mar 9, 2026
…able (#43566)

Follow up of #43547 and #43560

## Problem

The cron job tests run in serial mode and can be flaky.

## Solution

- Use simple query to install the `pg_cron` extension (way faster than
using UI)
- Make sure all tests can run in parallel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants