Files
K-Dog (Kevin) 1da25a7e72 chore(hipaa): self-serve PITR (#51342)
There is no reason why HIPAA customers cannot self-serve PITR add-on.
Instead of telling customers to reach out to support, let them
self-serve it.

- Docs also wrongfully stated the need for Small compute add-on.
- Ability to self-serve PITR
- Only 28-day PITR available
- Price is now also correct and displays $0 (pending backend change)

When enabled (marked as HIPAA compliant):
<img width="1128" height="216" alt="Screenshot 2026-10-06 at 1 53 01 PM"
src="https://github.com/user-attachments/assets/d83982e7-c71b-4236-ab29-67f85fc40f39"
/>

When not enabled (marked as HIPAA compliant):
<img width="1132" height="255" alt="Screenshot 2026-10-06 at 1 53 55 PM"
src="https://github.com/user-attachments/assets/f182813b-2163-4905-8cdf-9c69983ec1b9"
/>

<img width="772" height="542" alt="Screenshot 2026-10-06 at 1 56 08 PM"
src="https://github.com/user-attachments/assets/2cd59439-74b9-49d6-90d1-47c8d1722c9f"
/>
2026-10-06 15:11:55 +02:00

277 lines
7.6 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
getCustomDomainDisabledReason,
getIPv4DisabledReason,
getPitrAlertState,
getPitrDisabledReason,
} from './Addons.utils'
describe('getIPv4DisabledReason', () => {
it('returns the High Availability message before other checks', () => {
expect(
getIPv4DisabledReason({
isAws: false,
isProjectActive: false,
projectUpdateDisabled: true,
canUpdateIPv4: false,
ipv4Enabled: false,
isHighAvailability: true,
})
).toBe('Dedicated IPv4 address is unavailable on High Availability projects')
})
it('returns the AWS-only message for non-AWS projects', () => {
expect(
getIPv4DisabledReason({
isAws: false,
isProjectActive: true,
projectUpdateDisabled: false,
canUpdateIPv4: true,
ipv4Enabled: false,
isHighAvailability: false,
})
).toBe('Dedicated IPv4 address is only available for AWS projects')
})
it('returns the inactive-project message before other checks', () => {
expect(
getIPv4DisabledReason({
isAws: true,
isProjectActive: false,
projectUpdateDisabled: true,
canUpdateIPv4: false,
ipv4Enabled: false,
isHighAvailability: false,
})
).toBe('Project must be active to update IPv4')
})
it('returns the updates-disabled message when project updates are blocked', () => {
expect(
getIPv4DisabledReason({
isAws: true,
isProjectActive: true,
projectUpdateDisabled: true,
canUpdateIPv4: true,
ipv4Enabled: false,
isHighAvailability: false,
})
).toBe('Project updates are currently disabled')
})
it('returns the IPv6 requirement when IPv4 cannot be added yet', () => {
expect(
getIPv4DisabledReason({
isAws: true,
isProjectActive: true,
projectUpdateDisabled: false,
canUpdateIPv4: false,
ipv4Enabled: false,
isHighAvailability: false,
})
).toBe('You can only add IPv4 when your project network configuration is set to IPv6')
})
it('returns undefined when IPv4 is already enabled', () => {
expect(
getIPv4DisabledReason({
isAws: true,
isProjectActive: true,
projectUpdateDisabled: false,
canUpdateIPv4: false,
ipv4Enabled: true,
isHighAvailability: false,
})
).toBeUndefined()
})
})
describe('getPitrDisabledReason', () => {
it('returns the High Availability message before other checks', () => {
expect(
getPitrDisabledReason({
isProjectActive: false,
projectUpdateDisabled: true,
hasHipaaAddon: true,
sufficientPgVersion: false,
isOrioleDbInAws: true,
isHighAvailability: true,
})
).toBe('Point in time recovery is unavailable on High Availability projects')
})
it('returns the inactive-project message first', () => {
expect(
getPitrDisabledReason({
isProjectActive: false,
projectUpdateDisabled: true,
hasHipaaAddon: true,
sufficientPgVersion: false,
isOrioleDbInAws: true,
isHighAvailability: false,
})
).toBe('Project must be active to update PITR')
})
it('returns the updates-disabled message before feature-specific checks', () => {
expect(
getPitrDisabledReason({
isProjectActive: true,
projectUpdateDisabled: true,
hasHipaaAddon: true,
sufficientPgVersion: false,
isOrioleDbInAws: true,
isHighAvailability: false,
})
).toBe('Project updates are currently disabled')
})
it('returns the HIPAA message when HIPAA is enabled', () => {
expect(
getPitrDisabledReason({
isProjectActive: true,
projectUpdateDisabled: false,
hasHipaaAddon: true,
sufficientPgVersion: true,
isOrioleDbInAws: false,
isHighAvailability: false,
})
).toBe('PITR cannot be changed with HIPAA enabled')
})
it('returns the legacy-project message when the database version is too old', () => {
expect(
getPitrDisabledReason({
isProjectActive: true,
projectUpdateDisabled: false,
hasHipaaAddon: false,
sufficientPgVersion: false,
isOrioleDbInAws: false,
isHighAvailability: false,
})
).toBe('Your project is too old to enable PITR')
})
it('returns the OrioleDB message when PITR is unsupported', () => {
expect(
getPitrDisabledReason({
isProjectActive: true,
projectUpdateDisabled: false,
hasHipaaAddon: false,
sufficientPgVersion: true,
isOrioleDbInAws: true,
isHighAvailability: false,
})
).toBe('Point in time recovery is not supported with OrioleDB')
})
it('returns undefined when PITR can be updated', () => {
expect(
getPitrDisabledReason({
isProjectActive: true,
projectUpdateDisabled: false,
hasHipaaAddon: false,
sufficientPgVersion: true,
isOrioleDbInAws: false,
isHighAvailability: false,
})
).toBeUndefined()
})
})
describe('getCustomDomainDisabledReason', () => {
it('returns the High Availability message before other checks', () => {
expect(
getCustomDomainDisabledReason({
isProjectActive: false,
projectUpdateDisabled: true,
isHighAvailability: true,
})
).toBe('Custom domain is unavailable on High Availability projects')
})
it('returns the inactive-project message', () => {
expect(
getCustomDomainDisabledReason({
isProjectActive: false,
projectUpdateDisabled: true,
isHighAvailability: false,
})
).toBe('Project must be active to update custom domain')
})
it('returns the updates-disabled message when applicable', () => {
expect(
getCustomDomainDisabledReason({
isProjectActive: true,
projectUpdateDisabled: true,
isHighAvailability: false,
})
).toBe('Project updates are currently disabled')
})
it('returns undefined when the custom domain panel can be opened', () => {
expect(
getCustomDomainDisabledReason({
isProjectActive: true,
projectUpdateDisabled: false,
isHighAvailability: false,
})
).toBeUndefined()
})
})
describe('getPitrAlertState', () => {
it('prefers the HIPAA alert over other blocking reasons', () => {
expect(
getPitrAlertState({
hasHipaaAddon: true,
sufficientPgVersion: false,
isOrioleDbInAws: true,
})
).toBe('hipaa')
})
it('returns the non-compliant alert when HIPAA is enabled without 28-day PITR', () => {
expect(
getPitrAlertState({
hasHipaaAddon: true,
hasHipaaCompliantPitr: false,
sufficientPgVersion: true,
isOrioleDbInAws: false,
})
).toBe('hipaa-non-compliant')
})
it('returns the legacy-project alert when HIPAA is not enabled', () => {
expect(
getPitrAlertState({
hasHipaaAddon: false,
sufficientPgVersion: false,
isOrioleDbInAws: true,
})
).toBe('legacy-project')
})
it('returns the OrioleDB alert when it is the remaining blocker', () => {
expect(
getPitrAlertState({
hasHipaaAddon: false,
sufficientPgVersion: true,
isOrioleDbInAws: true,
})
).toBe('orioledb')
})
it('returns undefined when no PITR alert is needed', () => {
expect(
getPitrAlertState({
hasHipaaAddon: false,
sufficientPgVersion: true,
isOrioleDbInAws: false,
})
).toBeUndefined()
})
})