mirror of https://github.com/grafana/grafana
Merge pull request #10719 from grafana/add_permissions_10676
Grafana 5.0: Add permissions modal for the permissions pagespull/10722/head
commit
22a349051c
@ -1,73 +0,0 @@ |
||||
import React from 'react'; |
||||
import Permissions from './Permissions'; |
||||
import { RootStore } from 'app/stores/RootStore/RootStore'; |
||||
import { backendSrv } from 'test/mocks/common'; |
||||
import { shallow } from 'enzyme'; |
||||
|
||||
describe('Permissions', () => { |
||||
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} />); |
||||
return wrapper.instance().loadStore(1, true); |
||||
}); |
||||
|
||||
describe('when permission for a user is added', () => { |
||||
it('should save permission to db', () => { |
||||
const userItem = { |
||||
id: 2, |
||||
login: 'user2', |
||||
}; |
||||
|
||||
wrapper |
||||
.instance() |
||||
.userPicked(userItem) |
||||
.then(() => { |
||||
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'); |
||||
}); |
||||
}); |
||||
}); |
||||
}); |
@ -0,0 +1,98 @@ |
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP |
||||
|
||||
exports[`TeamPicker renders correctly 1`] = ` |
||||
<div |
||||
className="user-picker" |
||||
> |
||||
<div |
||||
className="Select gf-form-input gf-form-input--form-dropdown is-clearable is-loading is-searchable Select--single" |
||||
style={undefined} |
||||
> |
||||
<div |
||||
className="Select-control" |
||||
onKeyDown={[Function]} |
||||
onMouseDown={[Function]} |
||||
onTouchEnd={[Function]} |
||||
onTouchMove={[Function]} |
||||
onTouchStart={[Function]} |
||||
style={undefined} |
||||
> |
||||
<span |
||||
className="Select-multi-value-wrapper" |
||||
id="react-select-2--value" |
||||
> |
||||
<div |
||||
className="Select-placeholder" |
||||
> |
||||
Loading... |
||||
</div> |
||||
<div |
||||
className="Select-input" |
||||
style={ |
||||
Object { |
||||
"display": "inline-block", |
||||
} |
||||
} |
||||
> |
||||
<input |
||||
aria-activedescendant="react-select-2--value" |
||||
aria-describedby={undefined} |
||||
aria-expanded="false" |
||||
aria-haspopup="false" |
||||
aria-label={undefined} |
||||
aria-labelledby={undefined} |
||||
aria-owns="" |
||||
className={undefined} |
||||
id={undefined} |
||||
onBlur={[Function]} |
||||
onChange={[Function]} |
||||
onFocus={[Function]} |
||||
required={false} |
||||
role="combobox" |
||||
style={ |
||||
Object { |
||||
"boxSizing": "content-box", |
||||
"width": "5px", |
||||
} |
||||
} |
||||
tabIndex={undefined} |
||||
value="" |
||||
/> |
||||
<div |
||||
style={ |
||||
Object { |
||||
"height": 0, |
||||
"left": 0, |
||||
"overflow": "scroll", |
||||
"position": "absolute", |
||||
"top": 0, |
||||
"visibility": "hidden", |
||||
"whiteSpace": "pre", |
||||
} |
||||
} |
||||
> |
||||
|
||||
</div> |
||||
</div> |
||||
</span> |
||||
<span |
||||
aria-hidden="true" |
||||
className="Select-loading-zone" |
||||
> |
||||
<span |
||||
className="Select-loading" |
||||
/> |
||||
</span> |
||||
<span |
||||
className="Select-arrow-zone" |
||||
onMouseDown={[Function]} |
||||
> |
||||
<span |
||||
className="Select-arrow" |
||||
onMouseDown={[Function]} |
||||
/> |
||||
</span> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
`; |
Loading…
Reference in new issue