Files
supabase/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.test.tsx
Danny White 0b27205ae4 fix(studio): clarify fast database reboot (#49741)
## What kind of change does this PR introduce?

Bug fix. Resolves DEPR-657.

## What is the current behavior?

The Fast database reboot description suggests the action may fail to
recover from some failure modes, which can be read as a risk of the
reboot itself.

## What is the new behavior?

The description clearly explains that the faster option restarts only
the database service, has less downtime than a full project restart, and
leaves other project services running.

| Before | After |
| --- | --- |
| <img width="1460" height="512" alt="CleanShot 2026-08-31 at 09 24
49@2x"
src="https://github.com/user-attachments/assets/2d4a940c-4d66-4753-99d8-9d0d2b4951af"
/> | <img width="1458" height="500" alt="CleanShot 2026-08-31 at 09 31
18@2x"
src="https://github.com/user-attachments/assets/f58aa351-5c8c-4a9a-b31d-b771659defd3"
/> |

## To test

1. Open a project's **Settings > General** page.
2. Under **Project availability**, tab to **Restart project**, then tab
again to the adjacent chevron button.
3. Press Enter and confirm focus moves to **Fast database reboot**.
4. Confirm its description reads: “Restarts only the database service,
with less downtime than a full project restart. Other project services
remain running.”
5. Confirm the project availability descriptions appear as secondary
text beneath their action labels.


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

* **Accessibility Improvements**
* Improved keyboard navigation with separate tab stops for restart
actions and restart-type selection.
* Added clearer labeling and focus behavior when choosing a restart
type.

* **UI Improvements**
* Clarified that fast database restarts affect only PostgreSQL while
other services continue running.
  * Improved text contrast on the project settings page.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-31 13:01:17 +10:00

72 lines
2.2 KiB
TypeScript

import { screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { RestartServerButton } from './RestartServerButton'
import { customRender } from '@/tests/lib/custom-render'
const {
mockUseAsyncCheckPermissions,
mockUseFlag,
mockUseIsFeatureEnabled,
mockUseSelectedProjectQuery,
} = vi.hoisted(() => ({
mockUseAsyncCheckPermissions: vi.fn(),
mockUseFlag: vi.fn(),
mockUseIsFeatureEnabled: vi.fn(),
mockUseSelectedProjectQuery: vi.fn(),
}))
vi.mock('common', async (importOriginal) => ({
...(await importOriginal<typeof import('common')>()),
useFlag: mockUseFlag,
}))
vi.mock('next/router', () => ({
useRouter: () => ({ push: vi.fn() }),
}))
vi.mock('@/hooks/misc/useCheckPermissions', () => ({
useAsyncCheckPermissions: mockUseAsyncCheckPermissions,
}))
vi.mock('@/hooks/misc/useIsFeatureEnabled', () => ({
useIsFeatureEnabled: mockUseIsFeatureEnabled,
}))
vi.mock('@/hooks/misc/useSelectedProject', () => ({
useIsAwsK8sCloudProvider: () => false,
useIsProjectActive: () => true,
useSelectedProjectQuery: mockUseSelectedProjectQuery,
}))
describe('RestartServerButton', () => {
beforeEach(() => {
vi.clearAllMocks()
mockUseFlag.mockReturnValue(false)
mockUseAsyncCheckPermissions.mockReturnValue({ can: true })
mockUseIsFeatureEnabled.mockReturnValue({ projectSettingsRestartProject: true })
mockUseSelectedProjectQuery.mockReturnValue({
data: { ref: 'default', region: 'us-east-1', status: 'ACTIVE_HEALTHY' },
})
})
it('uses separate tab stops for the primary action and restart type menu', async () => {
const user = userEvent.setup()
customRender(<RestartServerButton />)
const restartProject = screen.getByRole('button', { name: 'Restart project' })
const chooseRestartType = screen.getByRole('button', { name: 'Choose restart type' })
await user.tab()
expect(restartProject).toHaveFocus()
await user.tab()
expect(chooseRestartType).toHaveFocus()
await user.keyboard('{Enter}')
expect(await screen.findByRole('menuitem', { name: /Fast database reboot/ })).toHaveFocus()
expect(screen.getByText(/Other project services remain running/)).toBeVisible()
})
})