Skip to content

Commit b1411a6

Browse files
test: coverage for CopyableCode component (#347)
1 parent 38bc4f5 commit b1411a6

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

frontend/src/components/HomeComponents/SetupGuide/__tests__/CopyableCode.test.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ describe('CopyableCode', () => {
2626
expect(screen.getByText(sampleText)).toBeInTheDocument();
2727
expect(screen.getByTestId('copy-icon')).toBeInTheDocument();
2828
});
29+
it('toggles sensitive value visibility and masks the text', () => {
30+
const sensitiveText = 'API_KEY 12345';
31+
32+
render(
33+
<CopyableCode
34+
text={sensitiveText}
35+
copyText={sensitiveText}
36+
isSensitive={true}
37+
/>
38+
);
39+
expect(screen.getByText(sensitiveText)).toBeInTheDocument();
40+
expect(screen.getByTestId('eye-off-icon')).toBeInTheDocument();
41+
fireEvent.click(
42+
screen.getByRole('button', { name: /hide sensitive value/i })
43+
);
44+
expect(screen.getByText('API_KEY •••••')).toBeInTheDocument();
45+
expect(screen.getByTestId('eye-icon')).toBeInTheDocument();
46+
});
2947

3048
it('copies text to clipboard and shows toast message', async () => {
3149
render(<CopyableCode text={sampleText} copyText={sampleCopyText} />);

0 commit comments

Comments
 (0)