Skip to content

Commit

Permalink
backoffice: search for email_addresses as well
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Aug 27, 2024
1 parent d52647a commit 561c23b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backoffice/backoffice/workflows/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WorkflowDocument(Document):
"preferred_name": fields.TextField(),
}
),
"email_address": fields.ObjectField(
"email_addresses": fields.ObjectField(
properties={
"value": fields.KeywordField(),
"current": fields.BooleanField(),
Expand Down
24 changes: 22 additions & 2 deletions backoffice/backoffice/workflows/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def setUpClass(cls):
],
"name": {"value": "Smith, John", "preferred_name": "John Smith"},
"email_addresses": [
{"value": "john.smith@someting.ch", "current": True}
{"value": "john.smith@something.ch", "current": True}
],
},
status=StatusChoices.RUNNING,
Expand All @@ -510,9 +510,29 @@ def test_search_data_name(self):

response = self.api_client.get(url)
results = response.json()["results"]
import ipdb

ipdb.set_trace()
assert len(results) == 1
assert results[0]["data"]["name"]["value"] == "Smith, John"
assert results[0]["data"]["email_addresses"]["value"] == "Smith, John"

def test_search_data_email(self):
self.api_client.force_authenticate(user=self.admin)

email = "[email protected]"

url = reverse("search:workflow-list")

urls = [
url + f"?search={email}",
url + f"?search=data.email_addresses.value:{email}",
]

for url in urls:
response = self.api_client.get(url)
results = response.json()["results"]
assert len(results) == 1
assert results[0]["data"]["email_addresses"][0]["value"] == email

def test_filter_status(self):
self.api_client.force_authenticate(user=self.admin)
Expand Down

0 comments on commit 561c23b

Please sign in to comment.