Merge branch 'master' of github.com:openedx/frontend-app-ora-grading into bilalqamar95/jest-v29-upgrade

This commit is contained in:
Bilal Qamar
2024-06-03 16:06:23 +05:00
13 changed files with 3325 additions and 78 deletions

View File

@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { BrowserRouter as Router } from 'react-router-dom';
import Footer from '@edx/frontend-component-footer';
import FooterSlot from '@openedx/frontend-slot-footer';
import { LearningHeader as Header } from '@edx/frontend-component-header';
import { selectors } from 'data/redux';
@@ -32,7 +32,7 @@ export const App = ({ courseMetadata, isEnabled }) => (
<main data-testid="main">
<ListView />
</main>
<Footer logo={process.env.LOGO_POWERED_BY_OPEN_EDX_URL_SVG} data-testid="footer" />
<FooterSlot />
</div>
</Router>
);

View File

@@ -15,14 +15,13 @@ jest.mock('data/redux', () => ({
jest.mock('@edx/frontend-component-header', () => ({
LearningHeader: 'Header',
}));
jest.mock('@edx/frontend-component-footer', () => 'Footer');
jest.mock('@edx/frontend-component-footer', () => ({ FooterSlot: 'Footer' }));
jest.mock('containers/DemoWarning', () => 'DemoWarning');
jest.mock('containers/CTA', () => 'CTA');
jest.mock('containers/ListView', () => 'ListView');
jest.mock('components/Head', () => 'Head');
const logo = 'fakeLogo.png';
let el;
describe('App router component', () => {
@@ -42,7 +41,6 @@ describe('App router component', () => {
});
describe('component', () => {
beforeEach(() => {
process.env.LOGO_POWERED_BY_OPEN_EDX_URL_SVG = logo;
el = shallow(<App {...props} />);
});
describe('Router', () => {
@@ -51,9 +49,6 @@ describe('App router component', () => {
expect(el.instance.findByTestId('main')[0].children[0].type).toBe('ListView');
});
});
test('Footer logo drawn from env variable', () => {
expect(el.instance.findByTestId('footer')[0].props.logo).toEqual(logo);
});
test('Header to use courseMetadata props', () => {
const {

View File

@@ -18,10 +18,7 @@ exports[`App router component snapshot: disabled (show demo warning) 1`] = `
>
<ListView />
</main>
<Footer
data-testid="footer"
logo="https://edx-cdn.org/v3/stage/open-edx-tag.svg"
/>
<FooterSlot />
</div>
</BrowserRouter>
`;
@@ -43,10 +40,7 @@ exports[`App router component snapshot: enabled 1`] = `
>
<ListView />
</main>
<Footer
data-testid="footer"
logo="https://edx-cdn.org/v3/stage/open-edx-tag.svg"
/>
<FooterSlot />
</div>
</BrowserRouter>
`;

View File

@@ -0,0 +1,50 @@
# Footer Slot
### Slot ID: `footer_slot`
## Description
This slot is used to replace/modify/hide the footer.
The implementation of the `FooterSlot` component lives in [the `frontend-slot-footer` repository](https://github.com/openedx/frontend-slot-footer/).
## Example
The following `env.config.jsx` will replace the default footer.
![Screenshot of Default Footer](./images/default_footer.png)
with a simple custom footer
![Screenshot of Custom Footer](./images/custom_footer.png)
```jsx
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
const config = {
pluginSlots: {
footer_slot: {
plugins: [
{
// Hide the default footer
op: PLUGIN_OPERATIONS.Hide,
widgetId: 'default_contents',
},
{
// Insert a custom footer
op: PLUGIN_OPERATIONS.Insert,
widget: {
id: 'custom_footer',
type: DIRECT_PLUGIN,
RenderWidget: () => (
<h1 style={{textAlign: 'center'}}>🦶</h1>
),
},
},
]
}
},
}
export default config;
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -0,0 +1,3 @@
# `frontend-app-ora-grading` Plugin Slots
* [`footer_slot`](./FooterSlot/)