feat: add new libray button (#710)

This commit is contained in:
Kristin Aoki
2023-11-22 13:42:37 -05:00
committed by Adolfo R. Brandes
parent 14f035435c
commit d48d6ffa5d
2 changed files with 19 additions and 21 deletions

View File

@@ -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;
}

View File

@@ -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({