generated from openedx/frontend-template-application
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add MainAppSlot for chatbot plugin (#1320)
* feat: add MainAppSlot for chatbot plugin * test: added test for MainAppSlot * chore: add read me for plugin-slot
- Loading branch information
1 parent
e496bb6
commit 47b0501
Showing
8 changed files
with
136 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,29 @@ | ||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import MainAppSlot from './index'; | ||
|
||
jest.mock('@openedx/frontend-plugin-framework', () => ({ | ||
PluginSlot: jest.fn(() => null), | ||
})); | ||
|
||
describe('MainAppSlot', () => { | ||
it('renders without crashing', () => { | ||
render(<MainAppSlot />); | ||
}); | ||
|
||
it('renders a PluginSlot component', () => { | ||
render(<MainAppSlot />); | ||
expect(PluginSlot).toHaveBeenCalled(); | ||
}); | ||
|
||
it('passes the correct id prop to PluginSlot', () => { | ||
render(<MainAppSlot />); | ||
expect(PluginSlot).toHaveBeenCalledWith({ id: 'main_app_slot' }, {}); | ||
}); | ||
|
||
it('does not render any children', () => { | ||
const { container } = render(<MainAppSlot />); | ||
expect(container.firstChild).toBeNull(); | ||
}); | ||
}); |
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,41 @@ | ||
# Main App Slot | ||
|
||
### Slot ID: `main_app_slot` | ||
|
||
## Description | ||
|
||
This slot is used for adding content at the root level. | ||
|
||
## Example | ||
|
||
The following `env.config.jsx` will render a component at the MFE root level. | ||
|
||
![Screenshot of Content added after the Main App Slot](./images/main_app_slot.png) | ||
|
||
```js | ||
import { | ||
DIRECT_PLUGIN, | ||
PLUGIN_OPERATIONS, | ||
} from "@openedx/frontend-plugin-framework"; | ||
import { ExampleComponent } from "@openedx/frontend-plugin-example"; | ||
|
||
const config = { | ||
pluginSlots: { | ||
main_app_slot: { | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: "example-component", | ||
type: DIRECT_PLUGIN, | ||
priority: 60, | ||
RenderWidget: ExampleComponent, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
export default config; | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,7 @@ | ||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
||
const MainAppSlot = () => ( | ||
<PluginSlot id="main_app_slot" /> | ||
); | ||
|
||
export default MainAppSlot; |
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,3 @@ | ||
# `frontend-app-authn` Plugin Slots | ||
|
||
- [`main_app_slot`](./MainAppSlot/) |