Skip to content

Commit a1524ea

Browse files
committed
chore: cleanup
1 parent 068f226 commit a1524ea

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

packages/driver/cypress/e2e/commands/prompt/prompt-initialization-error.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('src/cy/commands/prompt', () => {
1818

1919
cy.visit('http://www.foobar.com:3500/fixtures/dom.html')
2020

21-
cy['commandFns']['prompt'].__reset()
21+
cy['commandFns']['prompt'].__resetPrompt()
2222
// @ts-expect-error - this will not error when we actually release the experimentalPromptCommand flag
2323
cy.prompt(['Hello, world!'])
2424
})
@@ -42,7 +42,7 @@ describe('src/cy/commands/prompt', () => {
4242

4343
cy.visit('http://www.foobar.com:3500/fixtures/dom.html')
4444

45-
cy['commandFns']['prompt'].__reset()
45+
cy['commandFns']['prompt'].__resetPrompt()
4646
// @ts-expect-error - this will not error when we actually release the experimentalPromptCommand flag
4747
cy.prompt(['Hello, world!'])
4848
})

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

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -111,34 +111,31 @@ export default (Commands: Cypress.Cypress['Commands'], Cypress: Cypress.Cypress,
111111
if (Cypress.config('experimentalPromptCommand')) {
112112
let initializeCloudCyPromptPromise = initializeCloudCyPrompt(Cypress, cy)
113113

114-
// cy.prompt
115-
const prompt = (steps: string[], commandOptions: object = {}) => {
116-
const promptCmd = cy.state('current')
117-
118-
return cy.wrap(initializeCloudCyPromptPromise, { log: false, timeout: 45000 }).then((bundleResult: Awaited<ReturnType<typeof initializeCloudCyPrompt>>) => {
119-
if (bundleResult instanceof Error) {
120-
throw bundleResult
121-
}
122-
123-
const cyPrompt = bundleResult
124-
125-
return cyPrompt({
126-
steps,
127-
commandOptions,
128-
promptCmd,
114+
const commands = {
115+
prompt (steps: string[], commandOptions: object = {}) {
116+
const promptCmd = cy.state('current')
117+
118+
return cy.wrap(initializeCloudCyPromptPromise, { log: false, timeout: 45000 }).then((bundleResult: Awaited<ReturnType<typeof initializeCloudCyPrompt>>) => {
119+
if (bundleResult instanceof Error) {
120+
throw bundleResult
121+
}
122+
123+
const cyPrompt = bundleResult
124+
125+
return cyPrompt({
126+
steps,
127+
commandOptions,
128+
promptCmd,
129+
})
129130
})
130-
})
131+
},
131132
}
132133

133-
// For testing purposes, we can reset the prompt command initialization
134-
// by calling the __reset method.
135-
prompt.__reset = () => {
134+
commands.prompt['__resetPrompt'] = () => {
136135
initializedModule = null
137136
initializeCloudCyPromptPromise = initializeCloudCyPrompt(Cypress, cy)
138137
}
139138

140-
Commands.addAll({
141-
prompt,
142-
})
139+
Commands.addAll(commands)
143140
}
144141
}

packages/reporter/src/commands/command.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ const Command: React.FC<CommandProps> = observer(({ model, aliasesWithDuplicates
534534
<CommandDetails model={model} groupId={groupId} aliasesWithDuplicates={aliasesWithDuplicates} />
535535
<CommandControls model={model} commandName={commandName} />
536536
</div>
537-
{model.isCyPrompt && (model.state === 'passed' || model.state === 'failed') && (
537+
{model.isCyPrompt && model.state === 'passed' && (
538538
<div className='command-prompt-get-code' onClick={(e) => {
539539
e.stopPropagation()
540540
events.emit('prompt:get-code', { testId: model.testId, logId: model.id })

0 commit comments

Comments
 (0)