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
20052150
Commit
20052150
authored
Jan 31, 2018
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: Move tests from Permissions to AddPermissions #10676
parent
1b9e02e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
2 deletions
+80
-2
public/app/core/components/Permissions/AddPermissions.jest.tsx
+79
-0
public/app/core/components/Permissions/AddPermissions.tsx
+1
-1
public/app/core/components/Picker/UserPicker.tsx
+0
-1
No files found.
public/app/core/components/Permissions/AddPermissions.jest.tsx
0 → 100644
View file @
20052150
import
React
from
'react'
;
import
AddPermissions
from
'./AddPermissions'
;
import
{
RootStore
}
from
'app/stores/RootStore/RootStore'
;
import
{
backendSrv
}
from
'test/mocks/common'
;
import
{
shallow
}
from
'enzyme'
;
describe
(
'AddPermissions'
,
()
=>
{
let
wrapper
;
beforeAll
(()
=>
{
backendSrv
.
get
.
mockReturnValue
(
Promise
.
resolve
([
{
id
:
2
,
dashboardId
:
1
,
role
:
'Viewer'
,
permission
:
1
,
permissionName
:
'View'
},
{
id
:
3
,
dashboardId
:
1
,
role
:
'Editor'
,
permission
:
1
,
permissionName
:
'Edit'
},
{
id
:
4
,
dashboardId
:
1
,
userId
:
2
,
userLogin
:
'danlimerick'
,
userEmail
:
'dan.limerick@gmail.com'
,
permission
:
4
,
permissionName
:
'Admin'
,
},
])
);
backendSrv
.
post
=
jest
.
fn
();
const
store
=
RootStore
.
create
(
{},
{
backendSrv
:
backendSrv
,
}
);
// wrapper = shallow(<Permissions backendSrv={backendSrv} isFolder={true} dashboardId={1} {...store} />);
wrapper
=
shallow
(<
AddPermissions
permissions=
{
store
.
permissions
}
backendSrv=
{
backendSrv
}
dashboardId=
{
1
}
/>);
//<AddPermissions permissions={permissions} backendSrv={backendSrv} dashboardId={dashboardId} />
// return wrapper.instance().loadStore(1, true);
});
describe
(
'when permission for a user is added'
,
()
=>
{
it
(
'should save permission to db'
,
async
()
=>
{
const
evt
=
{
target
:
{
value
:
'User'
,
},
};
const
userItem
=
{
id
:
2
,
login
:
'user2'
,
};
const
instance
=
wrapper
.
instance
();
instance
.
typeChanged
(
evt
);
instance
.
userPicked
(
userItem
);
wrapper
.
find
(
'[data-save-permission]'
).
simulate
(
'click'
);
expect
(
backendSrv
.
post
.
mock
.
calls
.
length
).
toBe
(
1
);
expect
(
backendSrv
.
post
.
mock
.
calls
[
0
][
0
]).
toBe
(
'/api/dashboards/id/1/acl'
);
});
});
// describe('when permission for team is added', () => {
// it('should save permission to db', () => {
// const teamItem = {
// id: 2,
// name: 'ug1',
// };
// wrapper
// .instance()
// .teamPicked(teamItem)
// .then(() => {
// expect(backendSrv.post.mock.calls.length).toBe(1);
// expect(backendSrv.post.mock.calls[0][0]).toBe('/api/dashboards/id/1/acl');
// });
// });
// });
});
public/app/core/components/Permissions/AddPermissions.tsx
View file @
20052150
...
...
@@ -124,7 +124,7 @@ class AddPermissions extends Component<IProps, any> {
</
div
>
<
div
className=
"gf-form"
>
<
button
className=
"btn btn-success"
type=
"submit"
disabled=
{
!
newItem
.
isValid
()
}
>
<
button
data
-
save
-
permission
className=
"btn btn-success"
type=
"submit"
disabled=
{
!
newItem
.
isValid
()
}
>
Save
</
button
>
</
div
>
...
...
public/app/core/components/Picker/UserPicker.tsx
View file @
20052150
...
...
@@ -55,7 +55,6 @@ class UserPicker extends Component<IProps, any> {
render
()
{
const
AsyncComponent
=
this
.
state
.
creatable
?
Select
.
AsyncCreatable
:
Select
.
Async
;
const
{
isLoading
,
handlePicked
,
value
}
=
this
.
props
;
console
.
log
(
'value'
,
value
);
return
(
<
div
className=
"user-picker"
>
<
AsyncComponent
...
...
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