Skip to content

Commit

Permalink
test: [FC-0056] add tests for new waffle flag view
Browse files Browse the repository at this point in the history
  • Loading branch information
NiedielnitsevIvan authored and GlugovGrGlib committed May 2, 2024
1 parent 15c43b0 commit 84a2116
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lms/djangoapps/courseware/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
from lms.djangoapps.courseware.toggles import (
COURSEWARE_MICROFRONTEND_SEARCH_ENABLED,
COURSEWARE_OPTIMIZED_RENDER_XBLOCK,
COURSEWARE_SHOW_DEFAULT_RIGHT_SIDEBAR,
)
from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateClient
from lms.djangoapps.courseware.views.views import (
Expand Down Expand Up @@ -3812,3 +3813,39 @@ def test_is_mfe_search_waffle_disabled(self):

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


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

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

self.course = CourseFactory.create()

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

@override_waffle_flag(COURSEWARE_SHOW_DEFAULT_RIGHT_SIDEBAR, active=False)
def test_is_mfe_show_default_right_sidebar_disabled(self):
"""
Getter to check if Discussion/Notifications 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_SHOW_DEFAULT_RIGHT_SIDEBAR, active=True)
def test_is_mfe_show_default_right_sidebar_enabled(self):
"""
Getter to check if Discussion/Notifications 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 84a2116

Please sign in to comment.