Repository navigation
test(studio): add MSW tests for project creation flow - #47790
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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds a Vitest and React Testing Library suite for the Studio project-creation wizard. It mocks dependencies and API requests, then tests creation flows, blocking states, configuration, validation, GitHub integration, feature flags, and API errors. ChangesProject creation wizard tests
Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 Results (next)Details
Flaky testsFeatures › database.spec.ts › Database › Schema Visualizer › table actions work as expected Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/studio/tests/pages/new/`[slug].test.tsx:
- Around line 335-356: The happy-path project creation test relies on an
unreliable smart-region auto-fill, so it should explicitly choose a region
before submitting. Update the test around renderWizard, fillProjectName, and
generateAndWaitForStrongPassword to call selectRegion(/Americas/) before
clicking “Create new project”, so the flow does not depend on the flaky
auto-fill behavior and remains stable if the default changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8173915e-8af0-4c95-ab6e-184b81d2a5aa
📒 Files selected for processing (1)
apps/studio/tests/pages/new/[slug].test.tsx
| test('creates a project on the happy path for a paid-plan organization', async () => { | ||
| mockWizardEndpoints() | ||
| const onRequest = vi.fn() | ||
| mockCreateProject(onRequest) | ||
|
|
||
| await renderWizard() | ||
|
|
||
| await fillProjectName('My New Project') | ||
| await generateAndWaitForStrongPassword() | ||
|
|
||
| fireEvent.click(screen.getByRole('button', { name: 'Create new project' })) | ||
|
|
||
| await waitFor(() => expect(onRequest).toHaveBeenCalled()) | ||
| expect(screen.queryByText('Confirm compute costs')).not.toBeInTheDocument() | ||
|
|
||
| const body = onRequest.mock.calls[0][0] | ||
| expect(body.name).toBe('My New Project') | ||
| expect(body.organization_slug).toBe(ORG_SLUG) | ||
| expect(body.desired_instance_size).toBe('micro') | ||
|
|
||
| await waitFor(() => expect(routerMock.asPath).toBe('/project/new-project-ref')) | ||
| }) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Consider calling selectRegion in the happy path test for robustness.
The comment at Line 309 explicitly states the smart-region auto-fill is "unreliable (FE-3884)." Six tests that expect successful project creation (happy path, free plan, Data API, default privileges, auto RLS, GitHub repo) omit selectRegion and rely on this auto-fill. If the auto-fill fails intermittently or FE-3884 is fixed to require explicit region selection, these tests will break. Adding await selectRegion(/Americas/) before submit in at least the happy path test would make it more resilient and forward-compatible.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/studio/tests/pages/new/`[slug].test.tsx around lines 335 - 356, The
happy-path project creation test relies on an unreliable smart-region auto-fill,
so it should explicitly choose a region before submitting. Update the test
around renderWizard, fillProjectName, and generateAndWaitForStrongPassword to
call selectRegion(/Americas/) before clicking “Create new project”, so the flow
does not depend on the flaky auto-fill behavior and remains stable if the
default changes.
Replace the expensive findByRole({ name }) accessibility-tree poll for the
GitHub repository button with a cheap findByText, and raise the async-util and
test timeouts so the dependent-query chain has headroom on CPU-starved CI
workers instead of racing the defaults.
Braintrust eval report
|
Adds 21 MSW component tests covering the project creation wizard's permutations (plan/region/compute/OrioleDB/security options/GitHub/blocking states/errors). Closes FE-3883; surfaced a real empty-region submit bug tracked in FE-3884.
Summary by CodeRabbit