Skip to content

Commit 822dd39

Browse files
feat: tests added and updated after new item at the menu
1 parent 6984da1 commit 822dd39

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

src/header/hooks.test.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ describe('header utils', () => {
100100
ENABLE_CERTIFICATE_PAGE: 'true',
101101
});
102102
const actualItems = renderHook(() => useSettingMenuItems('course-123'), { wrapper: createWrapper() }).result.current;
103-
expect(actualItems).toHaveLength(6);
103+
expect(actualItems).toHaveLength(7);
104104
});
105105
it('when certificate page disabled should not include certificates option', () => {
106106
setConfig({
107107
...getConfig(),
108108
ENABLE_CERTIFICATE_PAGE: 'false',
109109
});
110110
const actualItems = renderHook(() => useSettingMenuItems('course-123'), { wrapper: createWrapper() }).result.current;
111-
expect(actualItems).toHaveLength(5);
111+
expect(actualItems).toHaveLength(6);
112112
});
113113
it('when user has access to advanced settings should include advanced settings option', () => {
114114
const actualItemsTitle = renderHook(() => useSettingMenuItems('course-123'), { wrapper: createWrapper() }).result.current.map((item) => item.title);
@@ -163,6 +163,19 @@ describe('header utils', () => {
163163
expect(actualItemsTitle).not.toContain('Advanced Settings');
164164
});
165165
});
166+
167+
it('should include roles and permissions option', () => {
168+
setConfig({
169+
...getConfig(),
170+
ADMIN_CONSOLE_URL: 'http://admin-console.example.com',
171+
});
172+
const actualItems = renderHook(() => useSettingMenuItems('course-123'), { wrapper: createWrapper() }).result.current;
173+
const rolesPermissionsItem = actualItems.find(item => item.title === 'Roles and Permissions');
174+
expect(rolesPermissionsItem).toEqual({
175+
href: 'http://admin-console.example.com/authz?scope=course-123',
176+
title: 'Roles and Permissions',
177+
});
178+
});
166179
});
167180

168181
describe('getToolsMenuItems', () => {

src/studio-home/StudioHome.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as reactRedux from 'react-redux';
2+
import { getConfig, setConfig } from '@edx/frontend-platform';
23

34
import {
45
fireEvent,
@@ -91,6 +92,18 @@ describe('<StudioHome />', () => {
9192
within(header).getByRole('button', { name: 'New course' }); // will error if not found
9293
});
9394

95+
it('should render roles and permissions button', async () => {
96+
setConfig({
97+
...getConfig(),
98+
ADMIN_CONSOLE_URL: 'https://admin-console.example.com',
99+
});
100+
101+
render(<StudioHome />, { path: '/home' });
102+
const header = getHeaderElement();
103+
const rolesButton = within(header).getByRole('link', { name: 'Roles and permissions' });
104+
expect(rolesButton).toHaveAttribute('href', 'https://admin-console.example.com/authz');
105+
});
106+
94107
it('should show verify email layout if user inactive', async () => {
95108
mockUseSelector.mockReturnValue({
96109
...studioHomeMock,

src/studio-home/messages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const messages = defineMessages({
1616
addRolesPermissionsBtnText: {
1717
id: 'course-authoring.studio-home.add-roles-permissions.btn.text',
1818
defaultMessage: 'Roles and permissions',
19+
description: 'Text for the button that links to the Admin Console Roles and Permissions page.',
1920
},
2021
homePageLoadFailedMessage: {
2122
id: 'course-authoring.studio-home.page-load.failed.message',

0 commit comments

Comments
 (0)