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

[Monitor management] Fix test now mode issues #129501

Merged
merged 6 commits into from
Apr 7, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
import {
isScreenshotImageBlob,
isScreenshotRef,
ScreenshotImageBlob,
ScreenshotRefImageData,
} from '../../../../../../common/runtime_types';
import { useFetcher, FETCH_STATUS } from '../../../../../../../observability/public';
Expand All @@ -35,10 +36,11 @@ const StepDiv = styled.div`
interface Props {
checkGroup?: string;
label?: string;
stepStatus?: string;
initialStepNo?: number;
}

export const PingTimestamp = ({ label, checkGroup, initialStepNo = 1 }: Props) => {
export const PingTimestamp = ({ label, checkGroup, stepStatus, initialStepNo = 1 }: Props) => {
const [stepNumber, setStepNumber] = useState(initialStepNo);
const [isImagePopoverOpen, setIsImagePopoverOpen] = useState(false);

Expand All @@ -57,6 +59,12 @@ export const PingTimestamp = ({ label, checkGroup, initialStepNo = 1 }: Props) =
});

const { data, status } = useFetcher(() => {
if (stepStatus === 'skipped') {
return new Promise<ScreenshotImageBlob | ScreenshotRefImageData | null>((resolve) =>
resolve(null)
);
}

if (intersection && intersection.intersectionRatio === 1 && !stepImages[stepNumber - 1])
return getJourneyScreenshot(imgPath);
}, [intersection?.intersectionRatio, stepNumber, imgPath]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

import { useEffect } from 'react';
import * as React from 'react';
import { EuiAccordion, EuiText } from '@elastic/eui';
import { EuiAccordion, EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner, EuiText } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import styled from 'styled-components';
import { StepsList } from '../../../synthetics/check_steps/steps_list';
import { JourneyStep } from '../../../../../common/runtime_types';
import { useBrowserRunOnceMonitors } from './use_browser_run_once_monitors';
import { TestResultHeader } from '../test_result_header';
import { StdErrorLogs } from '../../../synthetics/check_steps/stderr_logs';

interface Props {
monitorId: string;
Expand Down Expand Up @@ -74,11 +75,25 @@ export const BrowserTestRunResult = ({ monitorId, isMonitorSaved, onDone }: Prop
data-test-subj="expandResults"
initialIsOpen={true}
>
{isStepsLoading && <EuiText>{LOADING_STEPS}</EuiText>}
{isStepsLoading && (
<EuiFlexGroup alignItems="center" gutterSize="xs">
<EuiFlexItem grow={false}>
<EuiText>{LOADING_STEPS}</EuiText>
</EuiFlexItem>
<EuiFlexItem>
<EuiLoadingSpinner size="s" />
</EuiFlexItem>
</EuiFlexGroup>
)}
{isStepsLoadingFailed && (
<EuiText color="danger">{summaryDoc?.error?.message ?? FAILED_TO_RUN}</EuiText>
)}

{isStepsLoadingFailed &&
summaryDoc?.error?.message?.includes('journey did not finish executing') && (
<StdErrorLogs checkGroup={summaryDoc.monitor.check_group} hideTitle={true} />
)}

{stepEnds.length > 0 && stepListData?.steps && (
<StepsList
data={stepListData.steps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ export const StdErrorLogs = ({
timestamp,
title,
summaryMessage,
hideTitle = false,
}: {
configId?: string;
checkGroup?: string;
timestamp?: string;
title?: string;
summaryMessage?: string;
hideTitle?: boolean;
}) => {
const columns = [
{
Expand Down Expand Up @@ -95,24 +97,31 @@ export const StdErrorLogs = ({

return (
<>
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={false}>
<EuiTitle size="s">
<h3>{title ?? TEST_RUN_LOGS_LABEL}</h3>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem>
<EuiLink>
<EuiButtonEmpty href={discoverLink} iconType="discoverApp" isDisabled={!discoverLink}>
{VIEW_IN_DISCOVER_LABEL}
</EuiButtonEmpty>
</EuiLink>
</EuiFlexItem>
</EuiFlexGroup>

<EuiCallOut title={ERROR_SUMMARY_LABEL} color="danger" iconType="alert">
<p>{summaryMessage}</p>
</EuiCallOut>
{!hideTitle && (
<>
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={false}>
<EuiTitle size="s">
<h3>{title ?? TEST_RUN_LOGS_LABEL}</h3>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem>
<EuiLink>
<EuiButtonEmpty
href={discoverLink}
iconType="discoverApp"
isDisabled={!discoverLink}
>
{VIEW_IN_DISCOVER_LABEL}
</EuiButtonEmpty>
</EuiLink>
</EuiFlexItem>
</EuiFlexGroup>
<EuiCallOut title={ERROR_SUMMARY_LABEL} color="danger" iconType="alert">
<p>{summaryMessage}</p>
</EuiCallOut>
</>
)}

<EuiSpacer />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const StepImage = ({ step, compactView }: Props) => {
<PingTimestamp
checkGroup={step.monitor.check_group}
initialStepNo={step.synthetics?.step?.index}
stepStatus={step.synthetics.payload?.status}
/>
</EuiFlexItem>
<EuiFlexItem grow={false} style={{ minWidth: 80 }}>
Expand Down