Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate to react 18 #582

Merged
merged 5 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
module.exports = {
extension: ["js", "jsx", "ts", "tsx"],
recursive: true,
require: ["./test/ts-node", "./test/setup", "./test/assert-ext", "jsdom-global/register"],
require: [
"./test/setup/ts-node",
"./test/setup/globals",
"./test/setup/assert-ext",
"./test/setup/configure-testing-library"
],
};
2 changes: 1 addition & 1 deletion lib/adapters/test-result/testplane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const getStatus = (eventName: ValueOf<Testplane['events']>, events: Testp
} else if (eventName === events.TEST_PENDING) {
return TestStatus.SKIPPED;
} else if (eventName === events.RETRY || eventName === events.TEST_FAIL) {
return hasUnrelatedToScreenshotsErrors(testResult.err!) ? TestStatus.ERROR : TestStatus.FAIL;
return hasUnrelatedToScreenshotsErrors(testResult.err as Error) ? TestStatus.ERROR : TestStatus.FAIL;
} else if (eventName === events.TEST_BEGIN) {
return TestStatus.RUNNING;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/static/components/bottom-progress-bar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const BottomProgressBar = (props) => {

BottomProgressBar.propTypes = {
progressBar: PropTypes.object.isRequired,
visibleRootSuiteIds: PropTypes.arrayOf(PropTypes.number)
visibleRootSuiteIds: PropTypes.arrayOf(PropTypes.string)
};

export default connect(
Expand Down
2 changes: 1 addition & 1 deletion lib/static/components/bullet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Bullet = ({status, onClick, className}) => {
});

if (!isCheckbox) {
return <div className='bullet-container'><ChevronUp className={classNames(className, 'bullet_type-simple')}/></div>;
return <div className='bullet-container'><ChevronUp className={classNames(className, 'bullet_type-simple')} data-qa={'bullet-icon'}/></div>;
}

return <div onClick={handleClick} className='bullet-container'>
Expand Down
3 changes: 1 addition & 2 deletions lib/static/components/controls/common-controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class ControlButtons extends Component {
view: PropTypes.shape({
expand: PropTypes.string.isRequired,
viewMode: PropTypes.string.isRequired,
diffMode: PropTypes.string.isRequired,
changeViewMode: PropTypes.func.isRequired
diffMode: PropTypes.string.isRequired
}),
isStatisImageAccepterEnabled: PropTypes.bool,
actions: PropTypes.object.isRequired
Expand Down
2 changes: 1 addition & 1 deletion lib/static/components/controls/control-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from 'classnames';
import {Button} from '@gravity-ui/uikit';

interface ControlButtonProps {
label: string | Component;
label: React.ReactNode;
title?: string;
handler: () => void;
isActive?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion lib/static/components/controls/menu-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MenuBar extends Component {
}

return (
<div className="menu-bar" data-test-id='menu-bar'>
<div className="menu-bar" data-qa='menu-bar'>
shadowusr marked this conversation as resolved.
Show resolved Hide resolved
<DropdownMenu size='m' renderSwitcher={({className, ...props}) => (
<Button className={classNames('menu-bar__dropdown', className)}{...props} view="flat">
<Icon size={16} data={Bars} />
Expand Down
4 changes: 2 additions & 2 deletions lib/static/components/details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export default class Details extends Component {
size='l'>
<Disclosure.Summary>
{(props, defaultButton) => (
<div className={classNames(className, 'details__summary')} {...props}>
<div className='details__expand-button' onClick={this.stopPropagation}>
<div className={classNames(className, 'details__summary')} aria-controls={props.ariaControls} onClick={props.onClick} id={props.id}>
<div className="details__expand-button" onClick={this.stopPropagation}>
{defaultButton}
</div>
{title}
Expand Down
2 changes: 1 addition & 1 deletion lib/static/components/extension-point.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as plugins from '../modules/plugins';
export default class ExtensionPoint extends Component {
static propTypes = {
name: PropTypes.string.isRequired,
children: PropTypes.oneOfType([PropTypes.element, PropTypes.string])
children: PropTypes.oneOfType([PropTypes.element, PropTypes.string, PropTypes.array])
};

render() {
Expand Down
19 changes: 8 additions & 11 deletions lib/static/components/header/summary/dbBtn.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import {Ref} from 'semantic-ui-react';
import {Button} from '@gravity-ui/uikit';
import {ChevronDown} from '@gravity-ui/icons';

Expand All @@ -11,16 +10,14 @@ const ForwardedDbBtn = React.forwardRef(function DbBtn({fetchDbDetails}, ref) {
const content = `Databases loaded: ${value}`;

return (
<Ref innerRef={ref}>
<Button
view={isFailed ? 'flat-danger' : 'flat'}
>
<div className='db-info'>
<ChevronDown/>
{content}
</div>
</Button>
</Ref>
<Button
shadowusr marked this conversation as resolved.
Show resolved Hide resolved
view={isFailed ? 'flat-danger' : 'flat'} ref={ref}
>
<div className='db-info'>
<ChevronDown/>
{content}
</div>
</Button>
);
});

Expand Down
2 changes: 1 addition & 1 deletion lib/static/components/icons/view-in-browser/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ViewInBrowser extends Component {
onClick={this.onViewInBrowser}
title="view in browser"
target="_blank"
data-test-id='view-in-browser' rel="noreferrer"
data-qa='view-in-browser' rel="noreferrer"
><Eye color='black'/></a>
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/static/components/modals/screenshot-accepter/body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ScreenshotAccepterBody extends Component {

return (
<div className="screenshot-accepter__title">
<span className="screenshot-accepter__test-name" data-test-id="screenshot-accepter-test-name">{testName}</span>
<span className="screenshot-accepter__test-name" data-qa="screenshot-accepter-test-name">{testName}</span>
<span className="screenshot-accepter__title-divider">{'/'}</span>
<span className="screenshot-accepter__browser-name">{browserName}</span>
<span className="screenshot-accepter__title-divider">{'/'}</span>
Expand Down
18 changes: 9 additions & 9 deletions lib/static/components/modals/screenshot-accepter/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ScreenshotAccepter extends Component {
this.totalImagesCount = size(imagesByStateName);

for (let i = 1; i <= PRELOAD_IMAGE_COUNT; i++) {
this._preloadAdjacentImages(i);
this._preloadAdjacentImages(activeImageIndex, stateNameImageIds, i);
}
}

Expand All @@ -72,7 +72,7 @@ class ScreenshotAccepter extends Component {
const images = this._getActiveImages(activeImageIndex);

this.setState({retryIndex: images.length - 1, activeImageIndex});
this._preloadAdjacentImages();
this._preloadAdjacentImages(activeImageIndex, this.state.stateNameImageIds);
};

onScreenshotAccept = async (imageId) => {
Expand Down Expand Up @@ -117,7 +117,7 @@ class ScreenshotAccepter extends Component {
stateNameImageIds: stateNameIds,
retryIndex: newImages.length - 1
});
this._preloadAdjacentImages();
this._preloadAdjacentImages(activeImageIndex, stateNameIds);
};

onScreenshotUndo = async () => {
Expand Down Expand Up @@ -147,7 +147,7 @@ class ScreenshotAccepter extends Component {
stateNameImageIds: previousStateNameImageId,
retryIndex: images.length - 1
});
this._preloadAdjacentImages();
this._preloadAdjacentImages(ind, previousStateNameImageId);
};

onShowMeta = () => {
Expand Down Expand Up @@ -208,13 +208,13 @@ class ScreenshotAccepter extends Component {
return imageId;
}

_preloadAdjacentImages(offset = PRELOAD_IMAGE_COUNT) {
const screensCount = size(this.state.stateNameImageIds);
const previosImagesIndex = (screensCount + this.state.activeImageIndex - offset) % screensCount;
const nextImagesIndex = (this.state.activeImageIndex + offset) % screensCount;
_preloadAdjacentImages(activeImageIndex, stateNameImageIds, offset = PRELOAD_IMAGE_COUNT) {
shadowusr marked this conversation as resolved.
Show resolved Hide resolved
const screensCount = size(stateNameImageIds);
const previosImagesIndex = (screensCount + activeImageIndex - offset) % screensCount;
const nextImagesIndex = (activeImageIndex + offset) % screensCount;

[previosImagesIndex, nextImagesIndex].filter(ind => ind >= 0).forEach(preloadingImagesIndex => {
const stateNameImageId = this.state.stateNameImageIds[preloadingImagesIndex];
const stateNameImageId = stateNameImageIds[preloadingImagesIndex];
const {expectedImg, actualImg, diffImg} = last(this.props.imagesByStateName[stateNameImageId]);

[expectedImg, actualImg, diffImg].filter(Boolean).forEach(({path}) => preloadImage(path));
Expand Down
2 changes: 1 addition & 1 deletion lib/static/components/progress-bar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ProgressBar = ({done, total, dataTestId}) => {
const percent = (done / total).toFixed(2) * 100;

return (
<span className="progress-bar" data-content={`${done}/${total}`} data-test-id={dataTestId}>
<span className="progress-bar" data-content={`${done}/${total}`} data-qa={dataTestId}>
<span className="progress-bar__container" style={{width: `${percent}%`}}/>
</span>
);
Expand Down
2 changes: 1 addition & 1 deletion lib/static/components/retry-switcher/item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class RetrySwitcherItem extends Component {
{'tab-switcher__button_non-matched': keyToGroupTestsBy && !matchedSelectedGroup}
);

return <Button {...statusToView[status]} title={title} className={className} onClick={onClick} qa='retry-switcher'>{attempt + 1}</Button>;
return <Button {...statusToView[status]} title={title} className={className} onClick={onClick} qa={'retry-switcher'}>{attempt + 1}</Button>;
}
}

Expand Down
2 changes: 0 additions & 2 deletions lib/static/components/section/body/description.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

import React, {Component} from 'react';
import Markdown from 'react-markdown';
import PropTypes from 'prop-types';
Expand Down
2 changes: 1 addition & 1 deletion lib/static/components/state/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class State extends Component {
isDisabled={isScreenshotAccepterDisabled}
extendClassNames="screenshot-accepter__arrows-open-btn"
handler={() => this.toggleModal()}
data-test-id="test-switch-accept-mode"
data-qa="test-switch-accept-mode"
/>
</div>
);
Expand Down
9 changes: 1 addition & 8 deletions lib/static/components/state/screenshot/diff-circle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {keyframes} from 'styled-components';
import {CIRCLE_RADIUS} from '../../../../constants/defaults';

export default class DiffCircle extends Component {
Expand Down Expand Up @@ -48,16 +47,10 @@ export default class DiffCircle extends Component {
};
const radius = diffRect.minSize + CIRCLE_RADIUS;

const animation = keyframes`
100% {
transform: scale(${radius / diffRect.minSize})
}
`;

return (
<div
className='diff-circle'
style={{animation: `${animation} 1s ease-out`, ...diffCircle}}
style={{'--diff-bubbles-scale': `${radius / diffRect.minSize}`, animation: `diff-bubbles 1s ease-out`, ...diffCircle}}
onAnimationEnd={() => toggleDiff()}
>
</div>
Expand Down
Loading
Loading