feat: add new libray button (#710)
This commit is contained in:
committed by
Adolfo R. Brandes
parent
14f035435c
commit
d48d6ffa5d
@@ -42,7 +42,6 @@ const StudioHome = ({ intl }) => {
|
||||
studioRequestEmail,
|
||||
libraryAuthoringMfeUrl,
|
||||
redirectToLibraryAuthoringMfe,
|
||||
splitStudioHome,
|
||||
} = studioHomeData;
|
||||
|
||||
function getHeaderButtons() {
|
||||
@@ -68,26 +67,24 @@ const StudioHome = ({ intl }) => {
|
||||
);
|
||||
}
|
||||
|
||||
let libraryHref = `${getConfig().STUDIO_BASE_URL}/home#libraries-tab`;
|
||||
if (splitStudioHome) {
|
||||
libraryHref = `${getConfig().STUDIO_BASE_URL}/home_library`;
|
||||
}
|
||||
let libraryHref = `${getConfig().STUDIO_BASE_URL}/home_library`;
|
||||
if (redirectToLibraryAuthoringMfe) {
|
||||
libraryHref = `${libraryAuthoringMfeUrl}/create`;
|
||||
headerButtons.push(
|
||||
<Button
|
||||
variant="outline-primary"
|
||||
iconBefore={AddIcon}
|
||||
size="sm"
|
||||
disabled={showNewCourseContainer}
|
||||
href={libraryHref}
|
||||
data-testid="new-library-button"
|
||||
>
|
||||
{intl.formatMessage(messages.addNewLibraryBtnText)}
|
||||
</Button>,
|
||||
);
|
||||
}
|
||||
|
||||
headerButtons.push(
|
||||
<Button
|
||||
variant="outline-primary"
|
||||
iconBefore={AddIcon}
|
||||
size="sm"
|
||||
disabled={showNewCourseContainer}
|
||||
href={libraryHref}
|
||||
data-testid="new-library-button"
|
||||
>
|
||||
{intl.formatMessage(messages.addNewLibraryBtnText)}
|
||||
</Button>,
|
||||
);
|
||||
|
||||
return headerButtons;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,15 +116,16 @@ describe('<StudioHome />', async () => {
|
||||
});
|
||||
|
||||
describe('render new library button', () => {
|
||||
it('should not show button', async () => {
|
||||
it('href should include home_library', async () => {
|
||||
useSelector.mockReturnValue({
|
||||
...studioHomeMock,
|
||||
courseCreatorStatus: COURSE_CREATOR_STATES.granted,
|
||||
});
|
||||
const studioBaseUrl = 'http://localhost:18010';
|
||||
|
||||
const { queryByTestId } = render(<RootWrapper />);
|
||||
const createNewLibraryButton = queryByTestId('new-library-button');
|
||||
expect(createNewLibraryButton).toBeNull();
|
||||
const { getByTestId } = render(<RootWrapper />);
|
||||
const createNewLibraryButton = getByTestId('new-library-button');
|
||||
expect(createNewLibraryButton.getAttribute('href')).toBe(`${studioBaseUrl}/home_library`);
|
||||
});
|
||||
it('href should include create', async () => {
|
||||
useSelector.mockReturnValue({
|
||||
|
||||
Reference in New Issue
Block a user