diff --git a/src/studio-home/StudioHome.jsx b/src/studio-home/StudioHome.jsx
index 52c28353a..cd4542e05 100644
--- a/src/studio-home/StudioHome.jsx
+++ b/src/studio-home/StudioHome.jsx
@@ -26,6 +26,7 @@ import { useStudioHome } from './hooks';
import AlertMessage from '../generic/alert-message';
const StudioHome = ({ intl }) => {
+ const isPaginationCoursesEnabled = getConfig().ENABLE_HOME_PAGE_COURSE_API_V2 === 'true';
const {
isLoadingPage,
isFailedLoadingPage,
@@ -39,7 +40,7 @@ const StudioHome = ({ intl }) => {
hasAbilityToCreateNewCourse,
setShowNewCourseContainer,
dispatch,
- } = useStudioHome();
+ } = useStudioHome(isPaginationCoursesEnabled);
const {
userIsActive,
@@ -49,8 +50,6 @@ const StudioHome = ({ intl }) => {
redirectToLibraryAuthoringMfe,
} = studioHomeData;
- const isPaginationCoursesEnabled = getConfig().ENABLE_HOME_PAGE_COURSE_API_V2 === 'true';
-
function getHeaderButtons() {
const headerButtons = [];
diff --git a/src/studio-home/hooks.jsx b/src/studio-home/hooks.jsx
index a12bc4782..1c26087c9 100644
--- a/src/studio-home/hooks.jsx
+++ b/src/studio-home/hooks.jsx
@@ -14,7 +14,7 @@ import {
} from './data/selectors';
import { updateSavingStatuses } from './data/slice';
-const useStudioHome = () => {
+const useStudioHome = (isPaginated = false) => {
const location = useLocation();
const dispatch = useDispatch();
const studioHomeData = useSelector(getStudioHomeData);
@@ -31,13 +31,17 @@ const useStudioHome = () => {
const isFailedLoadingPage = studioHomeLoadingStatus === RequestStatus.FAILED;
useEffect(() => {
- dispatch(fetchStudioHomeData(location.search ?? ''));
- setShowNewCourseContainer(false);
+ if (!isPaginated) {
+ dispatch(fetchStudioHomeData(location.search ?? ''));
+ setShowNewCourseContainer(false);
+ }
}, [location.search]);
useEffect(() => {
- const { currentPage } = studioHomeCoursesParams;
- dispatch(fetchStudioHomeData(location.search ?? '', false, { page: currentPage }, true));
+ if (isPaginated) {
+ const { currentPage } = studioHomeCoursesParams;
+ dispatch(fetchStudioHomeData(location.search ?? '', false, { page: currentPage }, true));
+ }
}, [studioHomeCoursesParams.currentPage]);
useEffect(() => {
diff --git a/src/studio-home/tabs-section/TabsSection.test.jsx b/src/studio-home/tabs-section/TabsSection.test.jsx
index affcbea06..73b2205e8 100644
--- a/src/studio-home/tabs-section/TabsSection.test.jsx
+++ b/src/studio-home/tabs-section/TabsSection.test.jsx
@@ -157,6 +157,40 @@ describe('', () => {
});
});
+ describe('archived tab', () => {
+ it('should switch to Archived tab and render specific archived course details', async () => {
+ render();
+ axiosMock.onGet(getStudioHomeApiUrl()).reply(200, generateGetStudioHomeDataApiResponse());
+ axiosMock.onGet(courseApiLink).reply(200, generateGetStudioCoursesApiResponse());
+ await executeThunk(fetchStudioHomeData(), store.dispatch);
+
+ const archivedTab = screen.getByText(tabMessages.archivedTabTitle.defaultMessage);
+ fireEvent.click(archivedTab);
+
+ expect(screen.getByText(studioHomeMock.archivedCourses[0].displayName)).toBeVisible();
+
+ expect(screen.getByText(
+ `${studioHomeMock.archivedCourses[0].org} / ${studioHomeMock.archivedCourses[0].number} / ${studioHomeMock.archivedCourses[0].run}`,
+ )).toBeVisible();
+ });
+
+ it('should hide Archived tab when archived courses are empty', async () => {
+ const data = generateGetStudioCoursesApiResponse();
+ data.archivedCourses = [];
+
+ render();
+ axiosMock.onGet(getStudioHomeApiUrl()).reply(200, generateGetStudioHomeDataApiResponse());
+ axiosMock.onGet(courseApiLink).reply(200, data);
+ await executeThunk(fetchStudioHomeData(), store.dispatch);
+
+ expect(screen.getByText(tabMessages.coursesTabTitle.defaultMessage)).toBeInTheDocument();
+
+ expect(screen.getByText(tabMessages.librariesTabTitle.defaultMessage)).toBeInTheDocument();
+
+ expect(screen.queryByText(tabMessages.archivedTabTitle.defaultMessage)).toBeNull();
+ });
+ });
+
describe('library tab', () => {
it('should switch to Libraries tab and render specific library details', async () => {
render();