@@ -19,6 +19,8 @@ import Language.Haskell.LSP.Types
1919import qualified Language.Haskell.LSP.Types.Lens as L
2020import qualified Language.Haskell.LSP.Types.Capabilities as C
2121import Test.Hls.Util
22+ import Test.Hspec.Expectations
23+
2224import Test.Tasty
2325import Test.Tasty.ExpectedFailure (ignoreTestBecause , expectFailBecause )
2426import Test.Tasty.HUnit
@@ -293,17 +295,19 @@ redundantImportTests = testGroup "redundant import code actions" [
293295 runSession hlsCommand fullCaps " test/testdata/redundantImportTest/" $ do
294296 doc <- openDoc " src/CodeActionRedundant.hs" " haskell"
295297
296- diags <- waitForDiagnosticsFrom doc
298+ diags <- waitForDiagnosticsFromSource doc " typecheck "
297299 liftIO $ expectDiagnostic diags [" The import of" , " Data.List" , " is redundant" ]
298300
299301 mActions <- getAllCodeActions doc
300302
301- let allActions@ [removeAction, removeAllAction, makeAllExplicitAction] = map fromAction mActions
303+ let allActions = map fromAction mActions
304+ actionTitles = map (view L. title) allActions
305+
306+ liftIO $ actionTitles `shouldContain` [" Remove import" , " Remove all redundant imports" ]
307+
308+ let Just removeAction = find (\ x -> x ^. L. title == " Remove import" ) allActions
302309
303310 liftIO $ do
304- removeAction ^. L. title @?= " Remove import"
305- removeAllAction ^. L. title @?= " Remove all redundant imports"
306- makeAllExplicitAction ^. L. title @?= " Make all imports explicit"
307311 forM_ allActions $ \ a -> a ^. L. kind @?= Just CodeActionQuickFix
308312 forM_ allActions $ \ a -> a ^. L. command @?= Nothing
309313 forM_ allActions $ \ a -> isJust (a ^. L. edit) @? " Has edit"
@@ -318,7 +322,7 @@ redundantImportTests = testGroup "redundant import code actions" [
318322
319323 , testCase " doesn't touch other imports" $ runSession hlsCommand noLiteralCaps " test/testdata/redundantImportTest/" $ do
320324 doc <- openDoc " src/MultipleImports.hs" " haskell"
321- _ <- waitForDiagnosticsFrom doc
325+ _ <- waitForDiagnosticsFromSource doc " typecheck "
322326 CACommand cmd : _ <- getAllCodeActions doc
323327 executeCommand cmd
324328 contents <- documentContents doc
0 commit comments