-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When showing measurements on multiple dates, also allow for having co…
…lumns that show the delta between dates. The delta columns can be turned on and off via the Settings panel. Closes #7039.
- Loading branch information
Showing
7 changed files
with
212 additions
and
20 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
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import history from 'history/browser'; | ||
import { Table } from '../semantic_ui_react_wrappers'; | ||
import { DataModel } from "../context/DataModel"; | ||
import { SubjectTableRow } from './SubjectTableRow'; | ||
import { createTestableSettings, datamodel, report } from "../__fixtures__/fixtures"; | ||
|
||
beforeEach(() => { | ||
history.push("") | ||
}) | ||
|
||
function renderSubjectTableRow(direction, ascending, scale) { | ||
const dates = [new Date("2024-01-03"), new Date("2024-01-02"), new Date("2024-01-01")] | ||
const reverseMeasurements = [ | ||
{ metric_uuid: "metric_uuid", start: "2024-01-03T00:00", end: "2024-01-03T00:00", count: { value: 8, status: "target_met" }, version_number: { value: "0.8", status: "target_met" } }, | ||
{ metric_uuid: "metric_uuid", start: "2024-01-02T00:00", end: "2024-01-02T00:00", count: { value: 12, status: "target_met" }, version_number: { value: "1.2", status: "target_met" } }, | ||
{ metric_uuid: "metric_uuid", start: "2024-01-01T00:00", end: "2024-01-01T00:00", count: { value: 10, status: "target_met" }, version_number: { value: "1.0", status: "target_met" } }, | ||
] | ||
if (ascending) { | ||
dates.reverse() | ||
} | ||
render( | ||
<DataModel.Provider value={datamodel}> | ||
<Table> | ||
<Table.Body> | ||
<SubjectTableRow | ||
dates={dates} | ||
measurements={[]} | ||
metric={{ type: "metric_type", direction: direction ?? "<", recent_measurements: [], scale: scale ?? "count" }} | ||
metric_uuid="metric_uuid" | ||
report={report} | ||
reversedMeasurements={reverseMeasurements} | ||
settings={createTestableSettings()} | ||
/> | ||
</Table.Body> | ||
</Table> | ||
</DataModel.Provider> | ||
) | ||
} | ||
|
||
it('shows the delta column', () => { | ||
history.push("?nr_dates=3&date_interval=1") | ||
renderSubjectTableRow() | ||
expect(screen.getAllByText("+2").length).toBe(1); | ||
expect(screen.getAllByLabelText("The measurement value worsened with +2").length).toBe(1); | ||
expect(screen.getAllByText("-4").length).toBe(1); | ||
expect(screen.getAllByLabelText("The measurement value improved with -4").length).toBe(1); | ||
}) | ||
|
||
it('hides the delta column', () => { | ||
history.push("?nr_dates=2&hidden_columns=delta") | ||
renderSubjectTableRow() | ||
expect(screen.queryAllByText("+2").length).toBe(0); | ||
}) | ||
|
||
it('takes the metric direction into account', () => { | ||
history.push("?nr_dates=3&date_interval=1") | ||
renderSubjectTableRow(">") | ||
expect(screen.getAllByText("+2").length).toBe(1); | ||
expect(screen.getAllByLabelText("The measurement value improved with +2").length).toBe(1); | ||
expect(screen.getAllByText("-4").length).toBe(1); | ||
expect(screen.getAllByLabelText("The measurement value worsened with -4").length).toBe(1); | ||
}) | ||
|
||
it('takes the date order into account', () => { | ||
history.push("?nr_dates=3&date_interval=1&date_order=ascending") | ||
renderSubjectTableRow("<", true) | ||
expect(screen.getAllByText("+2").length).toBe(1); | ||
expect(screen.getAllByLabelText("The measurement value worsened with +2").length).toBe(1); | ||
expect(screen.getAllByText("-4").length).toBe(1); | ||
expect(screen.getAllByLabelText("The measurement value improved with -4").length).toBe(1); | ||
}) | ||
|
||
it('shows the delta column for the version scale', () => { | ||
history.push("?nr_dates=3&date_interval=1") | ||
renderSubjectTableRow("<", false, "version_number") | ||
expect(screen.getAllByText("+").length).toBe(1); | ||
expect(screen.getAllByLabelText("The measurement value worsened").length).toBe(1); | ||
expect(screen.getAllByText("-").length).toBe(1); | ||
expect(screen.getAllByLabelText("The measurement value improved").length).toBe(1); | ||
}) |
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