-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,179 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
12.* | ||
14.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
10.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
spotlight-client/src/MetricVizControls/MetricVizControls.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Recidiviz - a data platform for criminal justice reform | ||
// Copyright (C) 2021 Recidiviz, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
// ============================================================================= | ||
|
||
import { fireEvent, render, screen, within } from "@testing-library/react"; | ||
import React from "react"; | ||
import createMetricMapping from "../contentModels/createMetricMapping"; | ||
import HistoricalPopulationBreakdownMetric from "../contentModels/HistoricalPopulationBreakdownMetric"; | ||
import contentFixture from "../contentModels/__fixtures__/tenant_content_exhaustive"; | ||
import MetricVizControls from "./MetricVizControls"; | ||
|
||
const testTenantId = "US_ND"; | ||
const testMetricId = "ProbationPopulationHistorical"; | ||
const testMetadataMapping = { | ||
[testMetricId]: contentFixture.metrics[testMetricId], | ||
}; | ||
|
||
// we can use any metric here, the behavior is generic | ||
function getTestMetric() { | ||
return createMetricMapping({ | ||
localityLabelMapping: undefined, | ||
metadataMapping: testMetadataMapping, | ||
tenantId: testTenantId, | ||
}).get(testMetricId) as HistoricalPopulationBreakdownMetric; | ||
} | ||
|
||
test("download button", () => { | ||
const metric = getTestMetric(); | ||
jest.spyOn(metric, "download").mockImplementation(() => Promise.resolve()); | ||
|
||
render(<MetricVizControls filters={[]} metric={metric} />); | ||
|
||
const download = screen.getByRole("button", { name: "Download Data" }); | ||
expect(download).toBeVisible(); | ||
fireEvent.click(download); | ||
|
||
expect(metric.download).toHaveBeenCalled(); | ||
}); | ||
|
||
test("methodology modal", () => { | ||
const metric = getTestMetric(); | ||
render(<MetricVizControls filters={[]} metric={metric} />); | ||
|
||
const methodology = screen.getByRole("button", { name: "Methodology" }); | ||
|
||
fireEvent.click(methodology); | ||
|
||
const modal = screen.getByRole("dialog"); | ||
|
||
expect(modal).toBeVisible(); | ||
expect( | ||
within(modal).getByRole("heading", { name: "Methodology" }) | ||
).toBeVisible(); | ||
// this only works because the test metric has no HTML in it | ||
expect(within(modal).getByText(metric.methodology)).toBeVisible(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Recidiviz - a data platform for criminal justice reform | ||
// Copyright (C) 2021 Recidiviz, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
// ============================================================================= | ||
|
||
import { Modal as ModalBase } from "@recidiviz/case-triage-components"; | ||
import { rem, rgba } from "polished"; | ||
import styled from "styled-components/macro"; | ||
import { colors } from "."; | ||
import animation from "./animation"; | ||
import zIndex from "./zIndex"; | ||
|
||
export const Modal = styled(ModalBase).attrs({ | ||
closeTimeoutMS: animation.defaultDuration, | ||
})` | ||
/* | ||
the double ampersands are a trick to overcome | ||
specificity in the imported component styles | ||
*/ | ||
&& .ReactModal__Overlay { | ||
background: ${rgba(colors.modalOverlay, 0)}; | ||
transition: background-color ${animation.defaultDuration}ms, | ||
backdrop-filter ${animation.defaultDuration}ms; | ||
z-index: ${zIndex.modal}; | ||
&.ReactModal__Overlay--after-open { | ||
/* not all browsers support backdrop-filter but it's a nice progressive enhancement */ | ||
backdrop-filter: blur(${rem(4)}); | ||
background: ${rgba(colors.modalOverlay, 0.7)}; | ||
} | ||
&.ReactModal__Overlay--before-close { | ||
backdrop-filter: none; | ||
background: ${rgba(colors.modalOverlay, 0)}; | ||
} | ||
} | ||
&& .ReactModal__Content { | ||
max-height: 90vh; | ||
max-width: 90vw; | ||
overflow: auto; | ||
z-index: ${zIndex.modal + 1}; | ||
} | ||
`; | ||
|
||
export { ModalHeading } from "@recidiviz/case-triage-components"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions
26
spotlight-client/src/contentApi/sources/methodologyBoilerplate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Recidiviz - a data platform for criminal justice reform | ||
// Copyright (C) 2021 Recidiviz, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
// ============================================================================= | ||
|
||
export const ageGroup = `In distributions by age, individuals are counted towards the | ||
age group they fall into as of the reporting date.`; | ||
|
||
export const gender = `Gender distributions only include male and female due to | ||
low numbers of other reported genders.`; | ||
|
||
export const raceOrEthnicity = `Distributions by race count individuals with more than | ||
one reported race or ethnicity towards the racial or ethnic identity that is least | ||
represented in the general population.`; |
Oops, something went wrong.