From e65f259fd482314bf0b51c304f945e1635026b12 Mon Sep 17 00:00:00 2001 From: Nawfal Ahmed <111358247+NawfalAhmed@users.noreply.github.com> Date: Tue, 16 Apr 2024 07:45:55 +0500 Subject: [PATCH] feat: add source_system and update order no href for enrollments table (#380) --- .env | 1 + .env.development | 1 + .env.test | 1 + src/index.jsx | 1 + src/setupTest.js | 1 + src/users/enrollments/Enrollments.jsx | 21 ++++++++++++++++++++- src/users/enrollments/Enrollments.test.jsx | 21 +++++++++++++++++---- 7 files changed, 42 insertions(+), 5 deletions(-) diff --git a/.env b/.env index eb03380d0..73b56bd67 100644 --- a/.env +++ b/.env @@ -4,6 +4,7 @@ BASE_URL=null FEATURE_CONFIGURATION_MANAGEMENT='' FEATURE_CONFIGURATION_ENTERPRISE_PROVISION='' FEATURE_CONFIGURATION_EDIT_ENTERPRISE_PROVISION='' +COMMERCE_COORDINATOR_ORDER_DETAILS_URL='' CREDENTIALS_BASE_URL=null CSRF_TOKEN_API_PATH=null ECOMMERCE_BASE_URL=null diff --git a/.env.development b/.env.development index d362f9738..22d16951f 100644 --- a/.env.development +++ b/.env.development @@ -5,6 +5,7 @@ BASE_URL='http://localhost:18450' FEATURE_CONFIGURATION_MANAGEMENT='true' FEATURE_CONFIGURATION_ENTERPRISE_PROVISION='true' FEATURE_CONFIGURATION_EDIT_ENTERPRISE_PROVISION='true' +COMMERCE_COORDINATOR_ORDER_DETAILS_URL='http://localhost:8140/lms/order_details_page_redirect' CREDENTIALS_BASE_URL='http://localhost:18150' CSRF_TOKEN_API_PATH='/csrf/api/v1/token' ECOMMERCE_BASE_URL='http://localhost:18130' diff --git a/.env.test b/.env.test index 642dcbf25..90ee71a16 100644 --- a/.env.test +++ b/.env.test @@ -1,5 +1,6 @@ ACCESS_TOKEN_COOKIE_NAME='edx-jwt-cookie-header-payload' BASE_URL='localhost:1995' +COMMERCE_COORDINATOR_ORDER_DETAILS_URL='http://localhost:8140/lms/order_details_page_redirect' CREDENTIALS_BASE_URL='http://localhost:18150' CSRF_TOKEN_API_PATH='/csrf/api/v1/token' ENTERPRISE_ACCESS_BASE_URL='http://localhost:18270' diff --git a/src/index.jsx b/src/index.jsx index 076c22405..30e4ff626 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -100,6 +100,7 @@ initialize({ handlers: { config: () => { mergeConfig({ + COMMERCE_COORDINATOR_ORDER_DETAILS_URL: process.env.COMMERCE_COORDINATOR_ORDER_DETAILS_URL || null, LICENSE_MANAGER_URL: process.env.LICENSE_MANAGER_URL || null, ENTERPRISE_ACCESS_BASE_URL: process.env.ENTERPRISE_ACCESS_BASE_URL || null, FEATURE_CONFIGURATION_MANAGEMENT: process.env.FEATURE_CONFIGURATION_MANAGEMENT || hasFeatureFlagEnabled('FEATURE_CONFIGURATION_MANAGEMENT') || null, diff --git a/src/setupTest.js b/src/setupTest.js index db5a3fac9..bd3729ae8 100755 --- a/src/setupTest.js +++ b/src/setupTest.js @@ -8,6 +8,7 @@ import { MockAuthService } from '@edx/frontend-platform/auth'; Enzyme.configure({ adapter: new Adapter() }); mergeConfig({ + COMMERCE_COORDINATOR_ORDER_DETAILS_URL: process.env.COMMERCE_COORDINATOR_ORDER_DETAILS_URL || null, LICENSE_MANAGER_URL: process.env.LICENSE_MANAGER_URL, PREDEFINED_CATALOG_QUERIES: { everything: 1, diff --git a/src/users/enrollments/Enrollments.jsx b/src/users/enrollments/Enrollments.jsx index 764711045..14028d7b0 100644 --- a/src/users/enrollments/Enrollments.jsx +++ b/src/users/enrollments/Enrollments.jsx @@ -68,6 +68,7 @@ export default function Enrollments({ lastModifiedBy: enrollment.manualEnrollment && enrollment.manualEnrollment.enrolledBy ? enrollment.manualEnrollment.enrolledBy : 'N/A', reason: enrollment.manualEnrollment && enrollment.manualEnrollment.reason ? enrollment.manualEnrollment.reason : 'N/A', orderNumber: enrollment.orderNumber, + sourceSystem: enrollment.sourceSystem || 'N/A', }, enterpriseCourseEnrollments: enrollment.enterpriseCourseEnrollments?.map((ece => ({ enterpriseCustomerName: ece.enterpriseCustomerName, @@ -208,8 +209,26 @@ export default function Enrollments({ Header: 'Reason', accessor: 'reason', }, { + Header: 'Order Number', + accessor: 'orderNumber', // eslint-disable-next-line react/prop-types - Header: 'Order Number', accessor: 'orderNumber', Cell: ({ value }) => {value}, + Cell: ({ value }) => ( + + {value} + + ), + }, + { + Header: 'Source System', accessor: 'sourceSystem', }, ], [], diff --git a/src/users/enrollments/Enrollments.test.jsx b/src/users/enrollments/Enrollments.test.jsx index bdd27522d..cc83c39ed 100644 --- a/src/users/enrollments/Enrollments.test.jsx +++ b/src/users/enrollments/Enrollments.test.jsx @@ -1,11 +1,20 @@ import { mount } from 'enzyme'; import React from 'react'; +import { getConfig } from '@edx/frontend-platform'; import Enrollments from './Enrollments'; import { enrollmentsData } from '../data/test/enrollments'; import UserMessagesProvider from '../../userMessages/UserMessagesProvider'; import { waitForComponentToPaint } from '../../setupTest'; import * as api from '../data/api'; +jest.mock('@edx/frontend-platform', () => ({ + ...jest.requireActual('@edx/frontend-platform'), + getConfig: jest.fn(() => ({ + ECOMMERCE_BASE_URL: 'http://example.com', + COMMERCE_COORDINATOR_ORDER_DETAILS_URL: 'http://example.com/coordinater/', + })), +})); + const EnrollmentPageWrapper = (props) => ( @@ -101,8 +110,8 @@ describe('Course Enrollments Listing', () => { const extraDataTable = extraTables.at(0); const extraTableHeaders = extraDataTable.find('thead tr th'); - expect(extraTableHeaders.length).toEqual(4); - ['Last Modified', 'Last Modified By', 'Reason', 'Order Number'].forEach((expectedHeader, index) => expect( + expect(extraTableHeaders.length).toEqual(5); + ['Last Modified', 'Last Modified By', 'Reason', 'Order Number', 'Source System'].forEach((expectedHeader, index) => expect( extraTableHeaders.at(index).text(), ).toEqual(expectedHeader)); @@ -123,6 +132,10 @@ describe('Course Enrollments Listing', () => { }); it('Enterprise course enrollments table is not rendered if are no enterprise course enrollments', async () => { + getConfig.mockReturnValue({ + ECOMMERCE_BASE_URL: 'http://example.com', + COMMERCE_COORDINATOR_ORDER_DETAILS_URL: null, + }); const mockEnrollments = [{ ...enrollmentsData[0], enterpriseCourseEnrollments: [], @@ -146,8 +159,8 @@ describe('Course Enrollments Listing', () => { const extraDataTable = extraTables.at(0); const extraTableHeaders = extraDataTable.find('thead tr th'); - expect(extraTableHeaders.length).toEqual(4); - ['Last Modified', 'Last Modified By', 'Reason', 'Order Number'].forEach((expectedHeader, idx) => expect( + expect(extraTableHeaders.length).toEqual(5); + ['Last Modified', 'Last Modified By', 'Reason', 'Order Number', 'Source System'].forEach((expectedHeader, idx) => expect( extraTableHeaders.at(idx).text(), ).toEqual(expectedHeader)); });