Skip to content

Commit 92f0479

Browse files
calvin-codecovandrewshie-sentry
authored andcommitted
1 parent d77ef6b commit 92f0479

File tree

2 files changed

+156
-12
lines changed

2 files changed

+156
-12
lines changed
Lines changed: 92 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,100 @@
1-
import {OrganizationFixture} from 'sentry-fixture/organization';
1+
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
22

3-
import {render, screen} from 'sentry-test/reactTestingLibrary';
3+
import TestsOnboardingPage from 'sentry/views/codecov/tests/onboarding';
44

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();
618

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+
});
824

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+
},
1333
});
1434

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');
1799
});
18100
});
Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,47 @@
1+
import {useCallback} from 'react';
2+
import {useSearchParams} from 'react-router-dom';
13
import styled from '@emotion/styled';
24

5+
import RadioGroup from 'sentry/components/forms/controls/radioGroup';
6+
import {t} from 'sentry/locale';
37
import {space} from 'sentry/styles/space';
4-
import TestPreOnboardingPage from 'sentry/views/codecov/tests/preOnboarding';
8+
9+
type SetupOption = 'githubAction' | 'cli';
510

611
export default function TestsOnboardingPage() {
12+
const [searchParams, setSearchParams] = useSearchParams();
13+
const opt = searchParams.get('opt');
14+
15+
const handleRadioChange = useCallback(
16+
(newOption: SetupOption) => {
17+
setSearchParams({opt: newOption});
18+
},
19+
[setSearchParams]
20+
);
21+
722
return (
823
<LayoutGap>
924
<p>Test Analytics Onboarding</p>
10-
<TestPreOnboardingPage />
25+
<OnboardingContainer>
26+
<IntroContainer>
27+
<GetStartedHeader>{t('Get Started with Test Analytics')}</GetStartedHeader>
28+
<TAValueText>
29+
{t(
30+
'Test Analytics offers data on test run times, failure rates, and identifies flaky tests to help decrease the risk of deployment failures and make it easier to ship new features quickly.'
31+
)}
32+
</TAValueText>
33+
</IntroContainer>
34+
<SelectOptionHeader>{t('Select a setup option')}</SelectOptionHeader>
35+
<RadioGroup
36+
label="Select a setup option"
37+
value={opt === 'cli' ? 'cli' : 'githubAction'}
38+
onChange={handleRadioChange}
39+
choices={[
40+
['githubAction', t('Use GitHub Actions to run my CI')],
41+
['cli', t("Use Sentry Prevent's CLI to upload testing reports")],
42+
]}
43+
/>
44+
</OnboardingContainer>
1145
</LayoutGap>
1246
);
1347
}
@@ -16,3 +50,31 @@ const LayoutGap = styled('div')`
1650
display: grid;
1751
gap: ${space(2)};
1852
`;
53+
54+
const OnboardingContainer = styled('div')`
55+
padding: ${space(1.5)} ${space(4)};
56+
border: 1px solid ${p => p.theme.border};
57+
border-radius: ${p => p.theme.borderRadius};
58+
`;
59+
60+
const IntroContainer = styled('div')`
61+
border-bottom: 1px solid ${p => p.theme.border};
62+
padding-bottom: ${space(3)};
63+
`;
64+
65+
const GetStartedHeader = styled('h2')`
66+
font-size: 1.625rem;
67+
color: ${p => p.theme.tokens.content.primary};
68+
line-height: 40px;
69+
`;
70+
71+
const TAValueText = styled('p')`
72+
font-size: ${p => p.theme.fontSizeLarge};
73+
color: ${p => p.theme.tokens.content.primary};
74+
`;
75+
76+
const SelectOptionHeader = styled('h5')`
77+
font-size: ${p => p.theme.fontSizeExtraLarge};
78+
color: ${p => p.theme.tokens.content.primary};
79+
margin-top: ${space(3)};
80+
`;

0 commit comments

Comments
 (0)