-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Telemetry: Add playwright-prompt #33229
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
Merged
valentinpalkovic
merged 2 commits into
next
from
valentin/add-init-step-playwright-telemetry
Nov 29, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| // eslint-disable-next-line depend/ban-dependencies | ||
| import type { ExecaChildProcess } from 'execa'; | ||
|
|
||
| import { executeTaskWithSpinner } from './tasks'; | ||
|
|
||
| // Create a minimal fake ExecaChildProcess | ||
| const makeChild = (onStart?: (cp: Partial<ExecaChildProcess>) => void): ExecaChildProcess => { | ||
| const listeners: Record<string, Function[]> = {}; | ||
| const stdout = { | ||
| on: vi.fn((event: string, cb: (data: Buffer) => void) => { | ||
| listeners[event] ||= []; | ||
| listeners[event].push(cb); | ||
| }), | ||
| } as any; | ||
|
|
||
| const cp: Partial<ExecaChildProcess> = { | ||
| stdout: stdout as any, | ||
| then: undefined as any, | ||
| catch: undefined as any, | ||
| finally: undefined as any, | ||
| }; | ||
|
|
||
| const promise = Promise.resolve() as any; | ||
| Object.setPrototypeOf(cp, promise); | ||
| (cp as any).then = promise.then.bind(promise); | ||
| (cp as any).catch = promise.catch.bind(promise); | ||
| (cp as any).finally = promise.finally.bind(promise); | ||
|
|
||
| onStart?.(cp); | ||
| return cp as ExecaChildProcess; | ||
| }; | ||
|
|
||
| describe('executeTaskWithSpinner', () => { | ||
| it('returns "aborted" when the child process rejects with an abort error', async () => { | ||
| const outcome = await executeTaskWithSpinner(() => makeChild(), { | ||
| id: 'test', | ||
| intro: 'Intro', | ||
| error: 'Error', | ||
| success: 'Success', | ||
| abortable: true, | ||
| }); | ||
|
|
||
| // Non-abort path returns undefined | ||
| expect(outcome).toBeUndefined(); | ||
|
|
||
| // Simulate an aborted child process by rejecting with an abort-like error message | ||
| const outcome2 = await executeTaskWithSpinner( | ||
| () => { | ||
| const err = new Error('The operation was aborted'); | ||
| const p = Promise.reject(err); | ||
| // Avoid unhandled rejection warnings | ||
| p.catch(() => {}); | ||
| const cp: any = makeChild(); | ||
| // Make the thenable reject | ||
| const rejected = p as any; | ||
| Object.setPrototypeOf(cp, rejected); | ||
| cp.then = rejected.then.bind(rejected); | ||
| cp.catch = rejected.catch.bind(rejected); | ||
| cp.finally = rejected.finally.bind(rejected); | ||
| return cp; | ||
| }, | ||
| { | ||
| id: 'test2', | ||
| intro: 'Intro', | ||
| error: 'Error', | ||
| success: 'Success', | ||
| abortable: true, | ||
| } | ||
| ); | ||
|
|
||
| expect(outcome2).toBe('aborted'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mock missing the
resultfield from the updated return type.The
installPlaywrightmock returns{ errors: [] }, but the actual return type is{ errors: string[]; result: 'installed' | 'skipped' | 'aborted' | 'failed' }. The production code accessesresultto pass totelemetryService.trackPlaywrightPromptDecision(result). This may cause test failures or mask issues.vi.mock('storybook/internal/cli', async (actualImport) => ({ ...(await actualImport()), AddonVitestService: vi.fn().mockImplementation(() => ({ - installPlaywright: vi.fn().mockResolvedValue({ errors: [] }), + installPlaywright: vi.fn().mockResolvedValue({ errors: [], result: 'installed' }), })), }));And in
beforeEach:const mockInstance = { - installPlaywright: vi.fn().mockResolvedValue({ errors: [] }), + installPlaywright: vi.fn().mockResolvedValue({ errors: [], result: 'installed' }), };Also applies to: 43-48
🤖 Prompt for AI Agents