New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #5742 feat(nimbus): implement UI for manual enrollment end #5852
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
from django.urls import reverse | ||
from graphene.utils.str_converters import to_snake_case | ||
from graphene_django.utils.testing import GraphQLTestCase | ||
from parameterized import parameterized | ||
|
||
from experimenter.base.models import Country, Locale | ||
from experimenter.experiments.api.v6.serializers import NimbusExperimentSerializer | ||
|
@@ -745,6 +746,38 @@ def test_paused_experiment_returns_date(self): | |
self.assertEqual(experiment_data["isEnrollmentPaused"], True) | ||
self.assertEqual(experiment_data["enrollmentEndDate"], "2021-01-08") | ||
|
||
@parameterized.expand( | ||
[ | ||
[NimbusExperimentFactory.Lifecycles.PAUSING_REVIEW_REQUESTED, False, True], | ||
[NimbusExperimentFactory.Lifecycles.PAUSING_APPROVE, False, True], | ||
[NimbusExperimentFactory.Lifecycles.PAUSING_APPROVE_WAITING, False, True], | ||
[NimbusExperimentFactory.Lifecycles.PAUSING_APPROVE_TIMEOUT, False, True], | ||
[NimbusExperimentFactory.Lifecycles.PAUSING_APPROVE_APPROVE, True, False], | ||
[NimbusExperimentFactory.Lifecycles.PAUSING_REJECT, False, False], | ||
[NimbusExperimentFactory.Lifecycles.PAUSING_APPROVE_REJECT, False, False], | ||
] | ||
) | ||
def test_experiment_pause_pending(self, lifecycle, expected_paused, expected_pending): | ||
Comment on lines
+749
to
+760
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Figured I might as well try exhausting all the cases here to make sure the pending vs published pause states worked as expected. |
||
user_email = "user@example.com" | ||
experiment = NimbusExperimentFactory.create_with_lifecycle(lifecycle) | ||
response = self.query( | ||
""" | ||
query experimentBySlug($slug: String!) { | ||
experimentBySlug(slug: $slug) { | ||
isEnrollmentPaused | ||
isEnrollmentPausePending | ||
} | ||
} | ||
""", | ||
variables={"slug": experiment.slug}, | ||
headers={settings.OPENIDC_EMAIL_HEADER: user_email}, | ||
) | ||
self.assertEqual(response.status_code, 200, response.content) | ||
content = json.loads(response.content) | ||
experiment_data = content["data"]["experimentBySlug"] | ||
self.assertEqual(experiment_data["isEnrollmentPaused"], expected_paused) | ||
self.assertEqual(experiment_data["isEnrollmentPausePending"], expected_pending) | ||
|
||
def test_signoff_recommendations(self): | ||
user_email = "user@example.com" | ||
experiment = NimbusExperimentFactory.create_with_lifecycle( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ import PageLoading from "../PageLoading"; | |
|
||
type AppLayoutWithExperimentChildrenProps = { | ||
experiment: getExperiment_experimentBySlug; | ||
refetch: () => void; | ||
refetch: () => Promise<unknown>; | ||
analysis?: AnalysisData; | ||
}; | ||
Comment on lines
19
to
23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure where else we're using |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import React, { useMemo } from "react"; | ||
import Alert from "react-bootstrap/Alert"; | ||
import { LIFECYCLE_REVIEW_FLOWS } from "../../lib/constants"; | ||
import { humanDate } from "../../lib/dateUtils"; | ||
import { getExperiment_experimentBySlug } from "../../types/getExperiment"; | ||
import { | ||
NimbusChangeLogOldStatus, | ||
NimbusChangeLogOldStatusNext, | ||
} from "../../types/globalTypes"; | ||
|
||
export const RejectionReason = ({ | ||
rejectionEvent, | ||
}: { | ||
rejectionEvent: getExperiment_experimentBySlug["rejection"]; | ||
}) => { | ||
const { message, changedOn, changedBy, oldStatus, oldStatusNext } = | ||
rejectionEvent!; | ||
|
||
const rejectionActionDescription = useMemo(() => { | ||
if (oldStatus === NimbusChangeLogOldStatus.LIVE) { | ||
if (oldStatusNext === NimbusChangeLogOldStatusNext.LIVE) { | ||
return LIFECYCLE_REVIEW_FLOWS.PAUSE.description; | ||
} | ||
return LIFECYCLE_REVIEW_FLOWS.END.description; | ||
} | ||
if (oldStatus === NimbusChangeLogOldStatus.DRAFT) { | ||
return LIFECYCLE_REVIEW_FLOWS.LAUNCH.description; | ||
} | ||
}, [oldStatus, oldStatusNext]); | ||
|
||
return ( | ||
<Alert variant="warning" data-testid="rejection-notice"> | ||
<div className="text-body"> | ||
<p className="mb-2"> | ||
The request to {rejectionActionDescription} was{" "} | ||
<strong>Rejected</strong> due to: | ||
lmorchard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</p> | ||
<p className="mb-2"> | ||
{changedBy!.email} on {humanDate(changedOn!)}: | ||
</p> | ||
<p className="bg-white rounded border p-2 mb-0">{message}</p> | ||
</div> | ||
</Alert> | ||
); | ||
}; | ||
|
||
export default RejectionReason; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This combined with status=LIVE / status_next = LIVE should give us all the hints needed on the frontend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait explain this. Shouldn't you just be able to infer all this based on publish_status? Why do you need to check the difference between the pause and published pause state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't infer specifically that this is a pending change to end enrollment, and I wanted to be specific #5852 (comment)