feat: fixed iframe redirection logic (#30946)

* feat: fixed iframe redirection logic
* fix: Updated unit test to resolve test fails
This commit is contained in:
Ahtisham Shahid
2022-09-06 19:40:25 +05:00
committed by GitHub
parent a12243e9b3
commit d9073e99b0
2 changed files with 10 additions and 9 deletions

View File

@@ -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):

View File

@@ -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)])