Files
supabase/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.test.ts
T
9952d6f10f [FE-4067] fix(studio): re-allow all regions in local project creation (#48704)
Local dev stacks can run in any of the three supported regions (e.g.
Bobbie's is in `ap-southeast-1`), but enabling High Availability on the
project creation form pinned local to Frankfurt only. This unrestricts
local so all three regions are selectable again.

**Changed:**
- `getHighAvailabilityRegionCode()` returns `undefined` for `local`
(same as prod), so `filterHighAvailabilityRegions()` no longer collapses
the list — staging stays pinned to `us-east-1`
- The three-region warning in `RegionSelector` now adds a local-only
recommendation: "Use Central EU (Frankfurt) unless you're on a personal
dev stack."
- Updated unit tests, including an `ap-southeast-1` fixture region to
prove pass-through

## To test

- On a local stack, open the new project form and enable High
Availability — the region selector should offer all three regions (East
US, Frankfurt, Southeast Asia) instead of locking to Frankfurt, and the
warning should recommend Frankfurt unless you're on a personal dev stack
- Confirm staging behavior is unchanged (HA still pins to East US)
- `pnpm --filter studio exec vitest run
components/interfaces/ProjectCreation`

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Local development projects can now use high-availability regions
beyond Central EU.
* Region filtering and availability messaging now correctly reflect the
active environment, including staging restrictions.

* **User Experience**
* Added guidance recommending Central EU for local projects, unless
using a personal development stack.
* Region selection now provides clearer environment-specific information
when options are limited.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-08-05 14:51:57 +07:00

42 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
HIGH_AVAILABILITY_POSTGRES_ENGINE,
HIGH_AVAILABILITY_RELEASE_CHANNEL,
} from './ProjectCreation.constants'
import {
filterHighAvailabilityRegions,
getHighAvailabilityRegionCode,
} from './ProjectCreation.utils'
describe('High Availability project creation constraints', () => {
it('pins the Alpha Postgres engine and release channel', () => {
expect(HIGH_AVAILABILITY_POSTGRES_ENGINE).toBe('17')
expect(HIGH_AVAILABILITY_RELEASE_CHANNEL).toBe('ga')
})
it.each([
['local', 'eu-central-1'],
['staging', 'us-east-1'],
['prod', undefined],
])('resolves the %s region restriction', (environment, expectedRegion) => {
expect(getHighAvailabilityRegionCode(environment)).toBe(expectedRegion)
})
it.each([
['local', undefined],
['staging', 'us-east-1'],
['prod', undefined],
])(
'applies the %s region restriction to high availability projects',
(environment, expectedRegion) => {
const regions = [{ code: 'us-east-1' }, { code: 'eu-central-1' }, { code: 'ap-southeast-1' }]
expect(filterHighAvailabilityRegions(regions, true, environment)).toEqual(
expectedRegion === undefined ? regions : [{ code: expectedRegion }]
)
expect(filterHighAvailabilityRegions(regions, false, environment)).toEqual(regions)
}
)
})