diff --git a/src/Configuration/Customers/CustomerDetailView/CustomerCard.jsx b/src/Configuration/Customers/CustomerDetailView/CustomerCard.jsx index a90ce3a14..747a4bdad 100644 --- a/src/Configuration/Customers/CustomerDetailView/CustomerCard.jsx +++ b/src/Configuration/Customers/CustomerDetailView/CustomerCard.jsx @@ -1,28 +1,30 @@ import PropTypes from 'prop-types'; import { - ActionRow, - Button, - Card, - Icon, - Hyperlink, - Toast, + ActionRow, Button, Card, Icon, Hyperlink, Toast, useToggle, } from '@openedx/paragon'; import { Launch, ContentCopy } from '@openedx/paragon/icons'; import { getConfig } from '@edx/frontend-platform'; import { formatDate, useCopyToClipboard } from '../data/utils'; import DJANGO_ADMIN_BASE_URL from '../data/constants'; +import CustomerDetailModal from './CustomerDetailModal'; const CustomerCard = ({ enterpriseCustomer }) => { const { ADMIN_PORTAL_BASE_URL } = getConfig(); const { showToast, copyToClipboard, setShowToast } = useCopyToClipboard(); + const [isDetailsOpen, openDetails, closeDetails] = useToggle(false); return (
+ - + + + + + ); +}; + +CustomerDetailModal.propTypes = { + isOpen: PropTypes.bool.isRequired, + close: PropTypes.func.isRequired, + customer: PropTypes.shape({ + active: PropTypes.bool, + authOrgId: PropTypes.string, + contactEmail: PropTypes.string, + country: PropTypes.string, + defaultLanguage: PropTypes.string, + enableDataSharingConsent: PropTypes.bool, + enableGenerationOfApiCredentials: PropTypes.bool, + enablePortalReportingConfigScreen: PropTypes.bool, + enablePortalSamlConfigurationScreen: PropTypes.bool, + enableSlugLogin: PropTypes.bool, + enforceDataSharingConsent: PropTypes.string, + hideCourseOriginalPrice: PropTypes.bool, + hideLaborMarketData: PropTypes.bool, + modified: PropTypes.string, + name: PropTypes.string, + replaceSensitiveSsoUsername: PropTypes.bool, + replyTo: PropTypes.string, + senderAlias: PropTypes.string, + slug: PropTypes.string, + uuid: PropTypes.string, + }).isRequired, +}; + +export default CustomerDetailModal; diff --git a/src/Configuration/Customers/CustomerDetailView/tests/CustomerDetailModal.test.jsx b/src/Configuration/Customers/CustomerDetailView/tests/CustomerDetailModal.test.jsx new file mode 100644 index 000000000..7cc05a954 --- /dev/null +++ b/src/Configuration/Customers/CustomerDetailView/tests/CustomerDetailModal.test.jsx @@ -0,0 +1,51 @@ +/* eslint-disable react/prop-types */ +import { screen, render } from '@testing-library/react'; +import '@testing-library/jest-dom'; + +import { IntlProvider } from '@edx/frontend-platform/i18n'; +import CustomerDetailModal from '../CustomerDetailModal'; + +jest.mock('../../data/utils', () => ({ + getEnterpriseCustomer: jest.fn(), +})); + +const mockData = { + active: true, + authOrgId: null, + country: 'US', + defaultLanguage: 'English', + enableDataSharingConsent: true, + enableGenerationOfApiCredentials: true, + enableSlugLogin: true, + enforceDataSharingConsent: 'at_enrollment', + hideCourseOriginalPrice: true, + name: 'Test Customer Name', + replaceSensitiveSsoUsername: true, + replyTo: null, + senderAlias: null, + slug: 'customer-6', + uuid: 'test-id', +}; + +describe('CustomerDetailModal', () => { + it('renders customer detail modal', () => { + const props = { + customer: mockData, + isOpen: true, + close: jest.fn(() => {}), + }; + render( + + + , + ); + + expect(screen.getAllByText('Test Customer Name')).toHaveLength(2); + expect(screen.getByText('View only')).toBeInTheDocument(); + // null values will show as dashes + expect(screen.getAllByText('--')).toHaveLength(4); + expect(screen.getByText('/customer-6/')).toBeInTheDocument(); + expect(screen.getByText('At enrollment')).toBeInTheDocument(); + expect(screen.getByText('English')).toBeInTheDocument(); + }); +});