Skip to content

Commit

Permalink
added analysis report link fixes mozilla#3066
Browse files Browse the repository at this point in the history
  • Loading branch information
tiftran committed Jul 27, 2020
1 parent 22b2d9f commit 615f9d5
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 8 deletions.
42 changes: 42 additions & 0 deletions app/experimenter/static/rapid/__tests__/experimentDetails.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,48 @@ describe("<ExperimentDetails />", () => {
});
});

it("renders with analysis report when live", async () => {
await act(async () => {
const { getByText } = renderWithRouter(
wrapInExperimentProvider(<ExperimentDetails />, {
initialState: {
status: ExperimentStatus.LIVE,
slug: "test-slug",
name: "Test Name",
objectives: "Test objectives",
owner: "[email protected]",
features: ["pinned_tabs", "picture_in_picture"],
audience: "all_english",
firefox_min_version: "78.0",
},
}),
);

expect(getByText(/The results can be found/)).toBeInTheDocument();
});
});

it("renders without analysis report when not live", async () => {
await act(async () => {
const { queryByText } = renderWithRouter(
wrapInExperimentProvider(<ExperimentDetails />, {
initialState: {
status: ExperimentStatus.DRAFT,
slug: "test-slug",
name: "Test Name",
objectives: "Test objectives",
owner: "[email protected]",
features: ["pinned_tabs", "picture_in_picture"],
audience: "all_english",
firefox_min_version: "78.0",
},
}),
);

expect(queryByText(/The results can be found/)).toBe(null);
});
});

it("sends you to the edit page when the 'Back' button is clicked", async () => {
await act(async () => {
const { getByText, history } = renderWithRouter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,33 @@ const ExperimentDetails: React.FC = () => {
);
}

let analysis_report;
if (
[ExperimentStatus.LIVE, ExperimentStatus.COMPLETE].includes(
experimentData.status,
) &&
experimentData.slug
) {
const slug_underscored = experimentData.slug.split("-").join("_");
analysis_report = (
<>
<h3 className="my-4">Results</h3>
<p>
The results will be available 7 days after the experiment is launched.
An email will be sent to you once we start recording data.
</p>
<p>
The results can be found{" "}
<a
href={`https://metrics.mozilla.com/protected/experiments/${slug_underscored}.html`}
>
here
</a>
</p>
</>
);
}

const buttonsDisabled = experimentData.status !== ExperimentStatus.DRAFT;
let buttonsClass = "btn btn-primary";
if (buttonsDisabled) {
Expand Down Expand Up @@ -177,14 +204,7 @@ const ExperimentDetails: React.FC = () => {

{monitoring_url}

<h3 className="my-4">Results</h3>
<p>
The results will be available 7 days after the experiment is launched.
An email will be sent to you once we start recording data.
</p>
<p>
The results can be found here: <a href="#">(link here)</a>
</p>
{analysis_report}

{changeStatusButtons}
</div>
Expand Down

0 comments on commit 615f9d5

Please sign in to comment.