Skip to content

e2e(studio): index advisor tests#41246

Merged
awaseem merged 10 commits intomasterfrom
e2e/add-index-advisor-tests
Dec 11, 2025
Merged

e2e(studio): index advisor tests#41246
awaseem merged 10 commits intomasterfrom
e2e/add-index-advisor-tests

Conversation

@kemaldotearth
Copy link
Contributor

@kemaldotearth kemaldotearth commented Dec 10, 2025

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Adds a series of tests to make sure Index Advisor is enabled and warnings show in Query Performance.

Summary by CodeRabbit

  • Tests
    • Added comprehensive end-to-end test suite for the Index Advisor feature, including validation of extension status, functionality verification, and anti-flakiness measures to ensure reliable test execution.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Dec 10, 2025

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

Project Deployment Preview Comments Updated (UTC)
docs Ready Ready Preview Comment Dec 11, 2025 0:25am
7 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
studio Ignored Ignored Dec 11, 2025 0:25am
cms Skipped Skipped Dec 11, 2025 0:25am
design-system Skipped Skipped Dec 11, 2025 0:25am
studio-self-hosted Skipped Skipped Dec 11, 2025 0:25am
studio-staging Skipped Skipped Dec 11, 2025 0:25am
ui-library Skipped Skipped Dec 11, 2025 0:25am
zone-www-dot-com Skipped Skipped Dec 11, 2025 0:25am

@supabase
Copy link

supabase bot commented Dec 10, 2025

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 ↗︎.

@kemaldotearth kemaldotearth marked this pull request as ready for review December 10, 2025 17:17
@github-actions
Copy link
Contributor

github-actions bot commented Dec 10, 2025

🎭 Playwright Test Results

passed  65 passed
skipped  4 skipped

Details

stats  69 tests across 11 suites
duration  9 minutes, 23 seconds
commit  603d09d

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
Copy link
Contributor

awaseem commented Dec 11, 2025

We can remove all the tests related to the banner, I don't think that needs to be tested IMO. Just enabling and viewing the index in query performance

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

Walkthrough

Introduces a new end-to-end test suite for the Index Advisor feature that verifies extension enablement and warning detection. The suite includes helper functions for extension management, test table creation, query execution, and anti-flakiness measures using explicit waits and API response hooks.

Changes

Cohort / File(s) Summary
New Index Advisor E2E Test Suite
e2e/studio/features/index-advisor.spec.ts
Adds a serial test suite with helper functions to verify Index Advisor functionality. Includes checks for extension status, enables hypopg and index_advisor extensions, creates test tables, executes queries, and validates Index Advisor warnings appear in Query Performance. Implements anti-flakiness measures with explicit waits, API response hooks, and graceful fallback handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify the correctness and robustness of helper functions (checkIndexAdvisorExtensionsEnabled, enableIndexAdvisorViaExtensions, createTestTable, runQueryNeedingIndex)
  • Validate that API-wait hooks and timeouts are appropriately configured to prevent flakiness
  • Confirm that cleanup logic in afterAll safely handles all test artifacts
  • Review the test flow logic to ensure state management between test sections is correct
  • Verify that fallback handling for optional UI elements won't mask real failures

Poem

🐰 A test suite hops through extensions with care,
Index Advisor's wisdom floats in the air!
With helpers and waits, no flakes shall appear,
Query performance insights grow crystal clear. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding end-to-end tests for the Index Advisor feature.
Description check ✅ Passed The description includes confirmation of CONTRIBUTING.md review and explains the change type clearly, but omits the 'What is the current behavior?' and 'Additional context' sections from the template.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch e2e/add-index-advisor-tests

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
e2e/studio/features/index-advisor.spec.ts (1)

448-458: Test silently passes on failure, defeating its purpose.

Wrapping the assertion in try-catch means this test will always pass, even when no Index Advisor warnings are found. This hides actual failures and provides false confidence.

Consider one of these approaches:

  1. Let the assertion fail naturally if warnings are expected
  2. Use test.fail() or test.fixme() if the feature is known to be flaky
  3. Use a soft assertion with proper reporting if this is intentionally lenient
-      try {
-        await expect(
-          queryRows,
-          'At least one query with Index Advisor warning should be visible'
-        ).toBeVisible({ timeout: 10000 })
-        console.log('Successfully found queries with Index Advisor recommendations')
-      } catch (e) {
-        console.log(
-          'No queries with Index Advisor warnings found - may need more query executions or time'
-        )
-      }
+      // Use soft assertion if warnings may not always appear immediately
+      await expect
+        .soft(queryRows, 'At least one query with Index Advisor warning should be visible')
+        .toBeVisible({ timeout: 10000 })

Alternatively, if warnings are truly expected, remove the try-catch entirely:

-      try {
-        await expect(
-          queryRows,
-          'At least one query with Index Advisor warning should be visible'
-        ).toBeVisible({ timeout: 10000 })
-        console.log('Successfully found queries with Index Advisor recommendations')
-      } catch (e) {
-        console.log(
-          'No queries with Index Advisor warnings found - may need more query executions or time'
-        )
-      }
+      await expect(
+        queryRows,
+        'At least one query with Index Advisor warning should be visible'
+      ).toBeVisible({ timeout: 10000 })
🧹 Nitpick comments (1)
e2e/studio/features/index-advisor.spec.ts (1)

395-401: Consider adding assertion or documenting this as a setup step.

This test runs queries but has no assertions, making it effectively a setup step for the final test. Consider either:

  1. Adding a basic assertion (e.g., verify no SQL errors occurred)
  2. Moving this logic into the final test or a helper called by the final test

This is minor since the test serves as preparation for the warnings verification test.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 72a0c7c and 98c3e8c.

📒 Files selected for processing (1)
  • e2e/studio/features/index-advisor.spec.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
e2e/studio/features/index-advisor.spec.ts (3)
e2e/studio/utils/to-url.ts (1)
  • toUrl (3-5)
e2e/studio/utils/wait-for-response.ts (1)
  • waitForApiResponse (13-21)
e2e/studio/utils/test.ts (1)
  • test (17-21)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: format
  • GitHub Check: test
  • GitHub Check: typecheck
🔇 Additional comments (8)
e2e/studio/features/index-advisor.spec.ts (8)

1-29: LGTM!

Well-documented test file with clear explanations of the anti-flakiness measures. The imports are appropriate for the test requirements.


35-89: LGTM!

The helper function has good defensive error handling with the try-catch pattern for API waits and graceful handling of missing UI elements. The dual check (waitFor + count) provides resilience when the waitFor times out.


94-176: LGTM!

Good implementation with the API response waiter set up before triggering the click action. The 30-second timeout for extension initialization is appropriate. The duplicated code for enabling both extensions could be extracted into a shared helper, but it's acceptable for test clarity.


181-209: LGTM!

The function correctly waits for API response before continuing. The waitForTimeout fallback in the catch block (line 207) is acceptable as a last resort when the API times out, though a more deterministic approach (e.g., waiting for a success indicator in the UI) would be preferable if available.


214-241: LGTM!

Running the query multiple times to ensure visibility in Query Performance is a reasonable approach. The API wait pattern is consistent with other helpers.


243-263: LGTM!

Serial execution is the correct choice for these stateful tests that share a page instance. The refreshIndexAdvisorState helper appropriately synchronizes the local state with the actual extension status.


265-290: LGTM!

Proper cleanup with defensive error handling ensures test artifacts are removed without failing the suite if cleanup encounters issues.


292-370: LGTM!

Well-structured tests with appropriate conditional skipping based on the extension state. The verification of both extensions in the UI and the Warnings filter visibility are good functional checks.

Copy link
Contributor

@awaseem awaseem left a comment

Choose a reason for hiding this comment

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

LGTM

@awaseem awaseem merged commit aea06d6 into master Dec 11, 2025
20 checks passed
@awaseem awaseem deleted the e2e/add-index-advisor-tests branch December 11, 2025 15:45
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