Skip to content

Commit

Permalink
test: [AXIMST-611] Create a tests to feature flag view
Browse files Browse the repository at this point in the history
  • Loading branch information
NiedielnitsevIvan committed Mar 12, 2024
1 parent 6ed3109 commit d3bfdd9
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 @@ -79,6 +79,7 @@
from lms.djangoapps.courseware.testutils import RenderXBlockTestMixin
from lms.djangoapps.courseware.toggles import (
COURSEWARE_MICROFRONTEND_SEARCH_ENABLED,
COURSEWARE_MICROFRONTEND_SIDEBAR_DISABLED,
COURSEWARE_OPTIMIZED_RENDER_XBLOCK,
)
from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateClient
Expand Down Expand Up @@ -3784,3 +3785,39 @@ def test_is_mfe_search_disabled(self):

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


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

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

self.course = CourseFactory.create()

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

@override_waffle_flag(COURSEWARE_MICROFRONTEND_SIDEBAR_DISABLED, active=True)
def test_courseware_mfe_sidebar_disabled(self):
"""
Getter to check if user is allowed to show the Courseware navigation sidebar.
"""
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_SIDEBAR_DISABLED, active=False)
def test_is_mfe_search_sidebar_enabled(self):
"""
Getter to check if user is allowed to show the Courseware navigation sidebar.
"""
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 d3bfdd9

Please sign in to comment.