Skip to content

Commit e79b1fa

Browse files
[ft] Re-Add test gen copy (#3834)
1 parent 869a3bc commit e79b1fa

File tree

4 files changed

+53
-13
lines changed

4 files changed

+53
-13
lines changed
52.4 KB
Loading
52.2 KB
Loading

src/pages/CodecovAIPage/CodecovAICommands/CodecovAICommands.tsx

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import darkModeImage from 'assets/codecovAI/pr-review-example-dark-mode.png'
22
import lightModeImage from 'assets/codecovAI/pr-review-example-light-mode.png'
3+
import darkModeImageTests from 'assets/codecovAI/test-gen-example-dark-mode.png'
4+
import lightModeImageTests from 'assets/codecovAI/test-gen-example-light-mode.png'
35
import { Card } from 'ui/Card'
46
import { ExpandableSection } from 'ui/ExpandableSection'
57
import LightDarkImg from 'ui/LightDarkImg'
@@ -12,8 +14,14 @@ const CodecovAICommands: React.FC = () => {
1214
<Card.Title size="base">Codecov AI Commands</Card.Title>
1315
</Card.Header>
1416
<Card.Content>
15-
After installing the app, use this command in your PR comments:
17+
After installing the app, use these commands in your PR comments:
1618
<ul className="mt-2 list-inside list-disc space-y-1">
19+
<li>
20+
<span className="rounded border border-gray-200 bg-gray-100 px-1 font-semibold">
21+
@codecov-ai-reviewer test
22+
</span>
23+
-- the assistant will generate tests for the PR.
24+
</li>
1725
<li>
1826
<span className="rounded border border-gray-200 bg-gray-100 px-1 font-semibold">
1927
@codecov-ai-reviewer review
@@ -31,12 +39,32 @@ const CodecovAICommands: React.FC = () => {
3139
</p>
3240
</ExpandableSection.Trigger>
3341
<ExpandableSection.Content className="m-0 p-0">
34-
<LightDarkImg
35-
className="size-full object-cover"
36-
src={lightModeImage}
37-
darkSrc={darkModeImage}
38-
alt="codecov pr review example"
39-
/>
42+
<div className="h-[300px] w-full">
43+
<LightDarkImg
44+
className="size-full object-cover"
45+
src={lightModeImage}
46+
darkSrc={darkModeImage}
47+
alt="codecov pr review example"
48+
/>
49+
</div>
50+
</ExpandableSection.Content>
51+
</ExpandableSection>
52+
<ExpandableSection className="-mt-2 border-t-0">
53+
<ExpandableSection.Trigger>
54+
<p>
55+
Here is an example of Codecov AI Test Generation. Test generation
56+
may take time.
57+
</p>
58+
</ExpandableSection.Trigger>
59+
<ExpandableSection.Content className="m-0 p-0">
60+
<div className={`h-[300px] w-full`}>
61+
<LightDarkImg
62+
className="size-full object-cover"
63+
src={lightModeImageTests}
64+
darkSrc={darkModeImageTests}
65+
alt="codecov test generation example"
66+
/>
67+
</div>
4068
</ExpandableSection.Content>
4169
</ExpandableSection>
4270
</div>

src/pages/CodecovAIPage/CodecovAIPage.test.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ describe('CodecovAIPage', () => {
143143
/ the assistant will review the PR/
144144
)
145145
expect(commandOneText).toBeInTheDocument()
146+
147+
const commandTwoText = await screen.findByText(
148+
/ the assistant will generate tests/
149+
)
150+
expect(commandTwoText).toBeInTheDocument()
146151
})
147152

148153
it('renders examples', async () => {
@@ -154,20 +159,27 @@ describe('CodecovAIPage', () => {
154159
expect(reviewExample).toBeInTheDocument()
155160
})
156161

157-
it('renders screenshot', async () => {
162+
it('renders screenshots', async () => {
158163
render(<CodecovAIPage />, { wrapper })
159164
const user = userEvent.setup()
160-
const trigger = await screen.findByText((content) =>
165+
const trigger = await screen.findAllByText((content) =>
161166
content.startsWith('Here is an example')
162167
)
163-
expect(trigger).toBeInTheDocument()
168+
expect(trigger).toHaveLength(2)
164169

165-
await user.click(trigger)
170+
await user.click(trigger[0]!)
166171

167-
const screenshot = await screen.findByRole('img', {
172+
const screenshotReview = await screen.findByRole('img', {
168173
name: /codecov pr review example/,
169174
})
170-
expect(screenshot).toBeInTheDocument()
175+
expect(screenshotReview).toBeInTheDocument()
176+
177+
await user.click(trigger[1]!)
178+
179+
const screenshotTestGen = await screen.findByRole('img', {
180+
name: /codecov test generation example/,
181+
})
182+
expect(screenshotTestGen).toBeInTheDocument()
171183
})
172184

173185
it('renders a link to the docs', async () => {

0 commit comments

Comments
 (0)