-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw explicit exception when group children is not found. (#1010)
* Improve server error when group children is not found. Previously this was a DictionaryKeyNotFoundException, but now I add the Id of the group component to make it easier to debug (especially if someone has emtpy string as id) * Refactor and add tests * Go for 100% coverage (and don't reference page before it is availible)
- Loading branch information
Showing
4 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...pp.Core.Tests/LayoutExpressions/CommonTests/shared-tests/invalid/group-missing-child.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "Group with missing child gives error", | ||
"expectsFailure": "*missing-child*", | ||
"expression": ["dataModel", "a"], | ||
"layouts": { | ||
"Page1": { | ||
"$schema": "https://altinncdn.no/schemas/json/layout/layout.schema.v1.json", | ||
"data": { | ||
"layout": [ | ||
{ | ||
"id": "current-component", | ||
"type": "group", | ||
"children": [ | ||
"missing-child" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...Core.Tests/LayoutExpressions/CommonTests/shared-tests/invalid/two-components-same-id.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "Two components with same id gives error", | ||
"expectsFailure": "*duplicate-id*", | ||
"expression": ["dataModel", "a"], | ||
"layouts": { | ||
"Page1": { | ||
"$schema": "https://altinncdn.no/schemas/json/layout/layout.schema.v1.json", | ||
"data": { | ||
"layout": [ | ||
{ | ||
"id": "duplicate-id", | ||
"type": "Input" | ||
}, | ||
{ | ||
"id": "duplicate-id", | ||
"type": "Input" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
....Core.Tests/LayoutExpressions/CommonTests/shared-tests/invalid/two-groups-same-child.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "Two groups trying to reference the same child", | ||
"expectsFailure": "*double-referenced-child*", | ||
"expression": ["dataModel", "a"], | ||
"layouts": { | ||
"Page1": { | ||
"$schema": "https://altinncdn.no/schemas/json/layout/layout.schema.v1.json", | ||
"data": { | ||
"layout": [ | ||
{ | ||
"id": "group1", | ||
"type": "group", | ||
"children": [ | ||
"double-referenced-child" | ||
] | ||
}, | ||
{ | ||
"id": "group2", | ||
"type": "group", | ||
"children": [ | ||
"double-referenced-child" | ||
] | ||
}, | ||
{ | ||
"id": "double-referenced-child", | ||
"type": "Input" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |