mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
feat(dashboard_rbac): manage roles for dashboard (#13145)
* feat(dashboard_rbac): manage roles for dashboard * test: fix tests * fix: fix empty roles Co-authored-by: Amit Miran <47772523+amitmiran137@users.noreply.github.com>
This commit is contained in:
@@ -38,6 +38,7 @@ const dashboardResult = {
|
||||
slug: '/new',
|
||||
json_metadata: '{"something":"foo"}',
|
||||
owners: [],
|
||||
roles: [],
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -54,6 +55,7 @@ fetchMock.get('glob:*/api/v1/dashboard/*', {
|
||||
slug: '/new',
|
||||
json_metadata: '{"something":"foo"}',
|
||||
owners: [],
|
||||
roles: [],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -207,6 +209,7 @@ describe('PropertiesModal', () => {
|
||||
slug: '/new',
|
||||
json_metadata: '{"something":"foo"}',
|
||||
owners: [{ id: 1, first_name: 'Al', last_name: 'Pacino' }],
|
||||
roles: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -219,6 +222,27 @@ describe('PropertiesModal', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('should call onRolesChange', async () => {
|
||||
const wrapper = setup();
|
||||
const modalInstance = wrapper.find('PropertiesModal').instance();
|
||||
const fetchSpy = jest.spyOn(SupersetClient, 'get').mockResolvedValue({
|
||||
json: {
|
||||
result: {
|
||||
dashboard_title: 'New Title',
|
||||
slug: '/new',
|
||||
json_metadata: '{"something":"foo"}',
|
||||
owners: [],
|
||||
roles: [{ id: 1, name: 'Alpha' }],
|
||||
},
|
||||
},
|
||||
});
|
||||
const onRolwesSpy = jest.spyOn(modalInstance, 'onRolesChange');
|
||||
modalInstance.fetchDashboardDetails();
|
||||
await fetchSpy();
|
||||
expect(modalInstance.state.values.colorScheme).toBeUndefined();
|
||||
expect(onRolwesSpy).toHaveBeenCalledWith([{ value: 1, label: 'Alpha' }]);
|
||||
});
|
||||
|
||||
describe('when colorScheme is undefined as a prop', () => {
|
||||
describe('when color_scheme is defined in json_metadata', () => {
|
||||
const wrapper = setup();
|
||||
|
||||
Reference in New Issue
Block a user