mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-11 09:20:20 -06:00
fix: (cy.prompt) add more context to the error message shown when cy.prompt() fails to download (#32822)
This commit is contained in:
@@ -12,6 +12,7 @@ _Released 10/20/2025 (PENDING)_
|
||||
- Fixed an issue where grouped command text jumps up and down when expanding and collapsing in the command log. Addressed in [#32757](https://github.com/cypress-io/cypress/pull/32757).
|
||||
- Fixed an issue where command snapshots were not correctly displayed in Studio. Addressed in [#32808](https://github.com/cypress-io/cypress/pull/32808).
|
||||
- Fixed an issue with grouped console prop items having a hard to read blue color in the console log and duplicate `:` characters being displayed. Addressed in [#32776](https://github.com/cypress-io/cypress/pull/32776).
|
||||
- Added more context to the error message shown when `cy.prompt()` fails to download. Addressed in [#32822](https://github.com/cypress-io/cypress/pull/32822).
|
||||
|
||||
**Misc:**
|
||||
|
||||
|
||||
@@ -88,6 +88,8 @@ export class CyPromptLifecycleManager {
|
||||
const cloudUrl = ctx.cloud.getCloudUrl(cloudEnv)
|
||||
const cloudHeaders = await ctx.cloud.additionalHeaders()
|
||||
|
||||
const lastError = error instanceof AggregateError ? error.errors[error.errors.length - 1] : error
|
||||
|
||||
reportCyPromptError({
|
||||
cloudApi: {
|
||||
cloudUrl,
|
||||
@@ -99,7 +101,7 @@ export class CyPromptLifecycleManager {
|
||||
additionalHeaders: cloudHeaders,
|
||||
cyPromptHash: this.cyPromptHash,
|
||||
projectSlug: (await ctx.project.getConfig()).projectId || undefined,
|
||||
error,
|
||||
error: lastError,
|
||||
cyPromptMethod: 'initializeCyPromptManager',
|
||||
cyPromptMethodArgs: [],
|
||||
})
|
||||
@@ -107,7 +109,7 @@ export class CyPromptLifecycleManager {
|
||||
// Clean up any registered listeners
|
||||
this.listeners = []
|
||||
|
||||
return { error }
|
||||
return { error: lastError }
|
||||
})
|
||||
|
||||
this.cyPromptManagerPromise = cyPromptManagerPromise
|
||||
|
||||
@@ -566,6 +566,85 @@ describe('CyPromptLifecycleManager', () => {
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('handles errors from ensureCyPromptBundle', async () => {
|
||||
const actualError = new Error('Test error')
|
||||
|
||||
ensureCyPromptBundleStub.rejects(actualError)
|
||||
cyPromptLifecycleManager.initializeCyPromptManager({
|
||||
cloudDataSource: mockCloudDataSource,
|
||||
ctx: mockCtx,
|
||||
record: false,
|
||||
key: '123e4567-e89b-12d3-a456-426614174000',
|
||||
})
|
||||
|
||||
// @ts-expect-error - accessing private property
|
||||
const cyPromptPromise = cyPromptLifecycleManager.cyPromptManagerPromise
|
||||
|
||||
expect(cyPromptPromise).to.not.be.null
|
||||
|
||||
const { error } = (await cyPromptPromise) as { error: Error }
|
||||
|
||||
expect(error.message).to.equal('Test error')
|
||||
|
||||
expect(reportCyPromptErrorStub).to.be.calledWith({
|
||||
cloudApi: {
|
||||
cloudUrl: 'https://cloud.cypress.io',
|
||||
CloudRequest,
|
||||
createCloudRequest,
|
||||
isRetryableError,
|
||||
asyncRetry,
|
||||
},
|
||||
cyPromptHash: 'abc',
|
||||
projectSlug: 'test-project-id',
|
||||
error: actualError,
|
||||
cyPromptMethod: 'initializeCyPromptManager',
|
||||
cyPromptMethodArgs: [],
|
||||
additionalHeaders: {
|
||||
'Authorization': 'Bearer test-token',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('handles AggregateErrors from ensureCyPromptBundle', async () => {
|
||||
const aggregateError = new AggregateError([new Error('Test error'), new Error('Second error')], 'Multiple errors')
|
||||
|
||||
ensureCyPromptBundleStub.rejects(aggregateError)
|
||||
|
||||
cyPromptLifecycleManager.initializeCyPromptManager({
|
||||
cloudDataSource: mockCloudDataSource,
|
||||
ctx: mockCtx,
|
||||
record: false,
|
||||
key: '123e4567-e89b-12d3-a456-426614174000',
|
||||
})
|
||||
|
||||
// @ts-expect-error - accessing private property
|
||||
const cyPromptPromise = cyPromptLifecycleManager.cyPromptManagerPromise
|
||||
|
||||
expect(cyPromptPromise).to.not.be.null
|
||||
|
||||
const { error } = (await cyPromptPromise) as { error: Error }
|
||||
|
||||
expect(error.message).to.equal('Second error')
|
||||
|
||||
expect(reportCyPromptErrorStub).to.be.calledWith({
|
||||
cloudApi: {
|
||||
cloudUrl: 'https://cloud.cypress.io',
|
||||
CloudRequest,
|
||||
createCloudRequest,
|
||||
isRetryableError,
|
||||
asyncRetry,
|
||||
},
|
||||
cyPromptHash: 'abc',
|
||||
projectSlug: 'test-project-id',
|
||||
error: aggregateError.errors[aggregateError.errors.length - 1],
|
||||
cyPromptMethod: 'initializeCyPromptManager',
|
||||
cyPromptMethodArgs: [],
|
||||
additionalHeaders: {
|
||||
'Authorization': 'Bearer test-token',
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('getCyPrompt', () => {
|
||||
|
||||
Reference in New Issue
Block a user