Skip to content

Commit a218e82

Browse files
committed
✅ Add test
1 parent 39aab03 commit a218e82

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/sentry/api/endpoints/test_project_details.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from sentry.constants import RESERVED_PROJECT_SLUGS, ObjectStatus
1414
from sentry.dynamic_sampling import DEFAULT_BIASES, RuleType
1515
from sentry.dynamic_sampling.rules.base import NEW_MODEL_THRESHOLD_IN_MINUTES
16+
from sentry.issues.highlights import get_highlight_preset_for_project
1617
from sentry.models.apitoken import ApiToken
1718
from sentry.models.auditlogentry import AuditLogEntry
1819
from sentry.models.deletedproject import DeletedProject
@@ -837,6 +838,48 @@ def test_safe_fields(self):
837838
'Invalid syntax near "er ror" (line 1),\nDeep wildcard used more than once (line 2)',
838839
]
839840

841+
def test_highlights(self):
842+
# Default with or without flag, ignore update attempt
843+
highlight_context = ["red", "robin"]
844+
highlight_tags = ["bears", "beets", "battlestar_galactica"]
845+
resp = self.get_success_response(
846+
self.org_slug,
847+
self.proj_slug,
848+
highlightContext=highlight_context,
849+
highlightTags=highlight_tags,
850+
)
851+
assert self.project.get_option("sentry:highlight_context") is None
852+
assert self.project.get_option("sentry:highlight_tags") is None
853+
854+
preset = get_highlight_preset_for_project(self.project)
855+
assert resp.data["highlightContext"] == preset["context"]
856+
assert resp.data["highlightTags"] == preset["tags"]
857+
858+
with self.feature("organizations:event-tags-tree-ui"):
859+
# Set to custom
860+
resp = self.get_success_response(
861+
self.org_slug,
862+
self.proj_slug,
863+
highlightContext=highlight_context,
864+
highlightTags=highlight_tags,
865+
)
866+
assert self.project.get_option("sentry:highlight_context") == highlight_context
867+
assert self.project.get_option("sentry:highlight_tags") == highlight_tags
868+
assert resp.data["highlightContext"] == highlight_context
869+
assert resp.data["highlightTags"] == highlight_tags
870+
871+
# Set to empty
872+
resp = self.get_success_response(
873+
self.org_slug,
874+
self.proj_slug,
875+
highlightContext=[],
876+
highlightTags=[],
877+
)
878+
assert self.project.get_option("sentry:highlight_context") == []
879+
assert self.project.get_option("sentry:highlight_tags") == []
880+
assert resp.data["highlightContext"] == []
881+
assert resp.data["highlightTags"] == []
882+
840883
def test_store_crash_reports(self):
841884
resp = self.get_success_response(self.org_slug, self.proj_slug, storeCrashReports=10)
842885
assert self.project.get_option("sentry:store_crash_reports") == 10

0 commit comments

Comments
 (0)