Skip to content

Commit

Permalink
fix(frontend): fix test run success message (#2514)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeepc committed May 12, 2023
1 parent bf6cf53 commit d1c50f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
20 changes: 14 additions & 6 deletions web/src/components/RunDetailLayout/RunDetailLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import {useParams} from 'react-router-dom';
import RunDetailTest from 'components/RunDetailTest';
import RunDetailTrace from 'components/RunDetailTrace';
import RunDetailTrigger from 'components/RunDetailTrigger';
import {RunDetailModes, TestState} from 'constants/TestRun.constants';
import TestRunAnalyticsService from 'services/Analytics/TestRunAnalytics.service';
import {useTestRun} from 'providers/TestRun/TestRun.provider';
import {RunDetailModes} from 'constants/TestRun.constants';
import useDocumentTitle from 'hooks/useDocumentTitle';
import Test from 'models/Test.model';
import {isRunStateSucceeded} from 'models/TestRun.model';
import {useNotification} from 'providers/Notification/Notification.provider';
import {useSettingsValues} from 'providers/SettingsValues/SettingsValues.provider';
import {useTestRun} from 'providers/TestRun/TestRun.provider';
import TestRunAnalyticsService from 'services/Analytics/TestRunAnalytics.service';
import {ConfigMode} from 'types/DataStore.types';
import HeaderLeft from './HeaderLeft';
import HeaderRight from './HeaderRight';
import * as S from './RunDetailLayout.styled';
Expand All @@ -34,19 +37,24 @@ const RunDetailLayout = ({test: {id, name, trigger, version = 1}, test}: IProps)
const {mode = RunDetailModes.TRIGGER} = useParams();
const {showNotification} = useNotification();
const {isError, run, runEvents} = useTestRun();
const {dataStoreConfig} = useSettingsValues();
const [prevState, setPrevState] = useState(run.state);
useDocumentTitle(`${name} - ${run.state}`);

useEffect(() => {
if (run.state === TestState.FINISHED && prevState !== TestState.FINISHED) {
const isNoTracingMode = dataStoreConfig.mode === ConfigMode.NO_TRACING_MODE;

if (isRunStateSucceeded(run.state) && !isRunStateSucceeded(prevState)) {
showNotification({
type: 'success',
title: 'Trace has been fetched successfully',
title: isNoTracingMode
? 'Response received. Skipping looking for trace as you are in No-Tracing Mode'
: 'Trace has been fetched successfully',
});
}

setPrevState(run.state);
}, [prevState, run.state, showNotification]);
}, [dataStoreConfig.mode, prevState, run.state, showNotification]);

const tabBarExtraContent = useMemo(
() => ({
Expand Down
5 changes: 3 additions & 2 deletions web/src/components/TestSpecs/Empty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ const Empty = () => {
<S.EmptyTitle>There are no test specs for this test</S.EmptyTitle>
<S.EmptyText>Add a test spec, or choose from our predefined test specs:</S.EmptyText>
<S.SnippetsContainer>
{TEST_SPEC_SNIPPETS.map(snippet => (
<div>
{TEST_SPEC_SNIPPETS.map((snippet, index) => (
// eslint-disable-next-line react/no-array-index-key
<div key={`${snippet.selector}-${index}`}>
<Button
disabled={!isRunStateSucceeded(state)}
icon={<AimOutlined />}
Expand Down

0 comments on commit d1c50f1

Please sign in to comment.