Skip to content

Commit 11d9fa3

Browse files
committed
test: update role assignment tests and improve mock implementations
1 parent 71230b9 commit 11d9fa3

6 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/authz-module/libraries-manager/LibrariesUserManager.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ describe('LibrariesUserManager', () => {
251251
await user.click(realButton || assignRoleButtons[0]);
252252

253253
expect(mockNavigate).toHaveBeenCalledWith(
254-
'/authz/assign-role?scope=lib:123&users=testuser',
254+
'/authz/assign-role?users=testuser&from=%2Fauthz%2Flibraries%2Flib%3A123%2Ftestuser',
255255
);
256256
});
257257
});

src/authz-module/wizard/AssignRoleWizard.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ jest.mock('@edx/frontend-platform/auth', () => ({
1010
getAuthenticatedUser: jest.fn(),
1111
}));
1212

13+
jest.mock('@edx/frontend-platform/logging', () => ({
14+
logError: jest.fn(),
15+
}));
16+
1317
jest.mock('../data/hooks', () => ({
1418
useValidateUsers: jest.fn(),
1519
useAssignTeamMembersRole: jest.fn(),

src/authz-module/wizard/AssignRoleWizardPage.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ jest.mock('react-router-dom', () => ({
1414

1515
jest.mock('../data/hooks', () => ({
1616
useValidateUsers: jest.fn(),
17+
useAssignTeamMembersRole: jest.fn(() => ({
18+
mutate: jest.fn(),
19+
mutateAsync: jest.fn(),
20+
isPending: false,
21+
isError: false,
22+
isSuccess: false,
23+
})),
1724
}));
1825

1926
jest.mock('@edx/frontend-component-header', () => ({

src/authz-module/wizard/useScopeListData.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ describe('useScopeListData', () => {
195195
}));
196196

197197
const org1Scopes = result.current.scopesByOrg.org1;
198-
// Scopes are returned in API order - no sorting applied
198+
// Note: API returns scopes in whatever order - no sorting applied by this hook
199199
expect(org1Scopes[0].displayName).toBe('Library 1');
200200
expect(org1Scopes[1].displayName).toBe('All libraries in org1');
201201
});

src/authz-module/wizard/useScopePermissions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { renderHook } from '@testing-library/react';
22
import { useValidateUserPermissions } from '@src/data/hooks';
3-
import { CONTENT_LIBRARY_PERMISSIONS } from 'authz-module/libraries-manager/constants';
3+
import { CONTENT_LIBRARY_PERMISSIONS } from '../libraries-manager/constants';
44
import { useOrganizations } from '../data/hooks';
55
import { COURSE_PERMISSIONS } from '../constants';
66
import useScopePermissions from './useScopePermissions';

src/authz-module/wizard/useScopePermissions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useMemo } from 'react';
22
import { useValidateUserPermissions } from '@src/data/hooks';
3-
import { CONTENT_LIBRARY_PERMISSIONS } from 'authz-module/libraries-manager/constants';
3+
import { CONTENT_LIBRARY_PERMISSIONS } from '../libraries-manager/constants';
44
import { useOrganizations } from '../data/hooks';
55
import { COURSE_PERMISSIONS } from '../constants';
66

0 commit comments

Comments
 (0)