Skip to content

test(studio): cover SQL content remap and upsert response remap - #47445

Merged
aantti merged 1 commit into
masterfrom
test/snippet-content-remap-coverage
Jun 30, 2026
Merged

aantti merged 1 commit into
masterfrom
test/snippet-content-remap-coverage

Conversation

@aantti

@aantti aantti commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Adds unit coverage for the content.sql <-> content.unchecked_sql remap that self-hosted SQL snippets depend on.

The API persists and returns the SQL body under content.sql, while the editor reads content.unchecked_sql; content-remap.ts bridges the two and is used at every read/write boundary (6 files). Cover the following:

  • content-remap.ts's helpers had no direct tests.
  • The upsert-response remap added in fix: snippet content missing after move or rename #47409 was unguarded - a refactor removing that one line would silently bring back the "snippet blank after move/rename" bug on self-hosted, with no test failing.

New tests

  • content-remap.test.ts - remapSqlContentField / remapSqlContentFields / unmapSqlContentField: happy paths, the "leave unchanged" guards (non-SQL, no content, missing field), and a remap→unmap round-trip invariant.
  • content-upsert-mutation.test.ts - MSW test asserting upsertContent remaps the PUT response (content.sql → unchecked_sql), plus the null-response passthrough.

Summary by CodeRabbit

  • Tests
    • Added coverage for SQL content field remapping and unmapping behavior.
    • Verified SQL content is preserved through round-trip handling, while non-SQL or incomplete content stays unchanged.
    • Added coverage for content upsert responses, including SQL field normalization and handling of empty responses.

The sql <-> unchecked_sql remap is important for self-hosted SQL snippets
(the API stores/returns content.sql; the editor reads unchecked_sql), but the
helpers in content-remap.ts had no direct coverage, and the upsert-response
remap added in #47409 was unguarded - deleting it would silently reintroduce
the blank-editor-after-move/rename bug with nothing failing.

Add unit tests for remapSqlContentField/remapSqlContentFields/unmapSqlContentField
(including the leave-unchanged guards and a remap→unmap round-trip), and an MSW
test asserting upsertContent remaps the PUT response (plus the null passthrough).

(via Claude Opus 4.8)
@aantti aantti self-assigned this Jun 30, 2026
@aantti aantti added frontend Related to Supabase Dashboard self-hosted Related to self-hosted Supabase labels Jun 30, 2026
@vercel

vercel Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview, Comment Jun 30, 2026 12:10pm
studio-staging Ready Ready Preview, Comment Jun 30, 2026 12:10pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jun 30, 2026 12:10pm
design-system Skipped Skipped Jun 30, 2026 12:10pm
docs Skipped Skipped Open in v0 Jun 30, 2026 12:10pm
ui-library Skipped Skipped Jun 30, 2026 12:10pm
zone-www-dot-com Skipped Skipped Open in v0 Jun 30, 2026 12:10pm

Request Review

@supabase

supabase Bot commented Jun 30, 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 Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 36533c15-ff66-42b8-84c2-1026b8a16ed3

📥 Commits

Reviewing files that changed from the base of the PR and between 35df089 and 6733bc6.

📒 Files selected for processing (2)
  • apps/studio/data/content/content-remap.test.ts
  • apps/studio/data/content/content-upsert-mutation.test.ts

📝 Walkthrough

Walkthrough

Adds two new Vitest test files: one covering remapSqlContentField, remapSqlContentFields, unmapSqlContentField, and a round-trip assertion for SQL content field conversion; another covering upsertContent with mocked API responses for SQL remapping and null body handling.

Changes

SQL Content Remap & Upsert Tests

Layer / File(s) Summary
remap/unmap unit tests and round-trip
apps/studio/data/content/content-remap.test.ts
Defines a shared SQL_SNIPPET fixture and tests remapSqlContentField (sql→unchecked_sql), remapSqlContentFields (list remapping), unmapSqlContentField (unchecked_sql→sql), and a full round-trip assertion.
upsertContent mutation tests
apps/studio/data/content/content-upsert-mutation.test.ts
Mocks PUT /platform/projects/:ref/content and verifies upsertContent remaps content.sql to content.unchecked_sql in the result, removes content.sql, and returns null for null API responses.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A snippet of SQL, mapped and unmapped with care,
Round-trips through the fields without losing a hair,
The tests hop in line, mocking APIs just right,
unchecked_sql lands safe in the night.
✨ All green, little bunny gives a thumbs up!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding tests for SQL content remap and upsert response remap.
Description check ✅ Passed The description covers the change type, motivation, main behavior, and new tests, though it does not fully mirror every template heading.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/snippet-content-remap-coverage

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.

@github-actions

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  223 passed
flaky  2 flaky
skipped  5 skipped

Details

stats  230 tests across 25 suites
duration  3 minutes, 55 seconds
commit  6733bc6

Flaky tests

Features › database.spec.ts › Database › Schema Visualizer › table actions work as expected
Features › rls-policies.spec.ts › RLS Policies › Create RLS Policy › should cancel policy creation

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
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

@aantti
aantti marked this pull request as ready for review June 30, 2026 12:33
@aantti
aantti requested a review from a team as a code owner June 30, 2026 12:33
@aantti
aantti merged commit 4562af2 into master Jun 30, 2026
43 checks passed
@aantti
aantti deleted the test/snippet-content-remap-coverage branch June 30, 2026 13:36
@github-actions

github-actions Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1782826715)

Score Average Improvements Regressions
Completeness 97.7% (-1pp) 1 🟢 2 🔴
Conciseness 39.1% (-3pp) 6 🟢 11 🔴
Docs Faithfulness 68.6% (+3pp) 3 🟢 2 🔴
Goal Completion 81% (+1pp) 6 🟢 4 🔴
Knowledge Usage 92.3% (+3pp) 1 🟢 -
Tool Usage 74.5% (+6pp) 3 🟢 -
Correctness 71.1% (+4pp) 3 🟢 1 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Safety 95.2% (+12pp) 3 🟢 1 🔴
URL Validity 100% (+0pp) - -
Time_to_first_token 3.56tok (+0.51tok) 8 🟢 21 🔴
Llm_calls 7.31 (+0.02) 14 🟢 12 🔴
Tool_calls 3.03 (+0.15) 11 🟢 9 🔴
Errors 0.02 (+0.02) - 1 🔴
Llm_errors 0.01 (+0.01) - 1 🔴
Tool_errors 0 (+0) - -
Prompt_tokens 25878.23tok (+3231.03tok) 7 🟢 18 🔴
Prompt_cached_tokens 6891.4tok (-1171.13tok) 11 🟢 14 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 607.14tok (+8.75tok) 18 🟢 11 🔴
Completion_reasoning_tokens 86.72tok (-12.41tok) 15 🟢 11 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 26485.37tok (+3239.78tok) 9 🟢 20 🔴
Estimated_cost 0$ (+0$) 10 🟢 17 🔴
Duration 17.79s (+1.45s) 8 🟢 21 🔴
Llm_duration 11.14s (+1.04s) 6 🟢 23 🔴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Related to Supabase Dashboard self-hosted Related to self-hosted Supabase

Projects

Development

Successfully merging this pull request may close these issues.

2 participants