Skip to content

Commit

Permalink
feat: add source_system and update order no href for enrollments table (
Browse files Browse the repository at this point in the history
  • Loading branch information
NawfalAhmed authored Apr 16, 2024
1 parent da37a62 commit e65f259
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
1 change: 1 addition & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/setupTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 20 additions & 1 deletion src/users/enrollments/Enrollments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 }) => <a href={`${getConfig().ECOMMERCE_BASE_URL}/dashboard/orders/${value}`} rel="noopener noreferrer" target="_blank" className="word_break">{value}</a>,
Cell: ({ value }) => (
<a
href={
getConfig().COMMERCE_COORDINATOR_ORDER_DETAILS_URL
? `${getConfig().COMMERCE_COORDINATOR_ORDER_DETAILS_URL}/?order_number=${value}`
: `${getConfig().ECOMMERCE_BASE_URL}/dashboard/orders/${value}`
}
rel="noopener noreferrer"
target="_blank"
className="word_break"
>
{value}
</a>
),
},
{
Header: 'Source System', accessor: 'sourceSystem',
},
],
[],
Expand Down
21 changes: 17 additions & 4 deletions src/users/enrollments/Enrollments.test.jsx
Original file line number Diff line number Diff line change
@@ -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) => (
<UserMessagesProvider>
<Enrollments {...props} />
Expand Down Expand Up @@ -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));

Expand All @@ -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: [],
Expand All @@ -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));
});
Expand Down

0 comments on commit e65f259

Please sign in to comment.