Skip to content

Commit

Permalink
fix: refactoring and minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Nov 16, 2024
1 parent 254c2ba commit ebd8b23
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 74 deletions.
3 changes: 0 additions & 3 deletions lib/static/modules/reducers/tree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,6 @@ export default ((state, action) => {
calcSuitesShowness({tree, suiteIds: [failedSuiteId], diff: diff.tree});
}

console.log('applying diff');
console.log(diff);

return applyStateUpdate(state, diff);
}

Expand Down
39 changes: 39 additions & 0 deletions lib/static/new-ui/components/Card/EmptyReportCard.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.container {
padding: 10px;
height: 100%;
}

.hint-card {
height: 100%;
display: flex;
flex-direction: column;
}

.empty-report-icon {
width: 40px;
}

.card-title {
color: #000;
margin-top: 16px;
}

.hints-container {
max-width: 450px;
margin-top: 8px;
}

.hint {
margin-top: 12px;
display: flex;
}

.hint-item-icon {
flex-shrink: 0;
margin-right: 8px;
color: var(--g-color-base-brand);
}

.hint-item-text {
line-height: 1.4;
}
27 changes: 27 additions & 0 deletions lib/static/new-ui/components/Card/EmptyReportCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {TextHintCard} from '@/static/new-ui/components/Card/TextHintCard';
import EmptyReport from '@/static/icons/empty-report.svg';
import classNames from 'classnames';
import {Icon} from '@gravity-ui/uikit';
import {Check} from '@gravity-ui/icons';
import React, {ReactNode} from 'react';

import styles from './EmptyReportCard.module.css';

export function EmptyReportCard(): ReactNode {
return <div className={styles.container}>
<TextHintCard className={styles.hintCard}>
<img src={EmptyReport} alt='icon' className={styles.emptyReportIcon}/>
<span className={classNames('text-header-1', styles.cardTitle)}>This report is empty</span>
<div className={styles.hintsContainer}>
{[
'Check if your project contains any tests',
'Check if the tool you are using is configured correctly and is able to find your tests',
'Check logs to see if some critical error has occurred and prevented report from collecting any results'
].map((hintText, index) => <div key={index} className={styles.hint}>
<Icon data={Check} className={styles.hintItemIcon}/>
<div className={styles.hintItemText}>{hintText}</div>
</div>)}
</div>
</TextHintCard>
</div>;
}
40 changes: 0 additions & 40 deletions lib/static/new-ui/components/MainLayout/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,3 @@
.footer-item--active {
color: var(--gn-aside-header-item-current-icon-color) !important;
}

.hint-card-container {
padding: 10px;
height: 100%;
}

.hint-card {
height: 100%;
display: flex;
flex-direction: column;
}

.hint-card-icon {
width: 40px;
}

.hint-card-title {
color: #000;
margin-top: 16px;
}

.hint-card-hints-container {
max-width: 450px;
margin-top: 8px;
}

.hint-card-hint {
margin-top: 12px;
display: flex;
}

.hint-card-check {
flex-shrink: 0;
margin-right: 8px;
color: var(--g-color-base-brand);
}

.hint-card-hint-text {
line-height: 1.4;
}
19 changes: 2 additions & 17 deletions lib/static/new-ui/components/MainLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import TestplaneIcon from '../../../icons/testplane-mono.svg';
import styles from './index.module.css';
import {Footer} from './Footer';
import {State} from '@/static/new-ui/types/store';
import {TextHintCard} from '@/static/new-ui/components/Card/TextHintCard';
import EmptyReport from '../../../icons/empty-report.svg';
import {Check} from '@gravity-ui/icons';
import {Icon} from '@gravity-ui/uikit';
import {EmptyReportCard} from '@/static/new-ui/components/Card/EmptyReportCard';

export enum PanelId {
Settings = 'settings',
Expand Down Expand Up @@ -62,19 +59,7 @@ export function MainLayout(props: MainLayoutProps): ReactNode {
customBackgroundClassName={styles.asideHeaderBgWrapper}
renderContent={(): React.ReactNode => {
if (isReportEmpty) {
return <div className={styles.hintCardContainer}>
<TextHintCard className={styles.hintCard}>
<img src={EmptyReport} alt='icon' className={styles.hintCardIcon}/>
<span className={classNames('text-header-1', styles.hintCardTitle)}>This report is empty</span>
<div className={styles.hintCardHintsContainer}>
{[
'Check if your project contains any tests',
'Check if the tool you are using is configured correctly and is able to find your tests',
'Check logs to see if some critical error has occurred and prevented report from collecting any results'
].map((hintText, index) => <div key={index} className={styles.hintCardHint}><Icon data={Check} className={styles.hintCardCheck}/><div className={styles.hintCardHintText}>{hintText}</div></div>)}
</div>
</TextHintCard>
</div>;
return <EmptyReportCard />;
}

return props.children;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@
transition: scale .15s ease, visibility 0.15s ease, opacity 0.15s ease;

visibility: hidden;
/*scale: 0.95;*/
opacity: 0;
}

.selected-container--visible {
visibility: visible;
/*scale: 1;*/
opacity: 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ export function TreeActionsToolbar(props: TreeActionsToolbarProps): ReactNode {
{isRunTestsAvailable && <IconButton icon={<Icon data={Play} height={14}/>}
tooltip={isSelectedAtLeastOne ? 'Run selected' : 'Run visible'} view={'flat'} onClick={handleRun}
disabled={isRunning || !isInitialized}></IconButton>}
{isEditScreensAvailable && <>
{isEditScreensAvailable && (
isUndoButtonVisible ?
<IconButton icon={<Icon data={ArrowUturnCcwLeft} />} tooltip={isSelectedAtLeastOne ? 'Undo accepting selected screenshots' : 'Undo accepting visible screenshots'} view={'flat'} onClick={handleUndo} disabled={isRunning || !isInitialized}></IconButton> :
<IconButton icon={<Icon data={Check} />} tooltip={isSelectedAtLeastOne ? 'Accept selected screenshots' : 'Accept visible screenshots'} view={'flat'} onClick={handleAccept} disabled={isRunning || !isInitialized}></IconButton>
</>}
<IconButton icon={<Icon data={ArrowUturnCcwLeft} />} tooltip={isSelectedAtLeastOne ? 'Undo accepting selected screenshots' : 'Undo accepting visible screenshots'} view={'flat'} onClick={handleUndo} disabled={isRunning || !isInitialized}></IconButton> :
<IconButton icon={<Icon data={Check} />} tooltip={isSelectedAtLeastOne ? 'Accept selected screenshots' : 'Accept visible screenshots'} view={'flat'} onClick={handleAccept} disabled={isRunning || !isInitialized}></IconButton>
)}
<div className={styles.buttonsDivider}></div>
<IconButton icon={<Icon data={SquareDashed} height={14}/>} tooltip={'Focus on active test'} view={'flat'} onClick={props.onHighlightCurrentTest} disabled={!isInitialized}/>
<IconButton icon={<Icon data={ChevronsExpandVertical} height={14}/>} tooltip={'Expand all'} view={'flat'} onClick={handleExpandAll} disabled={!isInitialized}/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe('lib/static/modules/reducers/static-image-accepter', () => {

const state = {staticImageAccepter, tree};

const newState = reducer(state, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: {imageId: 'imageId'}});
const newState = reducer(state, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: ['imageId']});

assert.equal(newState.staticImageAccepter.acceptableImages['imageId'].commitStatus, null);

Expand Down
14 changes: 7 additions & 7 deletions test/unit/lib/static/modules/reducers/tree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1854,26 +1854,26 @@ describe('lib/static/modules/reducers/tree', () => {
it('should return original image status', () => {
const newState = reducer(state, {type: actionNames.STATIC_ACCEPTER_STAGE_SCREENSHOT, payload: ['i1']});

const nextState = reducer(newState, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: {imageId: 'i1'}});
const nextState = reducer(newState, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: ['i1']});

assert.equal(nextState.tree.images.byId['i1'].status, FAIL);
});

it('should return original result status', () => {
const firstState = reducer(state, {type: actionNames.STATIC_ACCEPTER_STAGE_SCREENSHOT, payload: ['i1', 'i2']});

const secondState = reducer(firstState, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: {imageId: 'i1'}});
const thirdState = reducer(secondState, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: {imageId: 'i2'}});
const secondState = reducer(firstState, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: ['i1']});
const thirdState = reducer(secondState, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: ['i2']});

assert.equal(thirdState.tree.results.byId['r1'].status, FAIL);
});

it('should return original suite status', () => {
const firstState = reducer(state, {type: actionNames.STATIC_ACCEPTER_STAGE_SCREENSHOT, payload: ['i1', 'i2', 'i3']});

const secondState = reducer(firstState, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: {imageId: 'i1'}});
const thirdState = reducer(secondState, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: {imageId: 'i2'}});
const fourthState = reducer(thirdState, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: {imageId: 'i3'}});
const secondState = reducer(firstState, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: ['i1']});
const thirdState = reducer(secondState, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: ['i2']});
const fourthState = reducer(thirdState, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: ['i3']});

assert.equal(fourthState.tree.suites.byId['s1'].status, FAIL);
});
Expand All @@ -1884,7 +1884,7 @@ describe('lib/static/modules/reducers/tree', () => {
state.tree.results.byId['r1'].status = STAGED;
state.tree.images.byId['i1'].status = STAGED;

const nextState = reducer(state, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: {imageId: 'i1'}});
const nextState = reducer(state, {type: actionNames.STATIC_ACCEPTER_UNSTAGE_SCREENSHOT, payload: ['i1']});

assert.equal(nextState.tree.suites.byId['s0'].status, FAIL);
assert.equal(nextState.tree.suites.byId['s1'].status, FAIL);
Expand Down
2 changes: 2 additions & 0 deletions test/unit/lib/static/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {TestStatus} from '@/constants';
import reducer from '@/static/modules/reducers';
import localStorage from '@/static/modules/middlewares/local-storage';
import {BrowserEntity, ImageEntityFail, State, SuiteEntity, TreeEntity} from '@/static/new-ui/types/store';
import {UNCHECKED} from '@/constants/checked-statuses';

export const mkState = ({initialState}: { initialState: Partial<State> }): State => {
return _.defaultsDeep(initialState ?? {}, defaultState);
Expand Down Expand Up @@ -77,6 +78,7 @@ export const addBrowserToTree = ({tree, suiteName, browserName}: AddBrowserToTre
} as BrowserEntity;
tree.browsers.stateById[fullId] = {
shouldBeShown: true,
checkStatus: UNCHECKED,
retryIndex: 0,
isHiddenBecauseOfStatus: false
};
Expand Down

0 comments on commit ebd8b23

Please sign in to comment.