Skip to content
Open
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
10 changes: 10 additions & 0 deletions experimenter/experimenter/nimbus_ui/new/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,23 @@ class RolloutOverviewForm(NimbusChangeLogFormMixin, forms.ModelForm):
public_description = forms.CharField(
required=False, widget=forms.Textarea(attrs={"class": "form-control", "rows": 3})
)
application = forms.ChoiceField(
Comment thread
moibra05 marked this conversation as resolved.
disabled=True,
choices=NimbusExperiment.Application.choices,
widget=forms.widgets.Select(
attrs={
"class": "form-select",
},
),
)

class Meta:
model = NimbusExperiment
fields = [
"name",
"hypothesis",
"public_description",
"application",
]

def __init__(self, *args, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<div class="text-secondary mb-1" style="font-size: 12px;">Observations &amp; Problem space</div>
<div class="small text-body" style="white-space: pre-wrap;">{{ experiment.hypothesis|default:"—" }}</div>
</div>
{# Application #}
<div>
<div class="text-secondary mb-1" style="font-size: 12px;">Application</div>
<div class="small text-body">{{ experiment.get_application_display }}</div>
</div>
{# Important Links #}
<div>
<div class="text-secondary mb-1" style="font-size: 12px;">Important Links</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
<div class="text-danger small mt-1">{{ form.hypothesis.errors|join:", " }}</div>
{% endif %}
</div>
{# Application #}
<div>
<label for="id_application" class="small text-body mb-1">Application</label>
{{ form.application }}
{% if form.application.errors %}
<div class="text-danger small mt-1">{{ form.application.errors|join:", " }}</div>
{% endif %}
<p class="form-text mb-0">
Rollouts can only target one Application at a time.
<br>
Application can not be changed after a rollout is created.
</p>
</div>
{# Important Links #}
<div>
<label class="small text-body mb-1">Important Links</label>
Expand Down
5 changes: 5 additions & 0 deletions experimenter/experimenter/nimbus_ui/tests/test_new_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def test_valid_form_saves(self):
"name": "new rollout name",
"hypothesis": "new hypothesis",
"public_description": "new description",
"application": NimbusExperiment.Application.FENIX,
"documentation_links-TOTAL_FORMS": "1",
"documentation_links-INITIAL_FORMS": "1",
"documentation_links-0-id": documentation_link.id,
Expand All @@ -244,6 +245,7 @@ def test_valid_form_saves(self):
self.assertEqual(experiment.name, "new rollout name")
self.assertEqual(experiment.hypothesis, "new hypothesis")
self.assertEqual(experiment.public_description, "new description")
self.assertEqual(experiment.application, NimbusExperiment.Application.FENIX)

documentation_link = experiment.documentation_links.all().get()
self.assertEqual(
Expand All @@ -260,6 +262,7 @@ def test_name_field_is_required(self):
"name": "",
"hypothesis": "new hypothesis",
"public_description": "new description",
"application": NimbusExperiment.Application.DESKTOP,
"documentation_links-TOTAL_FORMS": "0",
"documentation_links-INITIAL_FORMS": "0",
}
Expand All @@ -283,6 +286,7 @@ def test_valid_form_adds_documentation_link(self):
"name": "new name",
"hypothesis": "new hypothesis",
"public_description": "new description",
"application": experiment.application,
"documentation_links-TOTAL_FORMS": "0",
"documentation_links-INITIAL_FORMS": "0",
},
Expand Down Expand Up @@ -314,6 +318,7 @@ def test_valid_form_deletes_documentation_link(self):
"name": "new name",
"hypothesis": "new hypothesis",
"public_description": "new description",
"application": experiment.application,
"documentation_links-TOTAL_FORMS": "1",
"documentation_links-INITIAL_FORMS": "1",
"documentation_links-0-id": documentation_link.id,
Expand Down
5 changes: 5 additions & 0 deletions experimenter/experimenter/nimbus_ui/tests/test_new_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def overview_data(self, experiment, documentation_link=None, **overrides):
"name": experiment.name,
"hypothesis": experiment.hypothesis,
"public_description": experiment.public_description,
"application": experiment.application,
"documentation_links-TOTAL_FORMS": "0",
"documentation_links-INITIAL_FORMS": "0",
}
Expand Down Expand Up @@ -199,6 +200,7 @@ def test_post_valid_saves_and_returns_display_card(self):
name="updated name",
hypothesis="updated hypothesis",
public_description="updated description",
application=NimbusExperiment.Application.FENIX,
),
)

Expand All @@ -207,6 +209,7 @@ def test_post_valid_saves_and_returns_display_card(self):
experiment.refresh_from_db()
self.assertEqual(experiment.name, "updated name")
self.assertEqual(experiment.hypothesis, "updated hypothesis")
self.assertEqual(experiment.application, NimbusExperiment.Application.FENIX)
self.assertTrue(response.context["hx_swap_oob"])

def test_post_invalid_returns_edit_form_with_errors(self):
Expand Down Expand Up @@ -438,6 +441,7 @@ def test_post_creates_link_and_returns_edit_form(self):
{
"name": experiment.name,
"hypothesis": experiment.hypothesis,
"application": experiment.application,
"risk_brand": True,
"risk_message": True,
"public_description": experiment.public_description,
Expand Down Expand Up @@ -466,6 +470,7 @@ def test_post_deletes_link_and_returns_edit_form(self):
{
"name": experiment.name,
"hypothesis": experiment.hypothesis,
"application": experiment.application,
"risk_brand": True,
"risk_message": True,
"public_description": experiment.public_description,
Expand Down
Loading