From a8fa4d7e0dd3b874af8cb04ebe69878bcf2d5d92 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Thu, 6 Feb 2025 12:31:45 +0100 Subject: [PATCH] add prompt --- packages/html-reporter/src/reportView.tsx | 4 +-- packages/html-reporter/src/testErrorView.tsx | 36 +++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/packages/html-reporter/src/reportView.tsx b/packages/html-reporter/src/reportView.tsx index ec8966a68c..4531756747 100644 --- a/packages/html-reporter/src/reportView.tsx +++ b/packages/html-reporter/src/reportView.tsx @@ -78,7 +78,7 @@ export const ReportView: React.FC<{ return result; }, [report, filter]); - return
+ return
{report?.json() && } @@ -94,7 +94,7 @@ export const ReportView: React.FC<{ {!!report && }
-
; +
; }; const TestCaseViewLoader: React.FC<{ diff --git a/packages/html-reporter/src/testErrorView.tsx b/packages/html-reporter/src/testErrorView.tsx index ea402106a8..97db1b5c42 100644 --- a/packages/html-reporter/src/testErrorView.tsx +++ b/packages/html-reporter/src/testErrorView.tsx @@ -19,13 +19,47 @@ import * as React from 'react'; import './testErrorView.css'; import type { ImageDiff } from '@web/shared/imageDiffView'; import { ImageDiffView } from '@web/shared/imageDiffView'; +import { GitCommitInfoContext } from './reportView'; export const TestErrorView: React.FC<{ error: string; testId?: string; }> = ({ error, testId }) => { const html = React.useMemo(() => ansiErrorToHtml(error), [error]); - return
; + return ( +
+ +
+
+ ); +}; + +const ansiRegex = new RegExp('([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~])))', 'g'); +export function stripAnsiEscapes(str: string): string { + return str.replace(ansiRegex, ''); +} + +const PromptButton: React.FC<{ + error: string; +}> = ({ error }) => { + const gitCommitInfo = React.useContext(GitCommitInfoContext); + if (!gitCommitInfo) + return undefined; + + const diff = gitCommitInfo['pull.diff'] ?? gitCommitInfo['revision.diff']; + if (!diff) + return undefined; + + return ( + + ); }; export const TestScreenshotErrorView: React.FC<{