Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Mia Meng,
Christine Murad,
Justin Park,
Harsh Patel,
Daniel Rafailov,
Eleonora Scognamiglio,
Sam Shaftoe,
Ian Stewart-Binks,
Expand Down
21 changes: 20 additions & 1 deletion backend-test/Controllers/GraphControllerTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading