Back to main fanout screen on save

This commit is contained in:
Jack Kingsman
2026-03-06 18:20:53 -08:00
parent f82cadb4e1
commit 94546f90a4
2 changed files with 39 additions and 2 deletions
+31
View File
@@ -54,6 +54,18 @@ function renderSection(overrides?: { health?: HealthStatus }) {
);
}
function renderSectionWithRefresh(
onHealthRefresh: () => Promise<void>,
overrides?: { health?: HealthStatus }
) {
return render(
<SettingsFanoutSection
health={overrides?.health ?? baseHealth}
onHealthRefresh={onHealthRefresh}
/>
);
}
beforeEach(() => {
vi.clearAllMocks();
mockedApi.getFanoutConfigs.mockResolvedValue([]);
@@ -117,6 +129,25 @@ describe('SettingsFanoutSection', () => {
});
});
it('save as enabled returns to list even if health refresh fails', async () => {
mockedApi.getFanoutConfigs.mockResolvedValue([webhookConfig]);
mockedApi.updateFanoutConfig.mockResolvedValue({ ...webhookConfig, enabled: true });
const failingRefresh = vi.fn(async () => {
throw new Error('refresh failed');
});
renderSectionWithRefresh(failingRefresh);
await waitFor(() => expect(screen.getByText('Test Hook')).toBeInTheDocument());
fireEvent.click(screen.getByRole('button', { name: 'Edit' }));
await waitFor(() => expect(screen.getByText('← Back to list')).toBeInTheDocument());
fireEvent.click(screen.getByRole('button', { name: 'Save as Enabled' }));
await waitFor(() => expect(screen.queryByText('← Back to list')).not.toBeInTheDocument());
expect(screen.getByText('Test Hook')).toBeInTheDocument();
});
it('calls toggle enabled on checkbox click', async () => {
mockedApi.getFanoutConfigs.mockResolvedValue([webhookConfig]);
mockedApi.updateFanoutConfig.mockResolvedValue({ ...webhookConfig, enabled: false });