Skip to content

Commit 8909113

Browse files
fix(admin): Preserve night shift form options
Clear only the organization ID after a successful trigger so dry-run, region, and max-candidates remain selected.
1 parent 3a19006 commit 8909113

2 files changed

Lines changed: 53 additions & 1 deletion

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
2+
import {selectEvent} from 'sentry-test/selectEvent';
3+
4+
import {ConfigStore} from 'sentry/stores/configStore';
5+
6+
import {SeerAdminPage} from 'admin/views/seerAdminPage';
7+
8+
describe('SeerAdminPage', () => {
9+
beforeEach(() => {
10+
ConfigStore.set('localities', [
11+
{
12+
name: 'US',
13+
url: 'https://us.example.com',
14+
},
15+
{
16+
name: 'EU',
17+
url: 'https://eu.example.com',
18+
},
19+
]);
20+
});
21+
22+
it('only clears the organization ID after triggering a night shift run', async () => {
23+
const request = MockApiClient.addMockResponse({
24+
url: '/internal/seer/night-shift/trigger/',
25+
method: 'POST',
26+
});
27+
28+
render(<SeerAdminPage />);
29+
30+
const organizationId = screen.getByRole('spinbutton', {
31+
name: 'Organization ID (blank = all orgs)',
32+
});
33+
const maxCandidates = screen.getByRole('spinbutton', {
34+
name: 'Max candidates (optional)',
35+
});
36+
const dryRun = screen.getByRole('checkbox', {
37+
name: 'Dry run (triage only, no autofix triggered)',
38+
});
39+
40+
await selectEvent.select(screen.getByRole('textbox', {name: 'Region'}), 'EU');
41+
await userEvent.type(organizationId, '123');
42+
await userEvent.type(maxCandidates, '5');
43+
await userEvent.click(dryRun);
44+
await userEvent.click(screen.getByRole('button', {name: 'Trigger Night Shift'}));
45+
46+
await waitFor(() => expect(request).toHaveBeenCalled());
47+
await waitFor(() => expect(organizationId).toHaveValue(null));
48+
expect(maxCandidates).toHaveValue(5);
49+
expect(dryRun).toBeChecked();
50+
expect(screen.getByText('EU')).toBeInTheDocument();
51+
});
52+
});

static/gsAdmin/views/seerAdminPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function SeerAdminPage() {
7474
onSubmit: ({value}) =>
7575
mutation
7676
.mutateAsync(formSchema.parse(value))
77-
.then(() => form.reset())
77+
.then(() => form.setFieldValue('organizationId', null))
7878
.catch(() => {}),
7979
});
8080

0 commit comments

Comments
 (0)