Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b56e2a61
Commit
b56e2a61
authored
Feb 20, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
folders: basic integration tests for folders
parent
ea7998ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
1 deletions
+95
-1
tests/api/folder.test.ts
+78
-0
tests/api/setup.ts
+17
-1
No files found.
tests/api/folder.test.ts
0 → 100644
View file @
b56e2a61
import
client
from
'./client'
;
import
*
as
setup
from
'./setup'
;
describe
(
'/api/folders'
,
()
=>
{
let
state
:
any
=
{};
beforeAll
(
async
()
=>
{
state
=
await
setup
.
ensureState
({
orgName
:
'api-test-org'
,
users
:
[
{
user
:
setup
.
admin
,
role
:
'Admin'
},
{
user
:
setup
.
editor
,
role
:
'Editor'
},
{
user
:
setup
.
viewer
,
role
:
'Viewer'
},
],
admin
:
setup
.
admin
,
folders
:
[
{
title
:
'Folder 1'
,
uid
:
'f-01'
,
},
{
title
:
'Folder 2'
,
uid
:
'f-02'
,
},
{
title
:
'Folder 3'
,
uid
:
'f-03'
,
},
],
});
});
describe
(
'With admin user'
,
()
=>
{
it
(
'can delete folder'
,
async
()
=>
{
let
rsp
=
await
client
.
callAs
(
setup
.
admin
).
delete
(
`/api/folders/f-01`
);
expect
(
rsp
.
data
.
title
).
toBe
(
'Folder 1'
);
});
it
(
'can update folder'
,
async
()
=>
{
let
rsp
=
await
client
.
callAs
(
setup
.
admin
).
put
(
`/api/folders/f-02`
,
{
uid
:
'f-02'
,
title
:
'Folder 2 upd'
,
overwrite
:
true
,
});
expect
(
rsp
.
data
.
title
).
toBe
(
'Folder 2 upd'
);
});
it
(
'can update folder uid'
,
async
()
=>
{
let
rsp
=
await
client
.
callAs
(
setup
.
admin
).
put
(
`/api/folders/f-03`
,
{
uid
:
'f-03-upd'
,
title
:
'Folder 3 upd'
,
overwrite
:
true
,
});
expect
(
rsp
.
data
.
uid
).
toBe
(
'f-03-upd'
);
expect
(
rsp
.
data
.
title
).
toBe
(
'Folder 3 upd'
);
});
});
describe
(
'With viewer user'
,
()
=>
{
it
(
'Cannot delete folder'
,
async
()
=>
{
let
rsp
=
await
setup
.
expectError
(()
=>
{
return
client
.
callAs
(
setup
.
viewer
).
delete
(
`/api/folders/f-02`
);
});
expect
(
rsp
.
response
.
status
).
toBe
(
403
);
});
it
(
'Cannot update folder'
,
async
()
=>
{
let
rsp
=
await
setup
.
expectError
(()
=>
{
return
client
.
callAs
(
setup
.
viewer
).
put
(
`/api/folders/f-02`
,
{
uid
:
'f-02'
,
title
:
'Folder 2 upd'
,
overwrite
:
true
,
});
});
expect
(
rsp
.
response
.
status
).
toBe
(
403
);
});
});
});
tests/api/setup.ts
View file @
b56e2a61
...
...
@@ -90,6 +90,18 @@ export async function createDashboard(user, dashboard) {
return
dashboard
;
}
export
async
function
createFolder
(
user
,
folder
)
{
const
rsp
=
await
client
.
callAs
(
user
).
post
(
`/api/folders`
,
{
uid
:
folder
.
uid
,
title
:
folder
.
title
,
overwrite
:
true
,
});
folder
.
id
=
rsp
.
id
;
folder
.
url
=
rsp
.
url
;
return
folder
;
}
export
async
function
ensureState
(
state
)
{
const
org
=
await
getOrg
(
state
.
orgName
);
...
...
@@ -99,9 +111,13 @@ export async function ensureState(state) {
await
setUsingOrg
(
user
,
org
);
}
for
(
let
dashboard
of
state
.
dashboards
)
{
for
(
let
dashboard
of
state
.
dashboards
||
[]
)
{
await
createDashboard
(
state
.
admin
,
dashboard
);
}
for
(
let
folder
of
state
.
folders
||
[])
{
await
createFolder
(
state
.
admin
,
folder
);
}
return
state
;
}
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