Skip to content

Commit

Permalink
chore(new-ui): fix image attempt picking logic and image status color
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Oct 8, 2024
1 parent 51abe4d commit 3a5931e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 21 deletions.
5 changes: 0 additions & 5 deletions lib/static/new-ui/components/SuiteTitle/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
gap: 8px;
}

.label:global(.g-label_theme_danger) {
--_--text-color: var(--color-pink-600);
--_--bg-color: var(--color-pink-100);
}

.label :global(.g-label__content) {
display: flex;
align-items: center;
Expand Down
11 changes: 1 addition & 10 deletions lib/static/new-ui/components/SuiteTitle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, {ReactNode} from 'react';
import {Button, Icon, Label} from '@gravity-ui/uikit';
import {Camera, ChevronRight, PlanetEarth, ChevronUp, ChevronDown} from '@gravity-ui/icons';

import {TestStatus} from '@/constants';
import styles from './index.module.css';

interface SuiteTitleProps {
Expand All @@ -14,7 +13,6 @@ interface SuiteTitlePropsInternal extends SuiteTitleProps {
suitePath: string[];
browserName: string;
stateName?: string;
imageStatus?: TestStatus;
index: number;
totalItems: number;
onPrevious: () => void;
Expand All @@ -25,13 +23,6 @@ export function SuiteTitle(props: SuiteTitlePropsInternal): ReactNode {
const suiteName = props.suitePath[props.suitePath.length - 1];
const suitePath = props.suitePath.slice(0, -1);

let stateNameLabelTheme: 'normal' | 'danger' | 'success' = 'normal';
if (props.imageStatus === TestStatus.FAIL || props.imageStatus === TestStatus.ERROR) {
stateNameLabelTheme = 'danger';
} else if (props.imageStatus === TestStatus.SUCCESS) {
stateNameLabelTheme = 'success';
}

return <div className={classNames(styles.container, props.className)}>
<div className={styles.content}>
<div className={classNames(styles.breadcrumbs)}>
Expand All @@ -53,7 +44,7 @@ export function SuiteTitle(props: SuiteTitlePropsInternal): ReactNode {
<div className={styles.labelsContainer}>
<Label theme={'normal'} size={'xs'} className={styles.label}><PlanetEarth/>{props.browserName}
</Label>
{props.stateName && <Label theme={stateNameLabelTheme} size={'xs'} className={classNames(styles.label)}><Camera/>{props.stateName}</Label>}
{props.stateName && <Label theme='utility' size={'xs'} className={classNames(styles.label)}><Camera/>{props.stateName}</Label>}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ export function VisualChecksPageInternal({currentNamedImage, currentImage, visib
totalItems={visibleNamedImageIds.length}
onPrevious={onPreviousImageHandler}
stateName={currentNamedImage.stateName}
onNext={onNextImageHandler}
imageStatus={currentNamedImage.status}/>}
onNext={onNextImageHandler}/>}
</div>
{currentImage && <AssertViewResult result={currentImage}/>}
</UiCard>
Expand Down
10 changes: 9 additions & 1 deletion lib/static/new-ui/features/visual-checks/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ export const getCurrentImage = (state: State): ImageEntity | null => {
}

const retryIndex = state.tree.browsers.stateById[currentNamedImage.browserId].retryIndex;
const currentImageId = currentNamedImage.imageIds[retryIndex];
const currentImageId = currentNamedImage.imageIds.find(imageId => {
const resultId = state.tree.images.byId[imageId].parentId;

return state.tree.results.byId[resultId].attempt === retryIndex;
});

if (!currentImageId) {
return null;
}

return getImages(state)[currentImageId];
};
Expand Down
4 changes: 2 additions & 2 deletions test/unit/lib/static/components/controls/menu-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('<MenuBar />', () => {
initialState: {apiValues: {extraItems: {some: 'link'}}}
});

await user.click(component.getByRole('button'));
await user.click(component.getByTestId('menu-bar').querySelector('button'));

expect(component.getByText('some')).to.exist;
expect(component.getByText('some').href).to.equal('http://localhost/link');
Expand All @@ -22,6 +22,6 @@ describe('<MenuBar />', () => {
initialState: {apiValues: {extraItems: {}}}
});

expect(component.queryByRole('button')).to.not.exist;
expect(component.queryByTestId('menu-bar')).to.not.exist;
});
});
4 changes: 3 additions & 1 deletion test/unit/lib/static/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ export const addResultToTree = ({tree, suiteName, browserName, attempt, metaInfo
imageIds: [],
metaInfo,
status: TestStatus.IDLE,
timestamp: 0
timestamp: 0,
suitePath: [],
name: browserName
};
tree.results.stateById[fullId] = {
matchedSelectedGroup: false
Expand Down

0 comments on commit 3a5931e

Please sign in to comment.