Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
149
Issues
149
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
b9f48672
Commit
b9f48672
authored
Apr 08, 2024
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GQL NodeType tests
parent
9393b00a
Pipeline
#5887
passed with stages
in 76 minutes and 38 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
Node.hs
src/Gargantext/API/GraphQL/Node.hs
+8
-2
GraphQL.hs
test/Test/API/GraphQL.hs
+9
-3
No files found.
src/Gargantext/API/GraphQL/Node.hs
View file @
b9f48672
...
...
@@ -22,6 +22,7 @@ import Gargantext.API.Admin.Auth.Types
import
Gargantext.API.Auth.PolicyCheck
import
Gargantext.API.GraphQL.PolicyCheck
(
withPolicy
)
import
Gargantext.API.GraphQL.Types
import
Gargantext.Core
import
Gargantext.Database.Admin.Types.Node
(
NodeType
)
import
Gargantext.Database.Admin.Types.Node
qualified
as
NN
import
Gargantext.Database.Prelude
(
CmdCommon
)
-- , JSONB)
...
...
@@ -43,6 +44,7 @@ data Node = Node
,
name
::
Text
,
parent_id
::
Maybe
Int
,
type_id
::
Int
,
node_type
::
Maybe
NodeType
}
deriving
(
Show
,
Generic
,
GQLType
)
data
CorpusArgs
...
...
@@ -113,10 +115,14 @@ dbParentNodes node_id parent_type = do
pure
[
toNode
node
]
toNode
::
NN
.
Node
json
->
Node
toNode
N
.
Node
{
..
}
=
Node
{
id
=
NN
.
unNodeId
_node_
id
toNode
N
.
Node
{
..
}
=
Node
{
id
=
n
id
,
name
=
_node_name
,
parent_id
=
NN
.
unNodeId
<$>
_node_parent_id
,
type_id
=
_node_typename
}
,
type_id
=
_node_typename
,
node_type
=
lookupDBid
nid
}
where
nid
=
NN
.
unNodeId
_node_id
toCorpus
::
NN
.
Node
Value
->
Corpus
toCorpus
N
.
Node
{
..
}
=
Corpus
{
id
=
NN
.
unNodeId
_node_id
...
...
test/Test/API/GraphQL.hs
View file @
b9f48672
...
...
@@ -19,10 +19,9 @@ import Text.RawString.QQ (r)
tests
::
Spec
tests
=
sequential
$
aroundAll
withTestDBAndPort
$
do
describe
"Prelude"
$
do
it
"setup DB triggers"
$
\
((
testEnv
,
_
),
_
)
->
setupEnvironment
testEnv
describe
"GraphQL"
$
do
describe
"Prelude"
$
do
it
"setup DB triggers"
$
\
((
testEnv
,
_
),
_
)
->
setupEnvironment
testEnv
describe
"get_user_infos"
$
do
it
"allows 'alice' to see her own info"
$
\
((
testEnv
,
port
),
app
)
->
do
...
...
@@ -34,6 +33,13 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
let
expected
=
[
json
|
{"data":{"user_infos":[{"ui_id":2,"ui_email":"alice@gargan.text"}]}}
|]
protected
token
"POST"
"/gql"
query
`
shouldRespondWithFragment
`
expected
describe
"nodes"
$
do
it
"returns node_type"
$
\
((
_testEnv
,
port
),
app
)
->
do
withApplication
app
$
do
withValidLogin
port
"gargantua"
(
GargPassword
"secret_key"
)
$
\
token
->
do
let
query
=
[
r
|
{ "query": "{ nodes(node_id: 2) { node_type } }" }
|]
let
expected
=
[
json
|
{"data":{"nodes":[{"node_type":"NodeFolder"}]}}
|]
protected
token
"POST"
"/gql"
query
`
shouldRespondWithFragment
`
expected
describe
"check error format"
$
do
it
"returns the new error if header X-Garg-Error-Scheme: new is passed"
$
\
((
_testEnv
,
port
),
app
)
->
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment