Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

WIP Profiling Report #53

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
24 changes: 24 additions & 0 deletions packages/client/src/components/HtmlViewer/HtmlViewer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { StepResult } from '@testim/root-cause-types';
import React from 'react';
import { apiUrl } from '../../stores/MainStore';
import styles from './styles.module.scss';

export interface HtmlViewerProps {
className?: string;
step: StepResult;
}

export function HtmlViewer({ step: { mhtmlFile }, className: containerClass }: HtmlViewerProps) {
if (!mhtmlFile) {
// TODO: provide nicer image, like in logs file
return <div>No HTML Recorded</div>;
}

return (
<div className={containerClass}>
<div className={styles.innerContainer}>
<iframe title={mhtmlFile} src={`${apiUrl}/test/html/${mhtmlFile}`} />
</div>
</div>
);
}
12 changes: 12 additions & 0 deletions packages/client/src/components/HtmlViewer/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.innerContainer {
width: 100%;
height: 100%;
border-radius: 5px;
box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.75);
}

iframe {
border: none;
width: 100%;
height: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { StackTrace } from '../StackTrace/StackTrace';
import { Logs } from '../Logs/Logs';
import { StepsSidebar } from '../StepsSidebar/StepsSidebar';
import { TestResultTitlebar } from '../TestResultTitlebar/TestResultTitlebar';
import { StepResultTitlebar } from '../StepResultTitlebar/StepResultTitlebar';
import { StepResultTab, StepResultTitlebar } from '../StepResultTitlebar/StepResultTitlebar';
import styles from './styles.module.css';
import { NetworkViewer } from '../NetworkViewer/NetworkViewer';
import type { MainStore } from '../../stores/MainStore';
import { ZeroStepsTest } from '../ZeroStepsTest/ZeroStepsTest';
import { observer } from 'mobx-react-lite';
import { HtmlViewer } from '../HtmlViewer/HtmlViewer';

export const SingleTestResultPage = observer(function SingleTestResultPage({
mainStore,
Expand All @@ -18,9 +19,7 @@ export const SingleTestResultPage = observer(function SingleTestResultPage({
mainStore: MainStore;
isClickimMode: boolean;
}) {
const [selectedTab, selectTab] = React.useState<
'screenshots' | 'stacktrace' | 'logs' | 'network'
>('screenshots');
const [selectedTab, selectTab] = React.useState<StepResultTab>('screenshots');

const { selectedStep } = mainStore;

Expand All @@ -44,9 +43,14 @@ export const SingleTestResultPage = observer(function SingleTestResultPage({
);
}

if (selectedTab === 'html') {
return <HtmlViewer step={selectedStep} className={styles.htmlContainer} />;
}

if (selectedTab === 'stacktrace') {
return <StackTrace step={selectedStep} />;
}

if (selectedTab === 'logs') {
return <Logs step={selectedStep} />;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
.tabWrapper {
overflow: hidden;
width: 100%;
height: 100%;
}

.screenshotContainer {
.screenshotContainer,
.htmlContainer {
display: flex;
width: 100%;
align-items: center;
height: 100%;
justify-content: center;
}

.screenshotContainer .image {
overflow: hidden;
}

.loader:before {
position: absolute;
content: ' ';
Expand Down Expand Up @@ -44,6 +46,7 @@
padding-top: 30px;
padding-bottom: 30px;
}

.stepContents .navButton {
width: 28px;
height: 28px;
Expand All @@ -54,12 +57,15 @@
cursor: pointer;
user-select: none;
}

.stepContents .navButton:hover {
background: #dbdfe3;
}

.stepContents .navButton:nth-child(3) .arrowIconSvg {
transform: rotate(180deg);
}

.stepContents .screenshot {
background: white;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.11);
Expand Down Expand Up @@ -87,6 +93,7 @@
height: 100%;
background: white;
}

.app:focus {
outline: none;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,32 @@ import classnames from 'classnames';
import type { Har } from 'har-format';
import stripAnsi from 'strip-ansi';

export type StepResultTab = 'screenshots' | 'html' | 'stacktrace' | 'logs' | 'network';

function Tab({
tabName,
selectedTab,
selectTab,
}: {
selectedTab: string;
tabName: StepResultTab;
selectTab(tab: StepResultTab): void;
}) {
return (
<div
className={classnames({ [styles.selected]: selectedTab === tabName })}
onClick={() => selectTab(tabName)}
>
<div>
{tabName.toUpperCase()}
<div className={styles.underline}></div>
</div>
</div>
);
}

const SIMPLE_TABS: StepResultTab[] = ['screenshots', 'html', 'stacktrace', 'logs'];

export const StepResultTitlebar = function StepResultTitlebar({
selectedStep,
selectedTab,
Expand All @@ -14,17 +40,19 @@ export const StepResultTitlebar = function StepResultTitlebar({
isClickimMode,
}: {
selectedStep: StepResult;
selectedTab: 'screenshots' | 'stacktrace' | 'logs' | 'network';
selectTab(tab: 'screenshots' | 'stacktrace' | 'logs' | 'network'): unknown;
selectedTab: StepResultTab;
selectTab(tab: StepResultTab): void;
harFileContents: Har | undefined;
isClickimMode: boolean;
}) {
const [hover, setHover] = useState<boolean>(false);
const [toolTipNeeded, setToolTipNeeded] = useState<boolean>(false);
const stepNameRef = useRef<HTMLSpanElement>(null);

const stepErrorStr = selectedStep.stepError?.message
? stripAnsi(selectedStep.stepError?.message).substr(0, 100)
: undefined;

const stepName = selectedStep.name ? stripAnsi(selectedStep.name) : undefined;

useLayoutEffect(() => {
Expand All @@ -37,7 +65,7 @@ export const StepResultTitlebar = function StepResultTitlebar({

window.addEventListener('resize', handleResize, { passive: true });
return () => window.removeEventListener('resize', handleResize);
}, [toolTipNeeded, selectedStep]);
}, [setToolTipNeeded, selectedStep]);

return (
<div
Expand All @@ -58,52 +86,10 @@ export const StepResultTitlebar = function StepResultTitlebar({
<span className={styles.stepError}>{stepErrorStr}</span>
</div>
<div className={styles.tabs}>
<div
className={classnames({ [styles.selected]: selectedTab === 'screenshots' })}
onClick={() => {
selectTab('screenshots');
}}
>
<div>
SCREENSHOT
<div className={styles.underline}></div>
</div>
</div>
<div
className={classnames({ [styles.selected]: selectedTab === 'stacktrace' })}
onClick={() => {
selectTab('stacktrace');
}}
>
<div>
STACKTRACE
<div className={styles.underline}></div>
</div>
</div>
<div
className={classnames({ [styles.selected]: selectedTab === 'logs' })}
onClick={() => {
selectTab('logs');
}}
>
<div>
LOGS
<div className={styles.underline}></div>
</div>
</div>
{harFileContents && (
<div
className={classnames({ [styles.selected]: selectedTab === 'network' })}
onClick={() => {
selectTab('network');
}}
>
<div>
NETWORK
<div className={styles.underline}></div>
</div>
</div>
)}
{SIMPLE_TABS.map((tabName) => (
<Tab {...{ key: tabName, tabName, selectedTab, selectTab }} />
))}
{harFileContents && <Tab {...{ tabName: 'network', selectedTab, selectTab }} />}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Object {
"endedTimestamp": 26,
"fileName": "noise_removed/packages/root-cause-core/lib/launch-api.test.ts",
"hasNetworkLogs": true,
"profilingFile": "profile.cpuprofile",
"systemInfo": Object {
"automationFramework": "puppeteer",
"browser": "chromium",
Expand All @@ -25,9 +26,9 @@ Object {
"callstack": Array [
Object {
"column": 29,
"file": "lib/assortedHooks.ts",
"file": "lib/hooks/testEndHook.ts",
"function": "testEndHook",
"line": 118,
"line": 17,
},
Object {
"column": 15,
Expand All @@ -39,7 +40,7 @@ Object {
"column": 5,
"file": "lib/attach.ts",
"function": "endTest",
"line": 115,
"line": 120,
},
Object {
"column": 5,
Expand Down Expand Up @@ -82,6 +83,7 @@ Object {
"testFullName": "1-Launch api test Launch api test = failing",
"testName": "Launch api test Launch api test = failing",
"timestamp": 3,
"traceOutputFileName": "performanceTrace.json",
},
"steps": Array [
Object {
Expand Down Expand Up @@ -798,6 +800,7 @@ Object {
"endedTimestamp": 26,
"fileName": "noise_removed/packages/root-cause-core/lib/launch-api.test.ts",
"hasNetworkLogs": true,
"profilingFile": "profile.cpuprofile",
"systemInfo": Object {
"automationFramework": "puppeteer",
"browser": "chromium",
Expand All @@ -817,6 +820,7 @@ Object {
"testFullName": "1-Launch api test Launch api test passing",
"testName": "Launch api test Launch api test passing",
"timestamp": 3,
"traceOutputFileName": "performanceTrace.json",
},
"steps": Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Object {
"endedTimestamp": 29,
"fileName": "noise_removed/packages/root-cause-core/lib/sanity-integration-playwright.test.ts",
"hasNetworkLogs": true,
"profilingFile": "profile.cpuprofile",
"systemInfo": Object {
"automationFramework": "playwright",
"browser": "chromium",
Expand All @@ -25,9 +26,9 @@ Object {
"callstack": Array [
Object {
"column": 29,
"file": "lib/assortedHooks.ts",
"file": "lib/hooks/testEndHook.ts",
"function": "testEndHook",
"line": 118,
"line": 17,
},
Object {
"column": 15,
Expand All @@ -39,7 +40,7 @@ Object {
"column": 5,
"file": "lib/attach.ts",
"function": "endTest",
"line": 115,
"line": 120,
},
Object {
"column": 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Object {
"endedTimestamp": 33,
"fileName": "noise_removed/packages/root-cause-core/lib/sanity-integration.test.ts",
"hasNetworkLogs": true,
"profilingFile": "profile.cpuprofile",
"systemInfo": Object {
"automationFramework": "puppeteer",
"browser": "chromium",
Expand All @@ -25,9 +26,9 @@ Object {
"callstack": Array [
Object {
"column": 29,
"file": "lib/assortedHooks.ts",
"file": "lib/hooks/testEndHook.ts",
"function": "testEndHook",
"line": 118,
"line": 17,
},
Object {
"column": 15,
Expand All @@ -39,7 +40,7 @@ Object {
"column": 5,
"file": "lib/attach.ts",
"function": "endTest",
"line": 115,
"line": 120,
},
Object {
"column": 5,
Expand Down Expand Up @@ -73,6 +74,7 @@ Object {
"testFullName": "Sanity integration test Sanity integration test 1",
"testName": "Sanity integration test 1",
"timestamp": 2,
"traceOutputFileName": "performanceTrace.json",
},
"steps": Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Object {
"endedTimestamp": 15,
"fileName": "noise_removed/packages/root-cause-core/lib/with-har-record.test.ts",
"hasNetworkLogs": true,
"profilingFile": "profile.cpuprofile",
"systemInfo": Object {
"automationFramework": "puppeteer",
"browser": "chromium",
Expand All @@ -26,6 +27,7 @@ Object {
"testFullName": "with har record with har record",
"testName": "with har record",
"timestamp": 2,
"traceOutputFileName": "performanceTrace.json",
},
"steps": Array [
Object {
Expand Down
Loading