-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1326 from openedx/ammar/disable-lpr-and-analytics…
…-on-stage feat: disable lpr and analytics on stage
- Loading branch information
Showing
9 changed files
with
196 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
import { features } from '../../config'; | ||
import EnterpriseAppRoutes from './EnterpriseAppRoutes'; | ||
import { EnterpriseSubsidiesContext } from '../EnterpriseSubsidiesContext'; | ||
|
||
jest.mock('../AdvanceAnalyticsV2/AnalyticsV2Page', () => function AnalyticsV2PageMock() { | ||
return <div>AnalyticsV2Page Mock Component</div>; | ||
}); | ||
jest.mock('../../containers/AdminPage', () => function AdminPageMock() { | ||
return <div>AdminPage Mock Component</div>; | ||
}); | ||
jest.mock('../PlotlyAnalytics', () => ({ | ||
PlotlyAnalyticsPage: () => <div>PlotlyAnalyticsPage Mock Component</div>, | ||
})); | ||
|
||
let mockEnterpriseAppPage = 'analyticsv2'; | ||
|
||
jest.mock('react-router-dom', () => ({ | ||
...jest.requireActual('react-router-dom'), | ||
Routes: (props) => <span>{props.children}</span>, | ||
Route: ({ element }) => element, | ||
useParams: () => ({ enterpriseAppPage: mockEnterpriseAppPage }), | ||
})); | ||
|
||
const mockEnterpriseSubsidiesContextValue = { | ||
canManageLearnerCredit: true, | ||
}; | ||
|
||
const renderWithProviders = (props) => render( | ||
<IntlProvider locale="en"> | ||
<EnterpriseSubsidiesContext.Provider value={mockEnterpriseSubsidiesContextValue}> | ||
<EnterpriseAppRoutes {...props} /> | ||
</EnterpriseSubsidiesContext.Provider> | ||
</IntlProvider>, | ||
); | ||
|
||
describe('EnterpriseAppRoutes', () => { | ||
const defaultProps = { | ||
email: '[email protected]', | ||
enterpriseId: 'test-enterprise-id', | ||
enterpriseName: 'Test Enterprise', | ||
enableCodeManagementPage: false, | ||
enableReportingPage: false, | ||
enableSubscriptionManagementPage: false, | ||
enableAnalyticsPage: true, | ||
enableContentHighlightsPage: false, | ||
}; | ||
|
||
it('renders FeatureNotSupportedPage when ANALYTICS_SUPPORTED is false', () => { | ||
features.ANALYTICS_SUPPORTED = false; | ||
renderWithProviders(defaultProps); | ||
expect(screen.getByText('This feature is currently unavailable in this environment.')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders AnalyticsV2Page when ANALYTICS_SUPPORTED is true', () => { | ||
features.ANALYTICS_SUPPORTED = true; | ||
renderWithProviders(defaultProps); | ||
expect(screen.getByText('AnalyticsV2Page Mock Component')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders AdminPage when ANALYTICS_SUPPORTED is true', () => { | ||
mockEnterpriseAppPage = 'learners'; | ||
features.ANALYTICS_SUPPORTED = true; | ||
renderWithProviders(defaultProps); | ||
expect(screen.getByText('AdminPage Mock Component')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders Analytics when ANALYTICS_SUPPORTED is true', () => { | ||
mockEnterpriseAppPage = 'analytics'; | ||
features.ANALYTICS_SUPPORTED = true; | ||
renderWithProviders(defaultProps); | ||
expect(screen.getByText('PlotlyAnalyticsPage Mock Component')).toBeInTheDocument(); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
src/components/FeatureNotSupportedPage/FeatureNotSupportedPage.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
|
||
import FeatureNotSupportedPage from './index'; | ||
|
||
describe('<FeatureNotSupportedPage />', () => { | ||
it('renders correctly', () => { | ||
const tree = renderer | ||
.create(( | ||
<IntlProvider locale="en"> | ||
<FeatureNotSupportedPage /> | ||
</IntlProvider> | ||
)) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); |
54 changes: 54 additions & 0 deletions
54
src/components/FeatureNotSupportedPage/__snapshots__/FeatureNotSupportedPage.test.jsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<FeatureNotSupportedPage /> renders correctly 1`] = ` | ||
<main | ||
role="main" | ||
style={ | ||
{ | ||
"flex": 1, | ||
} | ||
} | ||
> | ||
<div | ||
className="container-fluid mt-3" | ||
> | ||
<div | ||
className="text-center py-5" | ||
> | ||
<div | ||
className="fade alert-content alert alert-info show" | ||
role="alert" | ||
> | ||
<span | ||
className="pgn__icon alert-icon" | ||
> | ||
<svg | ||
aria-hidden={true} | ||
fill="none" | ||
focusable={false} | ||
height={24} | ||
role="img" | ||
viewBox="0 0 24 24" | ||
width={24} | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm1 15h-2v-6h2v6Zm0-8h-2V7h2v2Z" | ||
fill="currentColor" | ||
/> | ||
</svg> | ||
</span> | ||
<div | ||
className="pgn__alert-message-wrapper" | ||
> | ||
<div | ||
className="alert-message-content" | ||
> | ||
This feature is currently unavailable in this environment. | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import { Helmet } from 'react-helmet'; | ||
import { FormattedMessage } from '@edx/frontend-platform/i18n'; | ||
import { | ||
Alert, | ||
} from '@openedx/paragon'; | ||
import { | ||
Info, | ||
} from '@openedx/paragon/icons'; | ||
|
||
export const FeatureNotSupported = () => ( | ||
<> | ||
<Helmet> | ||
<title>Feature not supported</title> | ||
</Helmet> | ||
<div className="text-center py-5"> | ||
<Alert variant="info" icon={Info}> | ||
<FormattedMessage | ||
id="admin.portal.feature.not.supported.page.message" | ||
defaultMessage="This feature is currently unavailable in this environment." | ||
description="The message displayed on the feature not supported page" | ||
/> | ||
</Alert> | ||
</div> | ||
</> | ||
); | ||
|
||
const FeatureNotSupportedPage = () => ( | ||
<main role="main" style={{ flex: 1 }}> | ||
<div className="container-fluid mt-3"> | ||
<FeatureNotSupported /> | ||
</div> | ||
</main> | ||
); | ||
|
||
export default FeatureNotSupportedPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters