|
8 | 8 | from django.core.files.uploadedfile import SimpleUploadedFile |
9 | 9 | from django.test import TestCase, override_settings |
10 | 10 | from django.urls import reverse |
| 11 | +from django.utils.html import escape |
11 | 12 | from parameterized import parameterized |
12 | 13 | from PIL import Image |
13 | 14 |
|
|
16 | 17 | LanguageFactory, |
17 | 18 | LocaleFactory, |
18 | 19 | ) |
19 | | -from experimenter.experiments.constants import NimbusConstants |
| 20 | +from experimenter.experiments.constants import EXTERNAL_URLS, NimbusConstants |
20 | 21 | from experimenter.experiments.models import ( |
21 | 22 | NimbusExperiment, |
22 | 23 | NimbusExperimentBranchThroughExcluded, |
@@ -5707,6 +5708,40 @@ def test_qa_runs_table_shows_experiments_with_testrail_urls_when_qa_status_not_s |
5707 | 5708 | self.assertNotIn(experiment_without_urls, qa_runs) |
5708 | 5709 | self.assertIn(experiment_with_status, qa_runs) |
5709 | 5710 |
|
| 5711 | + def _features_url_for(self, slug): |
| 5712 | + feature = self.feature_configs[slug] |
| 5713 | + url = reverse("nimbus-ui-features") |
| 5714 | + return f"{url}?application={feature.application}&feature_configs={feature.pk}" |
| 5715 | + |
| 5716 | + @patch("experimenter.jetstream.client.get_featmon_slugs") |
| 5717 | + def test_monitoring_card_shows_dashboard_and_info_when_monitored(self, mock_slugs): |
| 5718 | + mock_slugs.return_value = frozenset({"feature-desktop"}) |
| 5719 | + |
| 5720 | + response = self.client.get(self._features_url_for("feature-desktop")) |
| 5721 | + |
| 5722 | + self.assertEqual(response.status_code, 200) |
| 5723 | + content = response.content.decode() |
| 5724 | + self.assertIn("Open Grafana Dashboard", content) |
| 5725 | + self.assertIn(NimbusUIConstants.FEATURE_MONITORING_DASHBOARD_INFO, content) |
| 5726 | + self.assertIn( |
| 5727 | + escape(self.feature_configs["feature-desktop"].feature_monitoring_url), |
| 5728 | + content, |
| 5729 | + ) |
| 5730 | + |
| 5731 | + @patch("experimenter.jetstream.client.get_featmon_slugs") |
| 5732 | + def test_monitoring_card_shows_docs_and_example_when_not_monitored(self, mock_slugs): |
| 5733 | + mock_slugs.return_value = frozenset() |
| 5734 | + |
| 5735 | + response = self.client.get(self._features_url_for("feature-desktop")) |
| 5736 | + |
| 5737 | + self.assertEqual(response.status_code, 200) |
| 5738 | + content = response.content.decode() |
| 5739 | + self.assertIn("Grafana dashboard not available", content) |
| 5740 | + self.assertIn(EXTERNAL_URLS["FEATURE_MONITORING_DOC"], content) |
| 5741 | + self.assertIn(EXTERNAL_URLS["METRIC_HUB_FEATMON_CONFIG"], content) |
| 5742 | + self.assertIn(escape(EXTERNAL_URLS["FEATURE_MONITORING_EXAMPLE"]), content) |
| 5743 | + self.assertIn(escape(NimbusUIConstants.FEATURE_MONITORING_EXAMPLE_TEXT), content) |
| 5744 | + |
5710 | 5745 |
|
5711 | 5746 | class TestTagsManageView(AuthTestCase): |
5712 | 5747 | def test_tags_manage_view_renders(self): |
|
0 commit comments