Skip to content

Commit e804b9b

Browse files
internal: (cy.prompt) ensure that get code can properly work with prompts in cy.origin (#32596)
* internal: (cy.prompt) ensure that get code can properly work with prompts in cy.origin * additional tests * additional tests * Apply suggestions from code review * code review comment * fix merge * fix merge * Update packages/data-context/graphql/schemaTypes/index.ts
1 parent dd5bc47 commit e804b9b

File tree

4 files changed

+27
-47
lines changed

4 files changed

+27
-47
lines changed

packages/driver/src/cy/commands/prompt/index.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ const initializeCloudCyPrompt = async (Cypress: Cypress.Cypress, cy: Cypress.Cyp
9696
if (!Cypress.isCrossOriginSpecBridge) {
9797
Cypress.primaryOriginCommunicator.removeAllListeners('prompt:more-info-needed')
9898
Cypress.primaryOriginCommunicator.on('prompt:more-info-needed', ({ testId, logId, onSave, onCancel }: CyPromptMoreInfoNeededOptions) => {
99-
window.getEventManager!().ws.emit('prompt:more-info-needed', { testId, logId, onSave, onCancel })
99+
window.getEventManager!().localBus.emit('prompt:more-info-needed', { testId, logId, onSave, onCancel })
100+
})
101+
102+
Cypress.primaryOriginCommunicator.removeAllListeners('get:source:details:for:line')
103+
Cypress.primaryOriginCommunicator.on('get:source:details:for:line', ({ line, projectRoot }, { origin, responseEvent }) => {
104+
const sourceDetails = $stackUtils.getSourceDetailsForFirstLine(line, projectRoot)
105+
106+
Cypress.primaryOriginCommunicator.toSpecBridge(origin, responseEvent, sourceDetails)
100107
})
101108
}
102109

@@ -109,7 +116,17 @@ const initializeCloudCyPrompt = async (Cypress: Cypress.Cypress, cy: Cypress.Cyp
109116
extendErrorMessages: $errUtils.extendErrorMessages,
110117
throwErrByPath: $errUtils.throwErrByPath,
111118
},
112-
getSourceDetailsForFirstLine: $stackUtils.getSourceDetailsForFirstLine,
119+
getSourceDetailsForFirstLine: (line, projectRoot) => {
120+
if (Cypress.isCrossOriginSpecBridge) {
121+
return Cypress.specBridgeCommunicator.toPrimaryPromise({
122+
event: 'get:source:details:for:line',
123+
data: { line, projectRoot },
124+
timeout: Cypress.config().defaultCommandTimeout,
125+
})
126+
}
127+
128+
return $stackUtils.getSourceDetailsForFirstLine(line, projectRoot)
129+
},
113130
onMoreInfoNeeded: ({ testId, logId, onSave, onCancel }: CyPromptMoreInfoNeededOptions) => {
114131
if (Cypress.isCrossOriginSpecBridge) {
115132
Cypress.specBridgeCommunicator.toPrimary('prompt:more-info-needed', { testId, logId, onSave, onCancel })

packages/driver/src/cy/commands/prompt/prompt-driver-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export interface CyPromptOptions {
9494
getSourceDetailsForFirstLine: (
9595
stack: string,
9696
projectRoot?: string
97-
) => CyPromptStackLineDetail | undefined
97+
) => CyPromptStackLineDetail | Promise<CyPromptStackLineDetail | undefined> | undefined
9898
onMoreInfoNeeded: (options: CyPromptMoreInfoNeededOptions) => void
9999
}
100100

packages/errors/__snapshot-html__/EXPERIMENTAL_PROMPT_COMMAND_E2E_ONLY.html

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
The experimentalPromptCommand experiment is currently only supported for End to End Testing and must be configured as an e2e testing type property: e2e.experimentalPromptCommand.
2+

3+
{
4+
 e2e: {
5+
 experimentalPromptCommand: true
6+
 },
7+
}

0 commit comments

Comments
 (0)