Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cwelements
Manage
Activity
Members
Labels
Plan
Issues
17
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
cwelements
Merge requests
!99
[test] add readonly test
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
[test] add readonly test
topic/default/test_useQuery_readonly
into
branch/default
Overview
0
Commits
1
Pipelines
1
Changes
1
Merged
Elodie Thiéblin
requested to merge
topic/default/test_useQuery_readonly
into
branch/default
4 years ago
Overview
0
Commits
1
Pipelines
1
Changes
1
Expand
0
0
Merge request reports
Compare
branch/default
branch/default (base)
and
latest version
latest version
4d9133f7
1 commit,
4 years ago
1 file
+
30
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
tests/useQuery.test.tsx
+
30
−
0
Options
@@ -39,4 +39,34 @@ describe('useQuery', () => {
});
expect
(
result
.
current
.
resultsAndVariables
.
results
.
status
).
toBe
(
'
error
'
);
});
it
(
'
should return an error in query is insert in readonly mode
'
,
async
()
=>
{
const
queryRows
=
(
query
:
string
)
=>
{
return
Promise
.
resolve
(
'
Error in your query
'
);
};
rqlClient
.
queryRows
=
queryRows
.
bind
(
rqlClient
);
const
{
result
}
=
renderHook
(()
=>
useQuery
({
rqlClient
,
readonly
:
true
})
);
act
(()
=>
{
result
.
current
.
setQuery
(
'
INSERT 123 name "toto"
'
);
});
await
act
(
async
()
=>
{
await
result
.
current
.
executeQuery
();
});
expect
(
result
.
current
.
resultsAndVariables
.
results
.
status
).
toBe
(
'
error
'
);
expect
(
result
.
current
.
isForbiddenQuery
).
toBe
(
true
);
act
(()
=>
{
result
.
current
.
setQuery
(
'
Any X WHERE X is Toto
'
);
});
await
act
(
async
()
=>
{
await
result
.
current
.
executeQuery
();
});
expect
(
result
.
current
.
resultsAndVariables
.
results
.
status
).
toBe
(
'
success
'
);
expect
(
result
.
current
.
isForbiddenQuery
).
toBe
(
false
);
});
});
Loading