|
1 |
| -import {OrganizationFixture} from 'sentry-fixture/organization'; |
| 1 | +import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary'; |
2 | 2 |
|
3 |
| -import {render, screen} from 'sentry-test/reactTestingLibrary'; |
| 3 | +import TestsOnboardingPage from 'sentry/views/codecov/tests/onboarding'; |
4 | 4 |
|
5 |
| -import TestAnalyticsOnboardingPage from 'sentry/views/codecov/tests/onboarding'; |
| 5 | +describe('TestsOnboardingPage', () => { |
| 6 | + it('renders with GitHub Actions selected by default if no query param is provided', () => { |
| 7 | + render(<TestsOnboardingPage />, { |
| 8 | + initialRouterConfig: { |
| 9 | + location: { |
| 10 | + pathname: '/codecov/tests/new', |
| 11 | + query: {}, |
| 12 | + }, |
| 13 | + }, |
| 14 | + }); |
| 15 | + |
| 16 | + const githubRadio = screen.getByLabelText('Use GitHub Actions to run my CI'); |
| 17 | + expect(githubRadio).toBeChecked(); |
6 | 18 |
|
7 |
| -const COVERAGE_FEATURE = 'codecov-ui'; |
| 19 | + const cliRadio = screen.getByLabelText( |
| 20 | + "Use Sentry Prevent's CLI to upload testing reports" |
| 21 | + ); |
| 22 | + expect(cliRadio).not.toBeChecked(); |
| 23 | + }); |
8 | 24 |
|
9 |
| -describe('TestAnalyticsOnboardingPage', () => { |
10 |
| - it('renders the placeholder content', () => { |
11 |
| - render(<TestAnalyticsOnboardingPage />, { |
12 |
| - organization: OrganizationFixture({features: [COVERAGE_FEATURE]}), |
| 25 | + it('renders with GitHub Actions selected by default if empty opt query param is provided', () => { |
| 26 | + render(<TestsOnboardingPage />, { |
| 27 | + initialRouterConfig: { |
| 28 | + location: { |
| 29 | + pathname: '/codecov/tests/new', |
| 30 | + query: {opt: ''}, |
| 31 | + }, |
| 32 | + }, |
13 | 33 | });
|
14 | 34 |
|
15 |
| - const testContent = screen.getByText('Test Analytics Onboarding'); |
16 |
| - expect(testContent).toBeInTheDocument(); |
| 35 | + const githubRadio = screen.getByLabelText('Use GitHub Actions to run my CI'); |
| 36 | + expect(githubRadio).toBeChecked(); |
| 37 | + |
| 38 | + const cliRadio = screen.getByLabelText( |
| 39 | + "Use Sentry Prevent's CLI to upload testing reports" |
| 40 | + ); |
| 41 | + expect(cliRadio).not.toBeChecked(); |
| 42 | + }); |
| 43 | + |
| 44 | + it('renders with CLI selected when opt=cli in URL', () => { |
| 45 | + render(<TestsOnboardingPage />, { |
| 46 | + initialRouterConfig: { |
| 47 | + location: { |
| 48 | + pathname: '/codecov/tests/new', |
| 49 | + query: {opt: 'cli'}, |
| 50 | + }, |
| 51 | + }, |
| 52 | + }); |
| 53 | + |
| 54 | + const cliRadio = screen.getByLabelText( |
| 55 | + "Use Sentry Prevent's CLI to upload testing reports" |
| 56 | + ); |
| 57 | + expect(cliRadio).toBeChecked(); |
| 58 | + |
| 59 | + const githubRadio = screen.getByLabelText('Use GitHub Actions to run my CI'); |
| 60 | + expect(githubRadio).not.toBeChecked(); |
| 61 | + }); |
| 62 | + |
| 63 | + it('updates URL when GitHub Actions option is selected', async () => { |
| 64 | + const {router} = render(<TestsOnboardingPage />, { |
| 65 | + initialRouterConfig: { |
| 66 | + location: { |
| 67 | + pathname: '/codecov/tests/new', |
| 68 | + query: {opt: 'cli'}, |
| 69 | + }, |
| 70 | + }, |
| 71 | + }); |
| 72 | + |
| 73 | + const githubRadio = screen.getByLabelText('Use GitHub Actions to run my CI'); |
| 74 | + expect(githubRadio).not.toBeChecked(); |
| 75 | + |
| 76 | + await userEvent.click(githubRadio); |
| 77 | + |
| 78 | + expect(router.location.search).toBe('?opt=githubAction'); |
| 79 | + }); |
| 80 | + |
| 81 | + it('updates URL when CLI option is selected', async () => { |
| 82 | + const {router} = render(<TestsOnboardingPage />, { |
| 83 | + initialRouterConfig: { |
| 84 | + location: { |
| 85 | + pathname: '/codecov/tests/new', |
| 86 | + query: {opt: ''}, |
| 87 | + }, |
| 88 | + }, |
| 89 | + }); |
| 90 | + |
| 91 | + const cliRadio = screen.getByLabelText( |
| 92 | + "Use Sentry Prevent's CLI to upload testing reports" |
| 93 | + ); |
| 94 | + expect(cliRadio).not.toBeChecked(); |
| 95 | + |
| 96 | + await userEvent.click(cliRadio); |
| 97 | + |
| 98 | + expect(router.location.search).toBe('?opt=cli'); |
17 | 99 | });
|
18 | 100 | });
|
0 commit comments