|
@@ -11,27 +11,27 @@ describe('PermissionsStore', () => {
|
|
|
{ id: 3, dashboardId: 1, role: 'Editor', permission: 1, permissionName: 'Edit' },
|
|
{ id: 3, dashboardId: 1, role: 'Editor', permission: 1, permissionName: 'Edit' },
|
|
|
{
|
|
{
|
|
|
id: 4,
|
|
id: 4,
|
|
|
- dashboardId: 10,
|
|
|
|
|
|
|
+ dashboardId: 1,
|
|
|
permission: 1,
|
|
permission: 1,
|
|
|
permissionName: 'View',
|
|
permissionName: 'View',
|
|
|
teamId: 1,
|
|
teamId: 1,
|
|
|
- teamName: 'MyTestTeam',
|
|
|
|
|
|
|
+ team: 'MyTestTeam',
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
id: 5,
|
|
id: 5,
|
|
|
- dashboardId: 10,
|
|
|
|
|
|
|
+ dashboardId: 1,
|
|
|
permission: 1,
|
|
permission: 1,
|
|
|
permissionName: 'View',
|
|
permissionName: 'View',
|
|
|
userId: 1,
|
|
userId: 1,
|
|
|
- userName: 'MyTestUser',
|
|
|
|
|
|
|
+ userLogin: 'MyTestUser',
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
id: 6,
|
|
id: 6,
|
|
|
- dashboardId: 10,
|
|
|
|
|
|
|
+ dashboardId: 1,
|
|
|
permission: 1,
|
|
permission: 1,
|
|
|
permissionName: 'Edit',
|
|
permissionName: 'Edit',
|
|
|
teamId: 2,
|
|
teamId: 2,
|
|
|
- teamName: 'MyTestTeam2',
|
|
|
|
|
|
|
+ team: 'MyTestTeam2',
|
|
|
},
|
|
},
|
|
|
])
|
|
])
|
|
|
);
|
|
);
|
|
@@ -48,15 +48,12 @@ describe('PermissionsStore', () => {
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- console.log(store);
|
|
|
|
|
-
|
|
|
|
|
await store.load(1, false, false);
|
|
await store.load(1, false, false);
|
|
|
- console.log(store);
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should save update on permission change', async () => {
|
|
it('should save update on permission change', async () => {
|
|
|
expect(store.items[0].permission).toBe(1);
|
|
expect(store.items[0].permission).toBe(1);
|
|
|
- expect(store.items[0].permissionName).toBe('View');
|
|
|
|
|
|
|
+ expect(store.items[0].permissionName).toBe('Edit');
|
|
|
|
|
|
|
|
await store.updatePermissionOnIndex(0, 2, 'Edit');
|
|
await store.updatePermissionOnIndex(0, 2, 'Edit');
|
|
|
|
|
|
|
@@ -67,15 +64,20 @@ describe('PermissionsStore', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should save removed permissions automatically', async () => {
|
|
it('should save removed permissions automatically', async () => {
|
|
|
- expect(store.items.length).toBe(3);
|
|
|
|
|
|
|
+ expect(store.items.length).toBe(5);
|
|
|
|
|
|
|
|
await store.removeStoreItem(2);
|
|
await store.removeStoreItem(2);
|
|
|
|
|
|
|
|
- expect(store.items.length).toBe(2);
|
|
|
|
|
|
|
+ expect(store.items.length).toBe(4);
|
|
|
expect(backendSrv.post.mock.calls.length).toBe(1);
|
|
expect(backendSrv.post.mock.calls.length).toBe(1);
|
|
|
expect(backendSrv.post.mock.calls[0][0]).toBe('/api/dashboards/id/1/permissions');
|
|
expect(backendSrv.post.mock.calls[0][0]).toBe('/api/dashboards/id/1/permissions');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ it('should be sorted by sort rank and alphabetically', async () => {
|
|
|
|
|
+ expect(store.items[3].name).toBe('MyTestTeam2');
|
|
|
|
|
+ expect(store.items[4].name).toBe('MyTestUser');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
describe('when one inherited and one not inherited team permission are added', () => {
|
|
describe('when one inherited and one not inherited team permission are added', () => {
|
|
|
beforeEach(async () => {
|
|
beforeEach(async () => {
|
|
|
const overridingItemForChildDashboard = {
|
|
const overridingItemForChildDashboard = {
|
|
@@ -92,7 +94,7 @@ describe('PermissionsStore', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should add new overriding permission', () => {
|
|
it('should add new overriding permission', () => {
|
|
|
- expect(store.items.length).toBe(4);
|
|
|
|
|
|
|
+ expect(store.items.length).toBe(6);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|