Skip to content

Commit 6214e8f

Browse files
fix: some refactor and fixes
1 parent 8f8069d commit 6214e8f

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/course-home/dates-tab/DatesTab.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { sendTrackEvent } from '@edx/frontend-platform/analytics';
44
import { useIntl } from '@edx/frontend-platform/i18n';
55

66
import { MAIN_CONTENT_ID } from '@src/constants';
7+
import { useScrollToContent } from '@src/generic/hooks';
78
import messages from './messages';
89
import Timeline from './timeline/Timeline';
910

@@ -14,7 +15,6 @@ import SuggestedScheduleHeader from '../suggested-schedule-messaging/SuggestedSc
1415
import ShiftDatesAlert from '../suggested-schedule-messaging/ShiftDatesAlert';
1516
import UpgradeToCompleteAlert from '../suggested-schedule-messaging/UpgradeToCompleteAlert';
1617
import UpgradeToShiftDatesAlert from '../suggested-schedule-messaging/UpgradeToShiftDatesAlert';
17-
import { useScrollToContent } from '../../generic/hooks';
1818

1919
const DatesTab = () => {
2020
const intl = useIntl();

src/courseware/course/sequence/sequence-navigation/UnitButton.test.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
waitFor,
1010
} from '../../../../setupTest';
1111
import UnitButton from './UnitButton';
12+
import messages from './messages';
1213

1314
describe('Unit Button', () => {
1415
let mockData;
@@ -112,7 +113,7 @@ describe('Unit Button', () => {
112113
const { container } = render(
113114
<>
114115
<UnitButton {...mockData} />
115-
<button id="bookmark-button" type="button">Bookmark</button>
116+
<button id="bookmark-button" type="button">{messages.bookmark.defaultMessage}</button>
116117
</>,
117118
{ wrapWithRouter: true },
118119
);
@@ -136,7 +137,7 @@ describe('Unit Button', () => {
136137
const { container } = render(
137138
<>
138139
<UnitButton {...mockData} onClick={onClick} />
139-
<button id="bookmark-button" type="button">Bookmark</button>
140+
<button id="bookmark-button" type="button">{messages.bookmark.defaultMessage}</button>
140141
</>,
141142
{ wrapWithRouter: true },
142143
);

src/courseware/course/sequence/sequence-navigation/messages.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const messages = defineMessages({
1616
defaultMessage: 'Previous',
1717
description: 'Button to return to the previous section',
1818
},
19+
bookmark: {
20+
id: 'learning.generic.bookmark',
21+
defaultMessage: 'Bookmark',
22+
description: 'Button text for bookmarking',
23+
},
1924
});
2025

2126
export default messages;

src/generic/hooks.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('Hooks', () => {
6363
test('should scroll to target element and focus', async () => {
6464
render(<TestComponent />);
6565

66-
const skipLink = screen.getByRole('link', { name: /skip to content/i });
66+
const skipLink = screen.getByRole('link', { name: new RegExp(messages.skipToContent.defaultMessage, 'i') });
6767
const targetContent = screen.getByTestId('target-content');
6868

6969
targetContent.focus = jest.fn();
@@ -114,7 +114,7 @@ describe('Hooks', () => {
114114

115115
render(<ComponentWithoutTarget />);
116116

117-
const skipLink = screen.getByRole('link', { name: /skip to content/i });
117+
const skipLink = screen.getByRole('link', { name: new RegExp(messages.skipToContent.defaultMessage, 'i') });
118118

119119
await userEvent.click(skipLink);
120120

0 commit comments

Comments
 (0)