mirror of
https://github.com/supabase/supabase.git
synced 2026-09-06 09:59:03 +08:00
`getHighAvailabilityRegionCode` had `staging` and `local` cases but no `prod` case, so it returned `undefined` in production and the High Availability region filtering never applied — the creation flow offered every AWS region while HA Alpha is only live in `us-east-1`. Adds the `prod` case returning `us-east-1`, matching staging. The region filter and the "High Availability projects are currently limited to…" banner both key off this value, so no other changes are needed. This keeps the accepted hardcoded-per-environment pattern for Alpha; the API/entitlement-driven enabled-regions design stays open on the ticket for when the rollout expands. **Changed:** - `ProjectCreation.utils.ts` — `prod` → `us-east-1` - `ProjectCreation.utils.test.ts` — the two env tables previously pinned prod as unrestricted; now expect `us-east-1` Addresses [FE-3716](https://linear.app/supabase/issue/FE-3716/show-enabled-regions) (and the folded-in MUL-1337). ## To test - `pnpm --filter studio exec vitest run components/interfaces/ProjectCreation/ProjectCreation.utils.test.ts` - In prod after deploy: new project → toggle High Availability → region select offers only East US (North Virginia) and shows the "limited to" notice; staging/local behavior unchanged (only the `prod` env branch changed) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - High-availability project creation now correctly uses the `us-east-1` region for production environments. - Region selection is now properly restricted to `us-east-1` when creating production projects. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
118 lines
4.0 KiB
TypeScript
118 lines
4.0 KiB
TypeScript
import { AWS_REGIONS } from 'shared-data'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
HIGH_AVAILABILITY_INSTANCE_SIZE,
|
|
HIGH_AVAILABILITY_POSTGRES_ENGINE,
|
|
HIGH_AVAILABILITY_RELEASE_CHANNEL,
|
|
} from './ProjectCreation.constants'
|
|
import {
|
|
filterHighAvailabilityRegions,
|
|
getAvailableRegions,
|
|
getHighAvailabilityRegionCode,
|
|
resolveDefaultDbRegion,
|
|
} from './ProjectCreation.utils'
|
|
|
|
describe('resolveDefaultDbRegion', () => {
|
|
const base = {
|
|
cloudProvider: 'AWS_NIMBUS',
|
|
isHighAvailabilityRestricted: false,
|
|
highAvailabilityRegionName: undefined,
|
|
isSmartRegionEnabled: false,
|
|
recommendedSmartRegion: undefined,
|
|
autoDefaultRegion: undefined,
|
|
fixedDefaultRegion: AWS_REGIONS.EAST_US.displayName,
|
|
environment: 'prod',
|
|
} as const
|
|
|
|
it('prefers the high availability region when restricted, even while it is still loading', () => {
|
|
expect(
|
|
resolveDefaultDbRegion({
|
|
...base,
|
|
isHighAvailabilityRestricted: true,
|
|
highAvailabilityRegionName: AWS_REGIONS.EAST_US.displayName,
|
|
})
|
|
).toBe(AWS_REGIONS.EAST_US.displayName)
|
|
expect(resolveDefaultDbRegion({ ...base, isHighAvailabilityRestricted: true })).toBeUndefined()
|
|
})
|
|
|
|
it('uses the recommended smart region when smart regions are enabled', () => {
|
|
expect(
|
|
resolveDefaultDbRegion({
|
|
...base,
|
|
cloudProvider: 'AWS',
|
|
isSmartRegionEnabled: true,
|
|
recommendedSmartRegion: 'Americas',
|
|
autoDefaultRegion: AWS_REGIONS.SOUTHEAST_ASIA.displayName,
|
|
})
|
|
).toBe('Americas')
|
|
})
|
|
|
|
it('uses the geolocated region when the provider offers it', () => {
|
|
expect(
|
|
resolveDefaultDbRegion({
|
|
...base,
|
|
cloudProvider: 'AWS',
|
|
autoDefaultRegion: AWS_REGIONS.SOUTHEAST_ASIA.displayName,
|
|
})
|
|
).toBe(AWS_REGIONS.SOUTHEAST_ASIA.displayName)
|
|
})
|
|
|
|
it('falls back to the fixed default when the provider does not offer the geolocated region', () => {
|
|
expect(
|
|
resolveDefaultDbRegion({ ...base, autoDefaultRegion: AWS_REGIONS.SOUTHEAST_ASIA.displayName })
|
|
).toBe(AWS_REGIONS.EAST_US.displayName)
|
|
})
|
|
|
|
it('falls back to the fixed default when no geolocated region resolved', () => {
|
|
expect(resolveDefaultDbRegion(base)).toBe(AWS_REGIONS.EAST_US.displayName)
|
|
})
|
|
})
|
|
|
|
describe('getAvailableRegions', () => {
|
|
it.each(['local', 'staging', 'prod'])('returns all AWS regions for AWS on %s', (environment) => {
|
|
expect(getAvailableRegions('AWS', environment)).toEqual(AWS_REGIONS)
|
|
expect(getAvailableRegions('AWS_K8S', environment)).toEqual(AWS_REGIONS)
|
|
})
|
|
|
|
it.each([
|
|
['local', { SOUTHEAST_ASIA: AWS_REGIONS.SOUTHEAST_ASIA }],
|
|
['staging', { SOUTHEAST_ASIA: AWS_REGIONS.SOUTHEAST_ASIA }],
|
|
['prod', { EAST_US: AWS_REGIONS.EAST_US }],
|
|
])('returns the single AWS_NIMBUS region on %s', (environment, expectedRegions) => {
|
|
expect(getAvailableRegions('AWS_NIMBUS', environment)).toEqual(expectedRegions)
|
|
})
|
|
})
|
|
|
|
describe('High Availability project creation constraints', () => {
|
|
it('pins the Alpha Postgres engine, release channel, and compute size', () => {
|
|
expect(HIGH_AVAILABILITY_POSTGRES_ENGINE).toBe('17')
|
|
expect(HIGH_AVAILABILITY_RELEASE_CHANNEL).toBe('ga')
|
|
expect(HIGH_AVAILABILITY_INSTANCE_SIZE).toBe('large')
|
|
})
|
|
|
|
it.each([
|
|
['local', 'eu-central-1'],
|
|
['staging', 'us-east-1'],
|
|
['prod', 'us-east-1'],
|
|
])('resolves the %s region restriction', (environment, expectedRegion) => {
|
|
expect(getHighAvailabilityRegionCode(environment)).toBe(expectedRegion)
|
|
})
|
|
|
|
it.each([
|
|
['local', undefined],
|
|
['staging', 'us-east-1'],
|
|
['prod', 'us-east-1'],
|
|
])(
|
|
'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)
|
|
}
|
|
)
|
|
})
|