From d9073e99b0071fa2938e3db9aeafbc9ab938dd86 Mon Sep 17 00:00:00 2001 From: Ahtisham Shahid Date: Tue, 6 Sep 2022 19:40:25 +0500 Subject: [PATCH] feat: fixed iframe redirection logic (#30946) * feat: fixed iframe redirection logic * fix: Updated unit test to resolve test fails --- lms/djangoapps/courseware/tests/test_tabs.py | 15 ++++++++------- lms/djangoapps/discussion/plugins.py | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lms/djangoapps/courseware/tests/test_tabs.py b/lms/djangoapps/courseware/tests/test_tabs.py index 8418e28cb5..42687d4412 100644 --- a/lms/djangoapps/courseware/tests/test_tabs.py +++ b/lms/djangoapps/courseware/tests/test_tabs.py @@ -22,7 +22,7 @@ from lms.djangoapps.courseware.tabs import ( ) from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase from lms.djangoapps.courseware.views.views import StaticCourseTabView, get_static_tab_fragment -from lms.djangoapps.discussion.toggles import ENABLE_VIEW_MFE_IN_IFRAME +from lms.djangoapps.discussion.toggles import ENABLE_VIEW_MFE_IN_IFRAME, ENABLE_DISCUSSIONS_MFE_FOR_EVERYONE from openedx.core.djangoapps.discussions.url_helpers import get_discussions_mfe_url from openedx.core.djangolib.testing.utils import get_mock_request from openedx.core.lib.courses import get_course_by_id @@ -841,12 +841,13 @@ class DiscussionLinkTestCase(TabTestCase): expected_link = get_discussions_mfe_url(course_key=self.course.id) with self.settings(FEATURES={'ENABLE_DISCUSSION_SERVICE': True}): - self.check_discussion( - tab_list=self.tabs_with_discussion, - expected_discussion_link=expected_link, - expected_can_display_value=True, - in_iframe_flag=toggle_enabled, - ) + with override_waffle_flag(ENABLE_DISCUSSIONS_MFE_FOR_EVERYONE, True): + self.check_discussion( + tab_list=self.tabs_with_discussion, + expected_discussion_link=expected_link, + expected_can_display_value=True, + in_iframe_flag=toggle_enabled, + ) class DatesTabTestCase(TabListTestCase): diff --git a/lms/djangoapps/discussion/plugins.py b/lms/djangoapps/discussion/plugins.py index e3a8582c8a..df056f7fbb 100644 --- a/lms/djangoapps/discussion/plugins.py +++ b/lms/djangoapps/discussion/plugins.py @@ -8,7 +8,7 @@ from django.urls import reverse from django.utils.translation import gettext_noop -from lms.djangoapps.discussion.toggles import ENABLE_VIEW_MFE_IN_IFRAME +from lms.djangoapps.discussion.toggles import ENABLE_VIEW_MFE_IN_IFRAME, ENABLE_DISCUSSIONS_MFE_FOR_EVERYONE from openedx.core.djangoapps.discussions.url_helpers import get_discussions_mfe_url from xmodule.tabs import TabFragmentViewMixin @@ -44,7 +44,7 @@ class DiscussionTab(TabFragmentViewMixin, EnrolledTab): @property def link_func(self): def _link_func(course, reverse_func): - if not ENABLE_VIEW_MFE_IN_IFRAME.is_enabled(): + if not ENABLE_VIEW_MFE_IN_IFRAME.is_enabled() and ENABLE_DISCUSSIONS_MFE_FOR_EVERYONE.is_enabled(course.id): return get_discussions_mfe_url(course_key=course.id) return reverse('forum_form_discussion', args=[str(course.id)])