From 54c5590b9bd6b4fd97275d83bfde99b140d2e90a Mon Sep 17 00:00:00 2001 From: Binod Pant Date: Wed, 2 Jun 2021 14:27:54 -0400 Subject: [PATCH] feat: Add partner column, show first partner only, for now (#567) * feat: Add partner column, show first partner only, for now ENT-4608 * feat: partner name is next to course now. for better UX * feat: Test fix test fix --- .../BulkEnrollmentPage/CourseSearchResults.jsx | 5 +++++ .../CourseSearchResults.test.jsx | 15 +++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/BulkEnrollmentPage/CourseSearchResults.jsx b/src/components/BulkEnrollmentPage/CourseSearchResults.jsx index 224bab284b..9b4396a664 100644 --- a/src/components/BulkEnrollmentPage/CourseSearchResults.jsx +++ b/src/components/BulkEnrollmentPage/CourseSearchResults.jsx @@ -27,6 +27,7 @@ export const ENROLL_TEXT = 'Enroll learners'; export const TABLE_HEADERS = { courseName: 'Course name', courseStartDate: 'Course start date', + partnerName: 'Partner', enroll: '', }; @@ -90,6 +91,10 @@ export const BaseCourseSearchResults = (props) => { // eslint-disable-next-line react/prop-types Cell: ({ value, row }) => , }, + { + Header: TABLE_HEADERS.partnerName, + accessor: 'partners[0].name', + }, { Header: TABLE_HEADERS.courseStartDate, accessor: 'advertised_course_run.start', diff --git a/src/components/BulkEnrollmentPage/CourseSearchResults.test.jsx b/src/components/BulkEnrollmentPage/CourseSearchResults.test.jsx index 273def45e2..84ef60e814 100644 --- a/src/components/BulkEnrollmentPage/CourseSearchResults.test.jsx +++ b/src/components/BulkEnrollmentPage/CourseSearchResults.test.jsx @@ -39,6 +39,7 @@ const searchResults = { start: testStartDate, }, key: 'foo', + partners: [{ name: 'edX' }, { name: 'another_unused' }], }, ], page: 3, @@ -108,17 +109,19 @@ describe('', () => { // Four header columns, one for sorting, one for Course Name, one for Course Run, one for the enroll column const tableHeaderCells = wrapper.find('TableHeaderCell'); - expect(tableHeaderCells.length).toBe(4); + expect(tableHeaderCells.length).toBe(5); expect(tableHeaderCells.at(1).prop('Header')).toBe(TABLE_HEADERS.courseName); - expect(tableHeaderCells.at(2).prop('Header')).toBe(TABLE_HEADERS.courseStartDate); - expect(tableHeaderCells.at(3).prop('Header')).toBe(''); + expect(tableHeaderCells.at(2).prop('Header')).toBe(TABLE_HEADERS.partnerName); + expect(tableHeaderCells.at(3).prop('Header')).toBe(TABLE_HEADERS.courseStartDate); + expect(tableHeaderCells.at(4).prop('Header')).toBe(''); // Three table cells, one for sorting, one title, one course run const tableCells = wrapper.find('TableCell'); - expect(tableCells.length).toBe(4); + expect(tableCells.length).toBe(5); expect(tableCells.at(1).text()).toBe(testCourseName); - expect(tableCells.at(2).text()).toBe('Sep 10, 2020'); - expect(tableCells.at(3).find(EnrollButton)).toHaveLength(1); + expect(tableCells.at(2).text()).toBe('edX'); + expect(tableCells.at(3).text()).toBe('Sep 10, 2020'); + expect(tableCells.at(4).find(EnrollButton)).toHaveLength(1); }); it('displays search pagination', () => { const wrapper = mount();