11import React from 'react'
22import Command from './command'
33import CommandModel from './command-model'
4+ import type { ErrProps } from '../errors/err-model'
45import type { SessionStatus } from '../sessions/utils'
56import type { TestState } from '@packages/types'
67import events from '../lib/events'
@@ -151,7 +152,7 @@ describe('commands', () => {
151152 cy . percySnapshot ( )
152153 } )
153154
154- it ( 'should not render prompt get code button when state is failed' , ( ) => {
155+ it ( 'should not render prompt get code button when state is failed with no error ' , ( ) => {
155156 config . withArgs ( 'experimentalPromptCommand' ) . returns ( true )
156157 cy . mount (
157158 < div >
@@ -178,6 +179,110 @@ describe('commands', () => {
178179 cy . percySnapshot ( )
179180 } )
180181
182+ it ( 'should render prompt get code button when state is failed with non-excluded error' , ( ) => {
183+ config . withArgs ( 'experimentalPromptCommand' ) . returns ( true )
184+ cy . mount (
185+ < div >
186+ < Command
187+ model = {
188+ new CommandModel ( {
189+ name : 'prompt' ,
190+ state : 'failed' ,
191+ err : { name : 'SomeOtherError' } as ErrProps ,
192+ numElements : 1 ,
193+ hookId : '1' ,
194+ id : 1 ,
195+ testId : '1' ,
196+ } )
197+ }
198+ scrollIntoView = { ( ) => { } }
199+ aliasesWithDuplicates = { [ ] }
200+ />
201+ </ div > ,
202+ )
203+
204+ cy . get ( '.command-prompt-get-code' ) . should ( 'be.visible' ) . should ( 'have.text' , 'Code' )
205+ cy . get ( '.command-prompt-get-code-indicator' ) . should ( 'be.visible' )
206+ } )
207+
208+ it ( 'should not render prompt get code button when state is failed with PromptDisabledError' , ( ) => {
209+ config . withArgs ( 'experimentalPromptCommand' ) . returns ( true )
210+ cy . mount (
211+ < div >
212+ < Command
213+ model = {
214+ new CommandModel ( {
215+ name : 'prompt' ,
216+ state : 'failed' ,
217+ err : { name : 'PromptDisabledError' } as ErrProps ,
218+ numElements : 1 ,
219+ hookId : '1' ,
220+ id : 1 ,
221+ testId : '1' ,
222+ } )
223+ }
224+ scrollIntoView = { ( ) => { } }
225+ aliasesWithDuplicates = { [ ] }
226+ />
227+ </ div > ,
228+ )
229+
230+ cy . get ( '.command-prompt-get-code' ) . should ( 'not.exist' )
231+ cy . get ( '.command-prompt-get-code-indicator' ) . should ( 'not.exist' )
232+ } )
233+
234+ it ( 'should not render prompt get code button when state is failed with PromptAuthenticationError' , ( ) => {
235+ config . withArgs ( 'experimentalPromptCommand' ) . returns ( true )
236+ cy . mount (
237+ < div >
238+ < Command
239+ model = {
240+ new CommandModel ( {
241+ name : 'prompt' ,
242+ state : 'failed' ,
243+ err : { name : 'PromptAuthenticationError' } as ErrProps ,
244+ numElements : 1 ,
245+ hookId : '1' ,
246+ id : 1 ,
247+ testId : '1' ,
248+ } )
249+ }
250+ scrollIntoView = { ( ) => { } }
251+ aliasesWithDuplicates = { [ ] }
252+ />
253+ </ div > ,
254+ )
255+
256+ cy . get ( '.command-prompt-get-code' ) . should ( 'not.exist' )
257+ cy . get ( '.command-prompt-get-code-indicator' ) . should ( 'not.exist' )
258+ } )
259+
260+ it ( 'should not render prompt get code button when state is failed with PromptUsageLimitError' , ( ) => {
261+ config . withArgs ( 'experimentalPromptCommand' ) . returns ( true )
262+ cy . mount (
263+ < div >
264+ < Command
265+ model = {
266+ new CommandModel ( {
267+ name : 'prompt' ,
268+ state : 'failed' ,
269+ err : { name : 'PromptUsageLimitError' } as ErrProps ,
270+ numElements : 1 ,
271+ hookId : '1' ,
272+ id : 1 ,
273+ testId : '1' ,
274+ } )
275+ }
276+ scrollIntoView = { ( ) => { } }
277+ aliasesWithDuplicates = { [ ] }
278+ />
279+ </ div > ,
280+ )
281+
282+ cy . get ( '.command-prompt-get-code' ) . should ( 'not.exist' )
283+ cy . get ( '.command-prompt-get-code-indicator' ) . should ( 'not.exist' )
284+ } )
285+
181286 it ( 'should not render prompt get code button when state is not passed' , ( ) => {
182287 config . withArgs ( 'experimentalPromptCommand' ) . returns ( true )
183288 cy . mount (
0 commit comments