Skip to content

Commit

Permalink
test: [AXIMST-629] add tests for new waffle flag view
Browse files Browse the repository at this point in the history
  • Loading branch information
NiedielnitsevIvan committed Mar 14, 2024
1 parent cacdec9 commit 1821464
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion lms/djangoapps/courseware/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
from lms.djangoapps.courseware.tests.helpers import MasqueradeMixin, get_expiration_banner_text, set_preview_mode
from lms.djangoapps.courseware.testutils import RenderXBlockTestMixin
from lms.djangoapps.courseware.toggles import (
COURSEWARE_MICROFRONTEND_DISCUSSION_SIDEBAR_OPEN_DISABLED,
COURSEWARE_MICROFRONTEND_SEARCH_ENABLED,
COURSEWARE_MICROFRONTEND_SIDEBAR_DISABLED,
COURSEWARE_OPTIMIZED_RENDER_XBLOCK,
Expand Down Expand Up @@ -3812,7 +3813,7 @@ def test_courseware_mfe_sidebar_disabled(self):
self.assertEqual(body, {'enabled': False})

@override_waffle_flag(COURSEWARE_MICROFRONTEND_SIDEBAR_DISABLED, active=False)
def test_is_mfe_search_sidebar_enabled(self):
def test_is_mfe_sidebar_enabled(self):
"""
Getter to check if user is allowed to show the Courseware navigation sidebar.
"""
Expand All @@ -3821,3 +3822,39 @@ def test_is_mfe_search_sidebar_enabled(self):

self.assertEqual(response.status_code, 200)
self.assertEqual(body, {'enabled': True})


class TestMFEDiscussionSidebarEnabledAPI(SharedModuleStoreTestCase):
"""
Tests the endpoint to fetch the Courseware Discussion Sidebar waffle flag status.
"""

def setUp(self):
super().setUp()

self.course = CourseFactory.create()

self.client = APIClient()
self.apiUrl = reverse('discussion_sidebar_enabled_view', kwargs={'course_id': str(self.course.id)})

@override_waffle_flag(COURSEWARE_MICROFRONTEND_DISCUSSION_SIDEBAR_OPEN_DISABLED, active=True)
def test_is_mfe_discussion_sidebar_opening_disabled(self):
"""
Getter to check if discussion sidebar shouldn't be opened by default.
"""
response = self.client.get(self.apiUrl, content_type='application/json')
body = json.loads(response.content.decode('utf-8'))

self.assertEqual(response.status_code, 200)
self.assertEqual(body, {'enabled': False})

@override_waffle_flag(COURSEWARE_MICROFRONTEND_DISCUSSION_SIDEBAR_OPEN_DISABLED, active=False)
def test_is_mfe_discussion_sidebar_opening_enabled(self):
"""
Getter to check if discussion sidebar should be opened by default.
"""
response = self.client.get(self.apiUrl, content_type='application/json')
body = json.loads(response.content.decode('utf-8'))

self.assertEqual(response.status_code, 200)
self.assertEqual(body, {'enabled': True})

0 comments on commit 1821464

Please sign in to comment.