diff --git a/src/components/BackgroundImage/__tests__/BackgroundImage.test.tsx b/src/components/BackgroundImage/__tests__/BackgroundImage.test.tsx
index 4326a66d3..6f2aae286 100644
--- a/src/components/BackgroundImage/__tests__/BackgroundImage.test.tsx
+++ b/src/components/BackgroundImage/__tests__/BackgroundImage.test.tsx
@@ -3,7 +3,9 @@ import React from 'react';
import {render, screen} from '@testing-library/react';
import {testCustomClassName, testCustomStyle} from '../../../../test-utils/shared/common';
+import {testSourceProps} from '../../../../test-utils/shared/image';
import {BackgroundImageProps} from '../../../models';
+import {getQaAttrubutes} from '../../../utils';
import BackgroundImage from '../BackgroundImage';
const qa = 'background-image-component';
@@ -11,6 +13,8 @@ const qa = 'background-image-component';
const imageSrc =
'https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/img-gray.png';
+const qaAttributes = getQaAttrubutes(qa, 'image-desktop-source-compressed');
+
describe('BackgroundImage', () => {
test('Render BackgroundImage by default', async () => {
render();
@@ -21,17 +25,19 @@ describe('BackgroundImage', () => {
});
test('add image as src prop', () => {
- render();
- const component = screen.getByRole('img');
-
- expect(component).toHaveAttribute('src', imageSrc);
+ testSourceProps({
+ component: BackgroundImage,
+ props: {src: imageSrc, qa},
+ options: {qaId: qaAttributes.imageDesktopSourceCompressed},
+ });
});
test('add image as desktop prop', () => {
- render();
- const component = screen.getByRole('img');
-
- expect(component).toHaveAttribute('src', imageSrc);
+ testSourceProps({
+ component: BackgroundImage,
+ props: {desktop: imageSrc, qa},
+ options: {qaId: qaAttributes.imageDesktopSourceCompressed},
+ });
});
test('should hide image', () => {
diff --git a/src/components/BackgroundMedia/__tests__/BackgroundMedia.test.tsx b/src/components/BackgroundMedia/__tests__/BackgroundMedia.test.tsx
index 5fe0a0423..10fbe2f36 100644
--- a/src/components/BackgroundMedia/__tests__/BackgroundMedia.test.tsx
+++ b/src/components/BackgroundMedia/__tests__/BackgroundMedia.test.tsx
@@ -109,10 +109,10 @@ describe('BackgroundMedia', () => {
test('render image', () => {
const imageQaAttributes = getQaAttrubutes(
qaAttributes.mediaImageBackgroundImage,
- 'image-display-source',
+ 'image-desktop-source-compressed',
);
render();
- const component = screen.getByTestId(imageQaAttributes.imageDisplaySource);
+ const component = screen.getByTestId(imageQaAttributes.imageDesktopSourceCompressed);
expect(component).toBeInTheDocument();
});
diff --git a/src/components/Button/__tests__/Button.test.tsx b/src/components/Button/__tests__/Button.test.tsx
index a3064bece..a7afd6ec7 100644
--- a/src/components/Button/__tests__/Button.test.tsx
+++ b/src/components/Button/__tests__/Button.test.tsx
@@ -2,9 +2,8 @@ import React from 'react';
import {ButtonSize} from '@gravity-ui/uikit';
import {render, screen} from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
-import {testCustomClassName} from '../../../../test-utils/shared/common';
+import {testCustomClassName, testOnClick} from '../../../../test-utils/shared/common';
import {ButtonImagePosition, ButtonTheme} from '../../../models';
import Button, {ButtonProps} from '../Button';
import {ICON_QA} from '../utils';
@@ -63,14 +62,10 @@ describe('Button', () => {
});
test('call onClick', async () => {
- const user = userEvent.setup();
- const handleOnClick = jest.fn();
- render();
-
- const button = screen.getByRole('button');
-
- await user.click(button);
- expect(handleOnClick).toHaveBeenCalledTimes(1);
+ testOnClick({
+ component: Button,
+ props: {text: buttonProps.text, qa},
+ });
});
test.each(new Array('s', 'm', 'l', 'xl'))('render with given "%s" size', (size) => {
diff --git a/src/components/Image/Image.tsx b/src/components/Image/Image.tsx
index 1861be1e7..aa38dfcc7 100644
--- a/src/components/Image/Image.tsx
+++ b/src/components/Image/Image.tsx
@@ -16,10 +16,35 @@ export interface ImageProps extends Partial, Partial {
return src.endsWith('.webp') ? src : src + '.webp';
};
+const DeviceSpecificFragment = ({
+ disableWebp,
+ src,
+ breakpoint,
+ qa,
+}: DeviceSpecificFragmentProps) => (
+
+ {!disableWebp && (
+
+ )}
+
+
+);
+
const Image = (props: ImageProps) => {
const projectSettings = useContext(ProjectSettingsContext);
const {
@@ -49,7 +74,7 @@ const Image = (props: ImageProps) => {
'mobile-source',
'tablet-webp-source',
'tablet-source',
- 'display-source',
+ 'desktop-source-compressed',
);
const disableWebp =
@@ -61,44 +86,26 @@ const Image = (props: ImageProps) => {
return (