Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Unreleased
----------
* nothing unreleased

[8.11.0] - 2026-09-10
----------------------
* fix: change SupportContactEnterpriseTagStep to accept/return full context (ENT-11574)

[8.10.0] - 2026-09-08
----------------------
* feat: add SupportContactEnterpriseTagStep pipeline step (ENT-11574)
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "8.10.0"
__version__ = "8.11.0"
9 changes: 5 additions & 4 deletions enterprise/filters/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ class SupportContactEnterpriseTagStep(PipelineStep):
``org.openedx.learning.support.contact.context.requested.v1`` filter.
"""

def run_filter(self, tags, user): # pylint: disable=arguments-differ
def run_filter(self, context): # pylint: disable=arguments-differ
"""
Append 'enterprise_learner' to tags if the requester is linked to a customer account.
Append 'enterprise_learner' to context['tags'] if the requester is linked to a customer account.
"""
request = get_current_request()
customer = enterprise_customer_for_request(request)
tags = context.get('tags', [])
if customer and 'enterprise_learner' not in tags:
tags = [*tags, 'enterprise_learner']
context = {**context, 'tags': [*tags, 'enterprise_learner']}

return {'tags': tags, 'user': user}
return {'context': context}
29 changes: 12 additions & 17 deletions tests/filters/test_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from django.test import RequestFactory, TestCase

from enterprise.filters.support import SupportContactEnterpriseTagStep
from test_utils.factories import UserFactory

CONTACT_FILTER_TYPE = "org.openedx.learning.support.contact.context.requested.v1"

Expand All @@ -27,49 +26,45 @@ def _make_request(self):
def test_appends_tag_for_linked_customer_request(self, mock_get_current_request, mock_customer_for_request):
"""
When the request is associated with a linked customer account, 'enterprise_learner'
is appended to the tags list.
is appended to context['tags'].
"""
mock_customer_for_request.return_value = {'uuid': 'some-uuid', 'name': 'Test Customer'}
request = self._make_request()
mock_get_current_request.return_value = request
user = UserFactory()
tags = ['some_tag']
context = {'tags': ['some_tag']}

step = self._make_step()
result = step.run_filter(tags=tags, user=user)
result = step.run_filter(context=context)

assert result['tags'] == ['some_tag', 'enterprise_learner']
assert result['user'] is user
assert result['context']['tags'] == ['some_tag', 'enterprise_learner']
mock_customer_for_request.assert_called_once_with(request)

@patch('enterprise.filters.support.enterprise_customer_for_request')
@patch('enterprise.filters.support.get_current_request')
def test_does_not_duplicate_tag(self, mock_get_current_request, mock_customer_for_request):
"""
When 'enterprise_learner' is already in the tags list, it is not duplicated.
When 'enterprise_learner' is already in context['tags'], it is not duplicated.
"""
mock_customer_for_request.return_value = {'uuid': 'some-uuid', 'name': 'Test Customer'}
mock_get_current_request.return_value = self._make_request()
user = UserFactory()
tags = ['enterprise_learner']
context = {'tags': ['enterprise_learner']}

step = self._make_step()
result = step.run_filter(tags=tags, user=user)
result = step.run_filter(context=context)

assert result['tags'].count('enterprise_learner') == 1
assert result['context']['tags'].count('enterprise_learner') == 1

@patch('enterprise.filters.support.enterprise_customer_for_request')
@patch('enterprise.filters.support.get_current_request')
def test_does_not_append_tag_for_unlinked_request(self, mock_get_current_request, mock_customer_for_request):
"""
When the request is not associated with a linked customer account, tags are unchanged.
When the request is not associated with a linked customer account, context['tags'] is unchanged.
"""
mock_customer_for_request.return_value = None
mock_get_current_request.return_value = self._make_request()
user = UserFactory()
tags = ['some_tag']
context = {'tags': ['some_tag']}

step = self._make_step()
result = step.run_filter(tags=tags, user=user)
result = step.run_filter(context=context)

assert result['tags'] == ['some_tag']
assert result['context']['tags'] == ['some_tag']