From 4fb566bc3af0dd069454471de8443d00c81afb3e Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 6 Jan 2022 17:43:42 +0100 Subject: [PATCH 1/4] change text --- components/frontend/src/metric/Metric.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/frontend/src/metric/Metric.js b/components/frontend/src/metric/Metric.js index 2ca8a6dcda..447baf1293 100644 --- a/components/frontend/src/metric/Metric.js +++ b/components/frontend/src/metric/Metric.js @@ -19,11 +19,12 @@ function MeasurementValue({ metric }) { const metricValue = get_metric_value(metric) const value = metricValue && metricType.unit === "minutes" && metric.scale !== "percentage" ? format_minutes(metricValue) : metricValue || "?"; const valueText = {value + metricUnit} + console.log(metric) if (metric.latest_measurement) { return ( - Last measured
- First measured + {metric.status ? "Metric was last measured":"Last measurement attempt"}
+ {metric.status ? "Value was first measured":"Value unknown since"}
) } From 9d43161381b772916b1b31dabcc2bd5957e98ccd Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 6 Jan 2022 18:04:50 +0100 Subject: [PATCH 2/4] add unittests --- components/frontend/src/metric/Metric.js | 3 +-- components/frontend/src/metric/Metric.test.js | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/components/frontend/src/metric/Metric.js b/components/frontend/src/metric/Metric.js index 447baf1293..01b9915f32 100644 --- a/components/frontend/src/metric/Metric.js +++ b/components/frontend/src/metric/Metric.js @@ -19,10 +19,9 @@ function MeasurementValue({ metric }) { const metricValue = get_metric_value(metric) const value = metricValue && metricType.unit === "minutes" && metric.scale !== "percentage" ? format_minutes(metricValue) : metricValue || "?"; const valueText = {value + metricUnit} - console.log(metric) if (metric.latest_measurement) { return ( - + {metric.status ? "Metric was last measured":"Last measurement attempt"}
{metric.status ? "Value was first measured":"Value unknown since"}
diff --git a/components/frontend/src/metric/Metric.test.js b/components/frontend/src/metric/Metric.test.js index 8b273733a5..92dd0f16b8 100644 --- a/components/frontend/src/metric/Metric.test.js +++ b/components/frontend/src/metric/Metric.test.js @@ -1,6 +1,6 @@ import React from 'react'; import { Table } from 'semantic-ui-react'; -import { render, screen } from '@testing-library/react'; +import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import { Metric } from './Metric'; import { DataModel } from '../context/DataModel'; @@ -84,3 +84,22 @@ it('renders the minutes as percentage', () => { expect(screen.getAllByText(/50% minutes/).length).toBe(1); expect(screen.getAllByText(/≦ 0% minutes/).length).toBe(1); }); + +it('renders correct popups with status', async () => { + render_metric("violations"); + fireEvent.mouseOver(screen.getByText(/50 violations/)); + + await waitFor(() => screen.getByTestId('value-popup')) + expect(screen.getAllByText(/Metric was last measured/).length).toBe(1); + expect(screen.getAllByText(/Value was first measured/).length).toBe(1); +}); + +it('renders correct popups without status', async () => { + report.subjects.subject_uuid.metrics.violations.status = null; + render_metric("violations"); + fireEvent.mouseOver(screen.getByText(/50 violations/)); + + await waitFor(() => screen.getByTestId('value-popup')) + expect(screen.getAllByText(/Last measurement attempt/).length).toBe(1); + expect(screen.getAllByText(/Value unknown since/).length).toBe(1); +}); From 4755dcf04e96f7423a812012deea0a2f7d1620d7 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 7 Jan 2022 18:40:55 +0100 Subject: [PATCH 3/4] use a different query in a unittest --- components/frontend/src/metric/Metric.js | 2 +- components/frontend/src/metric/Metric.test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/frontend/src/metric/Metric.js b/components/frontend/src/metric/Metric.js index 01b9915f32..8f66e7683c 100644 --- a/components/frontend/src/metric/Metric.js +++ b/components/frontend/src/metric/Metric.js @@ -21,7 +21,7 @@ function MeasurementValue({ metric }) { const valueText = {value + metricUnit} if (metric.latest_measurement) { return ( - + {metric.status ? "Metric was last measured":"Last measurement attempt"}
{metric.status ? "Value was first measured":"Value unknown since"}
diff --git a/components/frontend/src/metric/Metric.test.js b/components/frontend/src/metric/Metric.test.js index 92dd0f16b8..42056bfbb1 100644 --- a/components/frontend/src/metric/Metric.test.js +++ b/components/frontend/src/metric/Metric.test.js @@ -89,7 +89,7 @@ it('renders correct popups with status', async () => { render_metric("violations"); fireEvent.mouseOver(screen.getByText(/50 violations/)); - await waitFor(() => screen.getByTestId('value-popup')) + await waitFor(() => screen.getByText(/Metric was last measured/)) expect(screen.getAllByText(/Metric was last measured/).length).toBe(1); expect(screen.getAllByText(/Value was first measured/).length).toBe(1); }); @@ -99,7 +99,7 @@ it('renders correct popups without status', async () => { render_metric("violations"); fireEvent.mouseOver(screen.getByText(/50 violations/)); - await waitFor(() => screen.getByTestId('value-popup')) + await waitFor(() => screen.getByText(/Last measurement attempt/)) expect(screen.getAllByText(/Last measurement attempt/).length).toBe(1); expect(screen.getAllByText(/Value unknown since/).length).toBe(1); }); From 95467944e9f67d37aad5afb4a9a07ac20b41061f Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 7 Jan 2022 18:45:10 +0100 Subject: [PATCH 4/4] update changelog --- docs/src/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/changelog.md b/docs/src/changelog.md index 3e4e82bd62..645e52cbf1 100644 --- a/docs/src/changelog.md +++ b/docs/src/changelog.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Changed - Use users' full name instead of their username in the change log so it's easier to see who changed what. Closes [#2930](https://github.com/ICTU/quality-time/issues/2930). +- Improved tooltips for the measurement column in the metrics details table. Closes [#3171](https://github.com/ICTU/quality-time/issues/3171). ### Added