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 @@ -19,6 +19,7 @@
- Cleared up documentation for various graph-related front-end functions
- Adopted TypeScript v7 into build and CI pipelines and converted `js/components/graph/Button.js` to `Button.tsx` as a proof of concept
- Added `.gitattributes` file to standardize to LF line endings and renormalized codebase
- Added invalid JSON graph test coverage for `saveGraphJSON` in `app/Controllers/Graph.hs`

## [0.8.1] - 2026-08-10

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Sam Shaftoe,
Ian Stewart-Binks,
Alan Su,
Maryam Taj,
Jack Tang,
Betty Wang,
Rui Weng,
Fullchee Zhang,
Expand Down
16 changes: 14 additions & 2 deletions backend-test/Controllers/GraphControllerTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,19 @@ runSaveGraphJSONTest (label, payload) =
let expectedValue = fmap addDefaults (decode payload :: Maybe Value)
assertEqual ("Unexpected response for " ++ label) expectedValue retrievedResult

-- | Run all save graph test cases
-- | Run all save graph test cases on valid inputs
runSaveGraphJSONTests :: [TestTree]
runSaveGraphJSONTests = map runSaveGraphJSONTest saveGraphJSONTestCases

-- | Run save graph test on invalid input
runSaveGraphJSONInvalidJSONTest :: TestTree
runSaveGraphJSONInvalidJSONTest = testCase "Invalid JSON graph" $ do
runDb clearDatabase
response <-
runServerPartWith Controllers.Graph.saveGraphJSON $
mockPutRequest "/graph-save" [("nameData", "Invalid Graph Name"), ("jsonData", "Invalid JSON")] ""
assertEqual "Unexpected response for invalid JSON" "Error" (BL.unpack $ rsBody response)

-- | List of test cases for getGraphJSON as (label, (texts, shapes, paths))
-- | Invariant: Expected Graph IDs are all set to 1
getGraphJSONTestCases :: [(String, ([Text], [Shape], [Path]))]
Expand Down Expand Up @@ -213,4 +222,7 @@ runGetGraphJSONTests = map runGetGraphJSONTest getGraphJSONTestCases

-- | Test suite for Graph Controller Module
test_graphController :: TestTree
test_graphController = withDatabase "Graph Controller tests" (runIndexTests ++ runSaveGraphJSONTests ++ runGetGraphJSONTests)
test_graphController =
withDatabase
"Graph Controller tests"
(runIndexTests ++ runSaveGraphJSONTests ++ [runSaveGraphJSONInvalidJSONTest] ++ runGetGraphJSONTests)
Loading