From cb2d94e4679cd651d240f324215568f53a1bb6c4 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Tue, 15 Apr 2025 17:29:07 +0200 Subject: [PATCH] chore: refactor error context (#35613) --- packages/html-reporter/src/testErrorView.tsx | 15 +++--- packages/html-reporter/src/testResultView.tsx | 6 +-- packages/playwright/src/DEPS.list | 2 +- .../src/{prompt.ts => errorContext.ts} | 54 ++++++++----------- packages/playwright/src/index.ts | 26 ++++----- .../src/isomorphic/testServerInterface.ts | 2 +- packages/playwright/src/reporters/base.ts | 4 +- packages/playwright/src/runner/testServer.ts | 2 +- packages/trace-viewer/src/ui/errorsTab.tsx | 7 +-- packages/trace-viewer/src/ui/modelUtil.ts | 4 +- packages/web/src/prompts.ts | 23 ++++++++ .../playwright.connect.spec.ts | 4 +- tests/playwright-test/playwright.spec.ts | 4 +- tests/playwright-test/reporter-json.spec.ts | 2 +- tests/playwright-test/reporter-line.spec.ts | 6 +-- 15 files changed, 89 insertions(+), 72 deletions(-) rename packages/playwright/src/{prompt.ts => errorContext.ts} (75%) create mode 100644 packages/web/src/prompts.ts diff --git a/packages/html-reporter/src/testErrorView.tsx b/packages/html-reporter/src/testErrorView.tsx index 881c420c22..d7a979a9d9 100644 --- a/packages/html-reporter/src/testErrorView.tsx +++ b/packages/html-reporter/src/testErrorView.tsx @@ -20,17 +20,18 @@ import './testErrorView.css'; import type { ImageDiff } from '@web/shared/imageDiffView'; import { ImageDiffView } from '@web/shared/imageDiffView'; import { TestAttachment } from './types'; +import { fixTestInstructions } from '@web/prompts'; export const TestErrorView: React.FC<{ error: string; testId?: string; - prompt?: TestAttachment; -}> = ({ error, testId, prompt }) => { + context?: TestAttachment; +}> = ({ error, testId, context }) => { return ( - {prompt && ( + {context && (
- +
)}
@@ -47,14 +48,14 @@ export const CodeSnippet = ({ code, children, testId }: React.PropsWithChildren< ); }; -const PromptButton: React.FC<{ prompt: TestAttachment }> = ({ prompt }) => { +const PromptButton: React.FC<{ context: TestAttachment }> = ({ context }) => { const [copied, setCopied] = React.useState(false); return