Skip to content

Commit 9df5e24

Browse files
committed
refactor: update types import
1 parent 3d11ffc commit 9df5e24

11 files changed

Lines changed: 25 additions & 207 deletions

File tree

src/authz-module/audit-user/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
} from '@src/authz-module/components/TableCells';
2323
import { useQuerySettings } from '@src/authz-module/hooks/useQuerySettings';
2424
import { useRevokeUserRoles, useUserAssignedRoles } from '@src/authz-module/data/hooks';
25-
import { RoleToDelete } from 'types';
25+
import { RoleToDelete } from '@src/types';
2626
import { useToastManager } from '@src/components/ToastManager/ToastManagerContext';
2727
import UserPermissions from '@src/authz-module/components/UserPermissions';
2828
import OrgFilter from '@src/authz-module/components/TableControlBar/OrgFilter';

src/authz-module/components/RenderPermissionColumn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Icon } from '@openedx/paragon';
2-
import { PermissionMetadata, ResourceMetadata } from 'types';
2+
import { PermissionMetadata, ResourceMetadata } from '@src/types';
33
import ResourceTooltip from './ResourceTooltip';
44

55
export type PermissionItem = ResourceMetadata & {

src/authz-module/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PermissionMetadata, ResourceMetadata, Role } from 'types';
1+
import { PermissionMetadata, ResourceMetadata, Role } from '@src/types';
22
import {
33
School, LibraryBooks, Article, Group, LocalOffer,
44
BookOpen,

src/authz-module/data/hooks.test.tsx

Lines changed: 15 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -87,42 +87,6 @@ const mockOrgs = {
8787
],
8888
};
8989

90-
const mockScopes = {
91-
count: 2,
92-
next: null,
93-
previous: null,
94-
results: [
95-
{
96-
externalKey: 'course-v1:OpenedX+DemoX+DemoCourse',
97-
displayName: 'Open edX Demo Course',
98-
org: {
99-
id: 1,
100-
created: '2026-04-02T19:30:36.779095Z',
101-
modified: '2026-04-02T19:30:36.779095Z',
102-
name: 'OpenedX',
103-
shortName: 'OpenedX',
104-
description: '',
105-
logo: null,
106-
active: true,
107-
},
108-
},
109-
{
110-
externalKey: 'lib:WGU:CSPROB',
111-
displayName: 'Computer Science Problems',
112-
org: {
113-
id: 2,
114-
created: '2026-04-02T19:31:21.196446Z',
115-
modified: '2026-04-02T19:31:21.196446Z',
116-
name: 'WGU',
117-
shortName: 'WGU',
118-
description: '',
119-
logo: null,
120-
active: true,
121-
},
122-
},
123-
],
124-
};
125-
12690
const mockQuerySettings: QuerySettings = {
12791
roles: null,
12892
scopes: null,
@@ -558,26 +522,33 @@ describe('useScopes', () => {
558522
await waitFor(() => expect(result.current.isError).toBe(true));
559523
expect(result.current.error).toBeDefined();
560524
});
525+
526+
it('handles search parameter', async () => {
527+
mockHttpClient().mockReturnValue({
528+
get: jest.fn().mockResolvedValue({ data: makeScopesResponse() }),
529+
});
530+
531+
const { result } = renderHook(() => useScopes({ search: 'library' }), { wrapper: createWrapper() });
532+
533+
await waitFor(() => expect(result.current.isSuccess).toBe(true));
534+
expect(result.current.data?.pages[0].results).toHaveLength(1);
535+
});
561536
});
562537

563538
describe('useOrgs', () => {
564539
beforeEach(() => {
565540
jest.clearAllMocks();
566541
});
567542

568-
const mockOrgsResult = [{
569-
id: 1, name: 'Org One', shortName: 'org1', description: '', logo: null, active: true,
570-
}];
571-
572543
it('returns organizations on success', async () => {
573544
mockHttpClient().mockReturnValue({
574-
get: jest.fn().mockResolvedValue({ data: { results: mockOrgsResult } }),
545+
get: jest.fn().mockResolvedValue({ data: mockOrgs }),
575546
});
576547

577548
const { result } = renderHook(() => useOrgs(), { wrapper: createWrapper() });
578549

579550
await waitFor(() => expect(result.current.isSuccess).toBe(true));
580-
expect(result.current.data?.results).toEqual(mockOrgsResult);
551+
expect(result.current.data?.results).toEqual(mockOrgs.results);
581552
});
582553

583554
it('handles error when API fails', async () => {
@@ -789,16 +760,7 @@ describe('useAllRoleAssignments', () => {
789760

790761
it('fetches and returns role assignments', async () => {
791762
const { result } = renderHook(
792-
() => useAllRoleAssignments({
793-
roles: null,
794-
scopes: null,
795-
organizations: null,
796-
search: null,
797-
order: null,
798-
sortBy: null,
799-
pageSize: 10,
800-
pageIndex: 0,
801-
}),
763+
() => useAllRoleAssignments(mockQuerySettings),
802764
{ wrapper: createWrapper() },
803765
);
804766
await waitFor(() => {
@@ -817,16 +779,7 @@ describe('useAllRoleAssignments', () => {
817779
})),
818780
});
819781
const { result } = renderHook(
820-
() => useAllRoleAssignments({
821-
roles: null,
822-
scopes: null,
823-
organizations: null,
824-
search: null,
825-
order: null,
826-
sortBy: null,
827-
pageSize: 10,
828-
pageIndex: 0,
829-
}),
782+
() => useAllRoleAssignments(mockQuerySettings),
830783
{ wrapper: createWrapper() },
831784
);
832785
await waitFor(() => {
@@ -836,70 +789,6 @@ describe('useAllRoleAssignments', () => {
836789
});
837790
});
838791

839-
describe('useOrgs', () => {
840-
beforeEach(() => {
841-
mockHttpClient().mockReturnValue({
842-
get: jest.fn(() => Promise.resolve({ data: mockOrgs })),
843-
});
844-
});
845-
846-
it('fetches and returns organizations', async () => {
847-
const { result } = renderHook(() => useOrgs(), { wrapper: createWrapper() });
848-
await waitFor(() => {
849-
expect(result.current.data?.results).toHaveLength(2);
850-
expect(result.current.data?.results[0].name).toBe('Organization 1');
851-
expect(result.current.data?.count).toBe(2);
852-
});
853-
});
854-
855-
it('handles empty results', async () => {
856-
mockHttpClient().mockReturnValueOnce({
857-
get: jest.fn(() => Promise.resolve({
858-
data: {
859-
count: 0, next: null, previous: null, results: [],
860-
},
861-
})),
862-
});
863-
const { result } = renderHook(() => useOrgs(), { wrapper: createWrapper() });
864-
await waitFor(() => {
865-
expect(result.current.data?.results).toEqual([]);
866-
expect(result.current.data?.count).toBe(0);
867-
});
868-
});
869-
});
870-
871-
describe('useScopes', () => {
872-
beforeEach(() => {
873-
mockHttpClient().mockReturnValue({
874-
get: jest.fn(() => Promise.resolve({ data: mockScopes })),
875-
});
876-
});
877-
878-
it('fetches and returns scopes', async () => {
879-
const { result } = renderHook(() => useScopes(), { wrapper: createWrapper() });
880-
await waitFor(() => {
881-
expect(result.current.data?.pages[0].results).toHaveLength(2);
882-
expect(result.current.data?.pages[0].results[0].displayName).toBe('Open edX Demo Course');
883-
expect(result.current.data?.pages[0].count).toBe(2);
884-
});
885-
});
886-
887-
it('handles empty results', async () => {
888-
mockHttpClient().mockReturnValueOnce({
889-
get: jest.fn(() => Promise.resolve({
890-
data: {
891-
count: 0, next: null, previous: null, results: [],
892-
},
893-
})),
894-
});
895-
const { result } = renderHook(() => useScopes(), { wrapper: createWrapper() });
896-
await waitFor(() => {
897-
expect(result.current.data?.pages[0].results).toEqual([]);
898-
expect(result.current.data?.pages[0].count).toBe(0);
899-
});
900-
});
901-
});
902-
903792
describe('useUserAssignedRoles', () => {
904793
beforeEach(() => {
905794
jest.clearAllMocks();
@@ -1026,74 +915,3 @@ describe('useUserAssignedRoles', () => {
1026915
expect(mockGet).toHaveBeenCalledTimes(2);
1027916
});
1028917
});
1029-
1030-
describe('useScopes', () => {
1031-
const mockScopesData = {
1032-
count: 2,
1033-
next: null,
1034-
previous: null,
1035-
results: [
1036-
{
1037-
displayName: 'Test Library 1',
1038-
scope: 'lib:test-library-1',
1039-
},
1040-
{
1041-
displayName: 'Test Course 1',
1042-
scope: 'course:test-course-1',
1043-
},
1044-
],
1045-
};
1046-
1047-
beforeEach(() => {
1048-
jest.clearAllMocks();
1049-
});
1050-
1051-
it('returns scopes when API call succeeds', async () => {
1052-
mockHttpClient().mockReturnValue({
1053-
get: jest.fn().mockResolvedValue({ data: mockScopesData }),
1054-
});
1055-
1056-
const { result } = renderHook(() => useScopes(), {
1057-
wrapper: createWrapper(),
1058-
});
1059-
1060-
await waitFor(() => expect(result.current.isSuccess).toBe(true));
1061-
1062-
expect(getAuthenticatedHttpClient).toHaveBeenCalled();
1063-
expect(result.current.data?.pages[0]).toEqual(mockScopesData);
1064-
expect(result.current.data?.pages[0].results).toHaveLength(2);
1065-
});
1066-
1067-
it('handles search parameter', async () => {
1068-
mockHttpClient().mockReturnValue({
1069-
get: jest.fn().mockResolvedValue({
1070-
data: {
1071-
count: 1, next: null, previous: null, results: [mockScopesData.results[0]],
1072-
},
1073-
}),
1074-
});
1075-
1076-
const { result } = renderHook(() => useScopes({ search: 'library' }), {
1077-
wrapper: createWrapper(),
1078-
});
1079-
1080-
await waitFor(() => expect(result.current.isSuccess).toBe(true));
1081-
expect(result.current.data?.pages[0].results).toHaveLength(1);
1082-
});
1083-
1084-
it('handles error when API call fails', async () => {
1085-
mockHttpClient().mockReturnValue({
1086-
get: jest.fn().mockRejectedValue(new Error('API failure')),
1087-
});
1088-
1089-
const { result } = renderHook(() => useScopes(), {
1090-
wrapper: createWrapper(),
1091-
});
1092-
1093-
await waitFor(() => expect(result.current.isError).toBe(true));
1094-
1095-
expect(getAuthenticatedHttpClient).toHaveBeenCalled();
1096-
expect(result.current.error).toBeDefined();
1097-
expect(result.current.data).toBeUndefined();
1098-
});
1099-
});

src/authz-module/role-assignation-wizard/AssignRoleWizard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
Stepper, Button, StatefulButton, Icon,
77
} from '@openedx/paragon';
88
import { SpinnerSimple } from '@openedx/paragon/icons';
9-
import { RoleMetadata } from 'types';
9+
import { RoleMetadata } from '@src/types';
1010
import { useToastManager } from '@src/components/ToastManager/ToastManagerContext';
1111
import SelectUsersAndRoleStep from './components/SelectUsersAndRoleStep';
1212
import DefineApplicationScopeStep from './components/DefineApplicationScopeStep';

src/authz-module/role-assignation-wizard/components/OrgSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState } from 'react';
22
import { Icon } from '@openedx/paragon';
33
import { ExpandLess, ExpandMore } from '@openedx/paragon/icons';
44
import { useIntl } from '@edx/frontend-platform/i18n';
5-
import { Scope } from 'types';
5+
import { Scope } from '@src/types';
66
import messages from '../messages';
77
import ScopeCheckboxItem from './ScopeCheckboxItem';
88

src/authz-module/role-assignation-wizard/components/ScopeCheckboxItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Form } from '@openedx/paragon';
2-
import { Scope } from 'types';
2+
import { Scope } from '@src/types';
33

44
interface ScopeCheckboxItemProps {
55
scope: Scope;

src/authz-module/role-assignation-wizard/components/ScopeList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useRef } from 'react';
22
import { Spinner } from '@openedx/paragon';
33
import { useIntl } from '@edx/frontend-platform/i18n';
4-
import { Org, Scope } from 'types';
4+
import { Org, Scope } from '@src/types';
55
import OrgSection from './OrgSection';
66
import ScopeCheckboxItem from './ScopeCheckboxItem';
77
import messages from '../messages';

src/authz-module/role-assignation-wizard/components/SelectUsersAndRoleStep.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Tooltip,
66
} from '@openedx/paragon';
77
import { getConfig } from '@edx/frontend-platform';
8-
import { RoleMetadata } from 'types';
8+
import { RoleMetadata } from '@src/types';
99
import HighlightedUsersInput from './HighlightedUsersInput';
1010
import messages from '../messages';
1111

src/authz-module/roles-permissions/course/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PermissionMetadata, ResourceMetadata, RoleMetadata } from 'types';
1+
import { PermissionMetadata, ResourceMetadata, RoleMetadata } from '@src/types';
22
import {
33
LibraryBooks, Article, Group, LocalOffer,
44
BookOpen,

0 commit comments

Comments
 (0)