Skip to content

Commit 9f60914

Browse files
jeremylenzclaude
andcommitted
Add test coverage for 'Analysis disabled' CVE column behavior
Adds two test cases to CVECountCell.test.js: - Renders "Analysis disabled" when opt_out is true - Renders CVE count link when valid count is returned Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent 42ac4aa commit 9f60914

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

webpack/InsightsVulnerabilityHostIndexExtensions/__tests__/CVECountCell.test.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,65 @@ describe('CVECountCell', () => {
127127
});
128128
expect(screen.getByText('—')).toBeInTheDocument();
129129
});
130+
131+
it('renders "Analysis disabled" when opt_out is true', () => {
132+
// Mock API to return opt_out: true
133+
API.get.mockImplementationOnce(async () => ({
134+
data: [
135+
{
136+
attributes: {
137+
opt_out: true,
138+
},
139+
},
140+
],
141+
}));
142+
143+
renderWithStore(<CVECountCell hostDetails={hostDetailsMock} />, {
144+
router: {
145+
location: {
146+
pathname: '/',
147+
search: '',
148+
hash: '',
149+
query: {},
150+
},
151+
},
152+
API: {
153+
ADVISOR_ENGINE_CONFIG: {
154+
response: { use_iop_mode: true },
155+
status: 'RESOLVED',
156+
},
157+
},
158+
});
159+
160+
expect(screen.getByText('Analysis disabled')).toBeInTheDocument();
161+
});
162+
163+
it('renders CVE count link when valid count is returned', () => {
164+
// Use the global mock which returns cve_count: 1
165+
renderWithStore(<CVECountCell hostDetails={hostDetailsMock} />, {
166+
router: {
167+
location: {
168+
pathname: '/',
169+
search: '',
170+
hash: '',
171+
query: {},
172+
},
173+
},
174+
API: {
175+
ADVISOR_ENGINE_CONFIG: {
176+
response: { use_iop_mode: true },
177+
status: 'RESOLVED',
178+
},
179+
},
180+
});
181+
182+
// Should render a link with the CVE count
183+
const link = screen.getByRole('link');
184+
expect(link).toBeInTheDocument();
185+
expect(link).toHaveTextContent('1');
186+
expect(link).toHaveAttribute(
187+
'href',
188+
`/hosts/${hostDetailsMock.name}#/Vulnerabilities`
189+
);
190+
});
130191
});

0 commit comments

Comments
 (0)