test(sqllab): add SQL Lab SDK API contract tests#38860
test(sqllab): add SQL Lab SDK API contract tests#38860sadpandajoe wants to merge 3 commits intomasterfrom
Conversation
Add predicate Path B negative test (queryEditor lookup filtering) and strengthen assertions in onDidQueryStop and onDidChangeActiveTab for consistency with other context/tab-emitting tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sequence DiagramThis PR adds contract tests that validate the SQL Lab SDK against a real Redux store and listener middleware. The tests verify listener predicate scoping and disposal behavior, and confirm imperative SDK methods mutate and read SQL Lab state correctly. sequenceDiagram
participant Tests
participant SqlLabSDK
participant Store
participant Middleware
participant Extension
Tests->>SqlLabSDK: Register listener for active editor
SqlLabSDK->>Middleware: Attach predicate based listener
Tests->>Store: Dispatch query action for active editor
Middleware-->>Extension: Emit query context
Tests->>Store: Dispatch query action for different editor
Middleware-->>Extension: Skip callback for non matching editor
Tests->>SqlLabSDK: Call createTab and getTabs
SqlLabSDK-->>Tests: Return updated tabs from store state
Tests->>SqlLabSDK: Dispose listener and dispatch again
Middleware-->>Extension: No callback after dispose
Generated by CodeAnt AI |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Adds Jest contract tests to validate the SQL Lab SDK API surface (src/core/sqlLab/index.ts) that extensions depend on, focusing on listener middleware behavior and imperative accessors against a real configureStore + createListenerMiddleware setup.
Changes:
- Introduces 22 contract tests covering SQL Lab event listeners, predicate scoping, and disposal behavior.
- Adds coverage for imperative SQL Lab SDK functions (tab/panel switching, tab creation, and state getters).
- Uses a real reducer + listener middleware test harness with per-test cleanup to avoid state/listener leaks.
Addresses PR feedback: nanoid mock now returns unique values (mock-nanoid-1, mock-nanoid-2, ...) instead of a static string, preventing id/immutableId collisions in addQueryEditor calls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code Review Agent Run #b9a8ddActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
User description
SUMMARY
Add 22 Jest contract tests for the SQL Lab SDK API surface (
src/core/sqlLab/index.ts) that extensions depend on. This is a companion to #38776 (host-wiring tests) and covers the Redux listener middleware + module-level singleton surface.Test breakdown:
Architecture: Real
configureStore+ realcreateListenerMiddlewarewithsqlLabReducer— no over-mocking. Store reset +clearListeners()inafterEachensures no test-to-test state leaks (verified with--randomize).BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — test-only change.
TESTING INSTRUCTIONS
cd superset-frontend npx jest src/core/sqlLab/sqlLab.test.ts --maxWorkers=2 npx jest src/core/sqlLab/sqlLab.test.ts --maxWorkers=2 --randomizeADDITIONAL INFORMATION
CodeAnt-AI Description
Add contract coverage for the SQL Lab SDK behavior that extensions rely on
What Changed
Impact
✅ Safer SQL Lab extensions✅ Fewer regressions in tab and query events✅ Clearer confidence in SQL Lab listener behavior💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.