Skip to content

Commit

Permalink
СB-4551 fix: icons has no data-test id
Browse files Browse the repository at this point in the history
  • Loading branch information
s.teleshev committed Jan 22, 2024
1 parent 87497cf commit a5f0fc5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions webapp/packages/core-blocks/src/Icon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ import { Icon } from './Icon';
test('icons.svg#name', () => {
(globalThis as any)._ROOT_URI_ = undefined;

render(<Icon name="test" />);
render(<Icon data-testid="Icon" name="test" />);
expect(screen.getByTestId('Icon').querySelector('use')).toHaveAttribute('href', '/icons/icons.svg#test');
});

test('/image.jpg', () => {
(globalThis as any)._ROOT_URI_ = undefined;

render(<Icon name="/image.jpg" />);
render(<Icon data-testid="Icon" name="/image.jpg" />);
expect(screen.getByTestId('Icon').querySelector('use')).toHaveAttribute('href', '/image.jpg');
});

test('{_ROOT_URI_}/icons.svg#name', () => {
(globalThis as any)._ROOT_URI_ = '/path/';

render(<Icon name="test" />);
render(<Icon data-testid="Icon" name="test" />);
expect(screen.getByTestId('Icon').querySelector('use')).toHaveAttribute('href', '/path/icons/icons.svg#test');
});
2 changes: 1 addition & 1 deletion webapp/packages/core-blocks/src/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const Icon: React.FC<SVGAttributes<any>> = function Icon(props) {
const cn = `icon ${className || ''}`;
const url = GlobalConstants.absoluteUrl(name.startsWith('/') ? name : `/icons/icons.svg#${name}`);
return (
<svg {...rest} data-testid="Icon" className={cn} aria-hidden="true" focusable="false">
<svg {...rest} className={cn} aria-hidden="true" focusable="false">
<use href={url} />
</svg>
);
Expand Down

0 comments on commit a5f0fc5

Please sign in to comment.