|
| 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 | +}); |
0 commit comments