packages feed

ihp-ide 1.5.0 → 1.5.1

raw patch · 4 files changed

+187/−1 lines, 4 files

Files

+ Test/IDE/Logs/ControllerSpec.hs view
@@ -0,0 +1,118 @@+module Test.IDE.Logs.ControllerSpec where++import Test.Hspec+import IHP.Prelude+import IHP.IDE.Logs.ServiceLog++tests :: Spec+tests = do+    describe "extractProcessComposeNames" do+        it "extracts process names from a simple config" do+            let yaml =+                    [ "version: \"0.5\""+                    , "processes:"+                    , "  ihp:"+                    , "    command: start"+                    , "  esbuild:"+                    , "    command: esbuild --watch"+                    , "  tailwind:"+                    , "    command: tailwindcss --watch"+                    ]+            extractProcessComposeNames yaml `shouldBe` ["ihp", "esbuild", "tailwind"]++        it "does not pick up nested keys like command or depends_on" do+            let yaml =+                    [ "processes:"+                    , "  esbuild:"+                    , "    command: esbuild --watch"+                    , "    depends_on:"+                    , "      postgres:"+                    , "        condition: process_healthy"+                    , "  tailwind:"+                    , "    command: tailwindcss"+                    ]+            extractProcessComposeNames yaml `shouldBe` ["esbuild", "tailwind"]++        it "stops at the next top-level key" do+            let yaml =+                    [ "processes:"+                    , "  myapp:"+                    , "    command: run"+                    , "environment:"+                    , "  - FOO=bar"+                    ]+            extractProcessComposeNames yaml `shouldBe` ["myapp"]++        it "returns empty list when no processes section" do+            let yaml =+                    [ "version: \"0.5\""+                    , "environment:"+                    , "  - FOO=bar"+                    ]+            extractProcessComposeNames yaml `shouldBe` []++        it "skips comment lines inside processes" do+            let yaml =+                    [ "processes:"+                    , "  # this is a comment"+                    , "  web:"+                    , "    command: run-web"+                    ]+            extractProcessComposeNames yaml `shouldBe` ["web"]++        it "handles empty processes section" do+            let yaml =+                    [ "processes:"+                    , "other_key:"+                    , "  foo: bar"+                    ]+            extractProcessComposeNames yaml `shouldBe` []++    describe "filterServiceLines" do+        it "extracts lines for a specific service" do+            let logLines =+                    [ "esbuild  | Building..."+                    , "esbuild  | Done in 0.5s"+                    , "tailwind | Rebuilding CSS"+                    , "esbuild  | Watching for changes"+                    ]+            filterServiceLines "esbuild" logLines `shouldBe`+                [ " Building..."+                , " Done in 0.5s"+                , " Watching for changes"+                ]++        it "returns empty list when service has no log lines" do+            let logLines =+                    [ "tailwind | Rebuilding CSS"+                    , "tailwind | Done"+                    ]+            filterServiceLines "esbuild" logLines `shouldBe` []++        it "handles lines without pipe separator" do+            let logLines =+                    [ "esbuild  | Building..."+                    , "some random line"+                    , "esbuild  | Done"+                    ]+            filterServiceLines "esbuild" logLines `shouldBe`+                [ " Building..."+                , " Done"+                ]++        it "handles padded service names (process-compose format)" do+            let logLines =+                    [ "esbuild           | Starting build"+                    , "postgres          | ready to accept connections"+                    ]+            filterServiceLines "esbuild" logLines `shouldBe` [" Starting build"]+            filterServiceLines "postgres" logLines `shouldBe` [" ready to accept connections"]++    describe "filterBuiltinServices" do+        it "removes ihp and postgres" do+            filterBuiltinServices ["ihp", "esbuild", "postgres", "tailwind"]+                `shouldBe` ["esbuild", "tailwind"]++        it "is case-insensitive for builtin names" do+            filterBuiltinServices ["IHP", "Postgres", "esbuild"]+                `shouldBe` ["esbuild"]
+ Test/IDE/ToolServer/MiddlewareSpec.hs view
@@ -0,0 +1,62 @@+{-|+Module: Test.IDE.ToolServer.MiddlewareSpec+Tests for ToolServer middleware stack.++This test verifies that the ToolServer middleware stack correctly includes+requestBodyMiddleware, which is required for controllers to read form params.++The test uses the actual 'buildToolServerApplication' function from ToolServer,+so if any required middleware is accidentally removed, this test will fail.+-}+module Test.IDE.ToolServer.MiddlewareSpec where++import IHP.Prelude+import Test.Hspec+import Network.Wai+import Network.Wai.Test+import Network.HTTP.Types+import qualified Data.ByteString.Lazy as LBS++import IHP.IDE.ToolServer (withToolServerApplication, ToolServerApplicationWithConfig(..))+import IHP.IDE.ToolServer.Types+import qualified System.Environment as Env+import Network.Socket (PortNumber)+import qualified System.Directory as Directory+import qualified Data.Map as Map++-- | Create a new ToolServerApplication with empty IORefs+newToolServerApplication :: PortNumber -> IO ToolServerApplication+newToolServerApplication appPort = do+    appStandardOutput <- newIORef []+    appErrorOutput <- newIORef []+    databaseNeedsMigration <- newIORef False+    pure ToolServerApplication {..}++-- | Build the test application once for all tests+buildTestApp :: IO Application+buildTestApp = do+    Directory.createDirectoryIfMissing True "Config"+    Env.setEnv "IHP_STATIC" "."+    toolServerApp <- newToolServerApplication 8000+    liveReloadClients <- newIORef Map.empty+    withToolServerApplication toolServerApp 8000 liveReloadClients \weightedApp ->+        pure weightedApp.application++tests :: Spec+tests = beforeAll buildTestApp $ do+    describe "ToolServer Middleware Stack" $ do+        it "includes requestBodyMiddleware so controllers can parse form params" $ \app -> do+            response <- runSession (postWithParams "/Migrations/CreateMigration" [("description", "test"), ("createOnly", "true")]) app+            let body = cs (simpleBody response) :: Text+            body `shouldNotSatisfy` ("lookupRequestVault" `isInfixOf`)+            body `shouldNotSatisfy` ("Could not find RequestBody" `isInfixOf`)++postWithParams :: ByteString -> [(ByteString, ByteString)] -> Session SResponse+postWithParams path params = srequest $ SRequest req (LBS.fromStrict $ renderSimpleQuery False params)+  where+    req = defaultRequest+        { requestMethod = methodPost+        , pathInfo = filter (/= "") $ decodePathSegments path+        , rawPathInfo = path+        , requestHeaders = [(hContentType, "application/x-www-form-urlencoded")]+        }
changelog.md view
@@ -1,5 +1,9 @@ # Changelog for `ihp-ide` +## v1.5.1++- Restore missing test sources in sdist: `Test.IDE.ToolServer.MiddlewareSpec` and `Test.IDE.Logs.ControllerSpec` were imported by `Test/Main.hs` but not declared in the cabal `test-suite > other-modules`, so they were excluded from the Hackage tarball and broke downstream builds (e.g. nixpkgs). No source changes — manifest fix only.+ ## v1.5.0  - Add PostgreSQL table inheritance (`INHERITS`) support in Schema Designer
ihp-ide.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.2 name:                ihp-ide-version:             1.5.0+version:             1.5.1 synopsis:            Dev tools for IHP description:         The Integrated Haskell Platform is a full stack framework focused on rapid application development while striving for robust code quality. license:             MIT@@ -343,4 +343,6 @@         Test.IDE.SchemaDesigner.SchemaOperationsSpec         Test.IDE.CodeGeneration.MigrationGenerator         Test.SchemaCompilerSpec+        Test.IDE.ToolServer.MiddlewareSpec+        Test.IDE.Logs.ControllerSpec         Test.ServerSpec