@@ -14,6 +14,7 @@ import { OutputChannel } from '../vscode/outputChannel'
1414import { Title } from '../vscode/title'
1515import { Args } from '../cli/dvc/constants'
1616import { findOrCreateDvcYamlFile , getFileExtension } from '../fileSystem'
17+ import { Toast } from '../vscode/toast'
1718
1819const mockedShowWebview = jest . fn ( )
1920const mockedDisposable = jest . mocked ( Disposable )
@@ -595,5 +596,38 @@ describe('Experiments', () => {
595596 mockedDvcRoot
596597 )
597598 } )
599+
600+ it ( 'should show a toast if the dvc.yaml file is invalid' , async ( ) => {
601+ const showErrorSpy = jest . spyOn ( Toast , 'showError' )
602+
603+ mockedQuickPickOne . mockResolvedValueOnce ( mockedDvcRoot )
604+ mockedListStages . mockResolvedValueOnce ( undefined )
605+
606+ await workspaceExperiments . getCwdThenRun ( mockedCommandId )
607+
608+ expect ( showErrorSpy ) . toHaveBeenCalledWith (
609+ 'Cannot perform task. Your dvc.yaml file is invalid.'
610+ )
611+ } )
612+
613+ it ( 'should not ask to create a stage if the dvc.yaml file is invalid' , async ( ) => {
614+ mockedQuickPickOne . mockResolvedValueOnce ( mockedDvcRoot )
615+ mockedListStages . mockResolvedValueOnce ( undefined )
616+
617+ await workspaceExperiments . getCwdThenRun ( mockedCommandId )
618+
619+ expect ( mockedGetValidInput ) . not . toHaveBeenCalled ( )
620+ } )
621+
622+ it ( 'should not show a toast if the dvc.yaml file is valid' , async ( ) => {
623+ const showErrorSpy = jest . spyOn ( Toast , 'showError' )
624+
625+ mockedQuickPickOne . mockResolvedValueOnce ( mockedDvcRoot )
626+ mockedListStages . mockResolvedValueOnce ( 'train' )
627+
628+ await workspaceExperiments . getCwdThenRun ( mockedCommandId )
629+
630+ expect ( showErrorSpy ) . not . toHaveBeenCalled ( )
631+ } )
598632 } )
599633} )
0 commit comments