feat: embedded form redirection experience (#32814)

Redirection for embedded registration experience

VAN-1535
This commit is contained in:
Mubbshar Anwar
2023-07-25 11:56:33 +05:00
committed by GitHub
parent 4379c089f1
commit daa52f3ba9
4 changed files with 18 additions and 3 deletions

View File

@@ -37,6 +37,7 @@ MFE_CONTEXT_WITH_TPA_DATA = {
'autoSubmitRegForm': False,
'syncLearnerProfileData': False,
'countryCode': '',
'welcomePageRedirectUrl': '',
'pipeline_user_details': {
'username': 'test123',
'email': 'test123@edx.com',
@@ -59,6 +60,7 @@ SERIALIZED_MFE_CONTEXT_WITH_TPA_DATA = {
'autoSubmitRegForm': False,
'syncLearnerProfileData': False,
'countryCode': '',
'welcomePageRedirectUrl': '',
'pipelineUserDetails': {
'username': 'test123',
'email': 'test123@edx.com',
@@ -85,6 +87,7 @@ MFE_CONTEXT_WITHOUT_TPA_DATA = {
'autoSubmitRegForm': False,
'syncLearnerProfileData': False,
'countryCode': '',
'welcomePageRedirectUrl': '',
'pipeline_user_details': {}
}
}
@@ -101,6 +104,7 @@ SERIALIZED_MFE_CONTEXT_WITHOUT_TPA_DATA = {
'autoSubmitRegForm': False,
'syncLearnerProfileData': False,
'countryCode': '',
'welcomePageRedirectUrl': '',
'pipelineUserDetails': {}
},
'registrationFields': {},

View File

@@ -117,6 +117,7 @@ class MFEContextViewTest(ThirdPartyAuthTestMixin, APITestCase):
'autoSubmitRegForm': False,
'syncLearnerProfileData': False,
'countryCode': self.country_code,
'welcomePageRedirectUrl': None,
'pipelineUserDetails': self.pipeline_user_details,
},
'registrationFields': {},
@@ -391,16 +392,19 @@ class MFEContextViewTest(ThirdPartyAuthTestMixin, APITestCase):
@override_settings(
ENABLE_DYNAMIC_REGISTRATION_FIELDS=True,
REGISTRATION_EXTRA_FIELDS={'specialty': 'optional', 'goals': 'optional'},
LOGIN_REDIRECT_WHITELIST=['openedx.service'],
)
def test_welcome_page_context(self):
"""
Test MFE Context API response for welcome page
"""
self.query_params.update({'is_welcome_page': True})
response = self.client.get(self.url, self.query_params)
redirect_url = 'https://openedx.service/coolpage'
self.query_params.update({'is_welcome_page': True, 'next': redirect_url})
response = self.client.get(self.url, self.query_params, HTTP_ACCEPT='*/*')
assert response.status_code == status.HTTP_200_OK
assert list(response.data['optionalFields']['fields'].keys()) == ['specialty', 'goals']
assert list(response.data['optionalFields']['extended_profile']) == ['specialty']
assert response.data['contextData']['welcomePageRedirectUrl'] == redirect_url
@skip_unless_lms

View File

@@ -81,10 +81,16 @@ class MFEContextView(APIView):
if settings.ENABLE_DYNAMIC_REGISTRATION_FIELDS:
if request_params.get('is_welcome_page'):
optional_fields = self._get_optional_fields_context()
context = {
'context_data': {
'welcomePageRedirectUrl': redirect_to if redirect_to == request_params.get('next') else None,
},
'optional_fields': optional_fields,
}
return Response(
status=status.HTTP_200_OK,
data=MFEContextSerializer(
{'optional_fields': optional_fields} if optional_fields else {}
context if optional_fields else {}
).data
)

View File

@@ -53,6 +53,7 @@ class ContextDataSerializer(serializers.Serializer):
autoSubmitRegForm = serializers.BooleanField(default=False)
syncLearnerProfileData = serializers.BooleanField(default=False)
countryCode = serializers.CharField(allow_null=True)
welcomePageRedirectUrl = serializers.CharField(allow_null=True)
pipelineUserDetails = serializers.SerializerMethodField()
def get_pipelineUserDetails(self, obj):