Skip to content

Commit ce86f1b

Browse files
feat: string displayNumber added to courses list (#3141)
1 parent 61c7c58 commit ce86f1b

2 files changed

Lines changed: 74 additions & 2 deletions

File tree

src/studio-home/tabs-section/courses-tab/index.test.tsx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,74 @@ describe('<CoursesTab />', () => {
156156
const state = store.getState();
157157
expect(state.studioHome.studioHomeCoursesRequestParams).toStrictEqual(studioHomeCoursesRequestParamsDefault);
158158
});
159+
160+
it('should render displayNumber in the card subtitle when it is provided', () => {
161+
const courseWithDisplayNumber = {
162+
...studioHomeMock.courses[0],
163+
number: '123',
164+
displayNumber: 'DISP-999',
165+
};
166+
const customStoreData = {
167+
studioHomeData: {
168+
courses: [courseWithDisplayNumber],
169+
numPages: 1,
170+
coursesCount: 1,
171+
},
172+
};
173+
renderComponent({}, customStoreData);
174+
expect(screen.getByText(/DISP-999/)).toBeInTheDocument();
175+
expect(screen.queryByText(/\/ 123 \//)).not.toBeInTheDocument();
176+
});
177+
178+
it('should fall back to number in the card subtitle when displayNumber is empty', () => {
179+
const courseWithEmptyDisplayNumber = {
180+
...studioHomeMock.courses[0],
181+
number: '123',
182+
displayNumber: '',
183+
};
184+
const customStoreData = {
185+
studioHomeData: {
186+
courses: [courseWithEmptyDisplayNumber],
187+
numPages: 1,
188+
coursesCount: 1,
189+
},
190+
};
191+
renderComponent({}, customStoreData);
192+
expect(screen.getByText(/\/ 123 \//)).toBeInTheDocument();
193+
});
194+
195+
it('should render displayOrg in the card subtitle when it is provided', () => {
196+
const courseWithDisplayOrg = {
197+
...studioHomeMock.courses[0],
198+
org: 'HarvardX',
199+
displayOrg: 'Harvard University',
200+
};
201+
const customStoreData = {
202+
studioHomeData: {
203+
courses: [courseWithDisplayOrg],
204+
numPages: 1,
205+
coursesCount: 1,
206+
},
207+
};
208+
renderComponent({}, customStoreData);
209+
expect(screen.getByText(/Harvard University \//)).toBeInTheDocument();
210+
expect(screen.queryByText(/HarvardX \//)).not.toBeInTheDocument();
211+
});
212+
213+
it('should fall back to org in the card subtitle when displayOrg is empty', () => {
214+
const courseWithEmptyDisplayOrg = {
215+
...studioHomeMock.courses[0],
216+
org: 'HarvardX',
217+
displayOrg: '',
218+
};
219+
const customStoreData = {
220+
studioHomeData: {
221+
courses: [courseWithEmptyDisplayOrg],
222+
numPages: 1,
223+
coursesCount: 1,
224+
},
225+
};
226+
renderComponent({}, customStoreData);
227+
expect(screen.getByText(/HarvardX \//)).toBeInTheDocument();
228+
});
159229
});

src/studio-home/tabs-section/courses-tab/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ const CardList = ({
8383
displayName,
8484
lmsLink,
8585
org,
86+
displayOrg,
8687
rerunLink,
8788
number,
89+
displayNumber,
8890
run,
8991
url,
9092
}) => (
@@ -96,8 +98,8 @@ const CardList = ({
9698
displayName={displayName}
9799
lmsLink={lmsLink}
98100
rerunLink={rerunLink}
99-
org={org}
100-
number={number}
101+
org={displayOrg || org}
102+
number={displayNumber || number}
101103
run={run}
102104
url={url}
103105
selectMode={inSelectMode ? 'single' : undefined}

0 commit comments

Comments
 (0)