From 5ce1e0516f158b1a2548e619152c205e5f73a611 Mon Sep 17 00:00:00 2001 From: Daniel Rafailov Date: Sun, 20 Sep 2026 15:27:13 -0400 Subject: [PATCH 1/3] Added test case for getGraphJSON when graph is not found in database --- .../Controllers/GraphControllerTests.hs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/backend-test/Controllers/GraphControllerTests.hs b/backend-test/Controllers/GraphControllerTests.hs index b960e0064..5a8f55fc4 100644 --- a/backend-test/Controllers/GraphControllerTests.hs +++ b/backend-test/Controllers/GraphControllerTests.hs @@ -207,9 +207,28 @@ runGetGraphJSONTest (label, (texts', shapes', paths')) = assertEqual ("Shapes differ for " ++ label) shapes' (map (\shape -> shape{shapeGraph = toSqlKey 1}) parsedShapes) assertEqual ("Paths differ for " ++ label) paths' (map (\path -> path{pathGraph = toSqlKey 1}) parsedPaths) +-- | Run a specific test case that verifies the behaviour of getGraphJSON when graphName does not correspond to a graph in the database. +testGraphNotFound :: TestTree +testGraphNotFound = + let label = "Graph not found returns empty components" + in testCase label $ do + let graphName = "Test Graph Name" + runDb clearDatabase + response <- + runServerPartWith Controllers.Graph.getGraphJSON $ + mockGetRequest "/get-json-data" [("graphName", T.unpack graphName)] "" + let body = rsBody response + let jsonObj = parseGraphComponentsJSON body + case jsonObj of + Nothing -> assertFailure ("Maybe ([Text], [Shape], [Path]) returned as Nothing for " ++ label) + Just (parsedTexts, parsedShapes, parsedPaths) -> do + assertEqual ("Texts differ for " ++ label) [] parsedTexts + assertEqual ("Shapes differ for " ++ label) [] parsedShapes + assertEqual ("Paths differ for " ++ label) [] parsedPaths + -- | Run all getGraphJSON tests runGetGraphJSONTests :: [TestTree] -runGetGraphJSONTests = map runGetGraphJSONTest getGraphJSONTestCases +runGetGraphJSONTests = map runGetGraphJSONTest getGraphJSONTestCases ++ [testGraphNotFound] -- | Test suite for Graph Controller Module test_graphController :: TestTree From 7ce8f866023e398baf8ebb833a1630c6c986eb1d Mon Sep 17 00:00:00 2001 From: Daniel Rafailov Date: Sun, 20 Sep 2026 15:32:41 -0400 Subject: [PATCH 2/3] added changes to Changelog file --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d0dfa517..908a209f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### 🔧 Internal changes +- Added a test case for the getGraphJSON function in `Controllers/Graph` - Migrated JS package manager from yarn to pnpm - Updated `react-leaflet` to v5.0.0 and `@eslint/compat` to v2.1.0 - Added peer dependency overrides for `eslint-plugin-react` (for `eslint` v10) and `@babel/plugin-syntax-*` (for `@babel/core` v8.0.1 From 50e4ed17810b1db499a1ed519cac79fd9b2553e1 Mon Sep 17 00:00:00 2001 From: Daniel Rafailov Date: Sun, 20 Sep 2026 15:34:32 -0400 Subject: [PATCH 3/3] Added my name to the list of contributors --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9aef5c4ed..35b6ed208 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ Mia Meng, Christine Murad, Justin Park, Harsh Patel, +Daniel Rafailov, Eleonora Scognamiglio, Sam Shaftoe, Ian Stewart-Binks,