Skip to content

Commit 68244d7

Browse files
committed
fix: add type for contextType and fix RolePermissions test typing
1 parent 849a6cb commit 68244d7

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/authz-module/roles-permissions/RolesPermissions.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jest.mock('./course/constants', () => ({
2525
],
2626
coursePermissions: [],
2727
courseResourceTypes: [],
28+
courseRolesMetadata: [],
2829
}));
2930

3031
jest.mock('./library/constants', () => ({
@@ -35,6 +36,7 @@ jest.mock('./library/constants', () => ({
3536
],
3637
libraryPermissions: [],
3738
libraryResourceTypes: [],
39+
libraryRolesMetadata: [],
3840
}));
3941

4042
jest.mock('@openedx/paragon', () => ({

src/authz-module/roles-permissions/library/utils.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createIntl } from '@edx/frontend-platform/i18n';
2+
import type { Role } from '@src/types';
23
import { buildPermissionMatrixByResource } from './utils';
34

45
const intl = createIntl({ locale: 'en', messages: {} });
@@ -14,15 +15,15 @@ const permissions = [
1415
const resources = [
1516
{ key: 'library', label: 'Library', description: '' },
1617
];
17-
const roles = [
18+
const roles: Role[] = [
1819
{
19-
name: 'admin', permissions: ['create_library', 'edit_library'], userCount: 2, role: 'admin', description: '', contextType: '', scope: '',
20+
name: 'admin', permissions: ['create_library', 'edit_library'], userCount: 2, role: 'admin', description: '', contextType: 'library', scope: '',
2021
},
2122
{
22-
name: 'editor', permissions: ['edit_library'], userCount: 2, role: 'editor', description: '', contextType: '', scope: '',
23+
name: 'editor', permissions: ['edit_library'], userCount: 2, role: 'editor', description: '', contextType: 'library', scope: '',
2324
},
2425
{
25-
name: 'guest', permissions: [], userCount: 2, role: 'guest', description: '', contextType: '', scope: '',
26+
name: 'guest', permissions: [], userCount: 2, role: 'guest', description: '', contextType: 'library', scope: '',
2627
},
2728
];
2829

src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ export interface LibraryMetadata {
2727
allowPublicRead: boolean;
2828
}
2929

30+
export type ContextType = 'course' | 'library';
31+
3032
export interface RoleMetadata {
3133
role: string;
3234
name: string;
3335
description: string;
34-
contextType: string;
36+
contextType: ContextType;
3537
disabled?: boolean;
3638
}
3739
// TODO: remove unnecessary fields when libraries gets removed

0 commit comments

Comments
 (0)