Skip to content

Commit

Permalink
Correctly format the measurement entity status end dates in the measu…
Browse files Browse the repository at this point in the history
…rement details table.

Fixes #10907.
  • Loading branch information
fniessink committed Feb 26, 2025
1 parent 8537157 commit aea3b01
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion components/frontend/src/source/SourceEntity.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export function SourceEntity({
style={{ maxHeight: "100px", overflow: "auto" }}
>
<TableCell sx={style}>{SOURCE_ENTITY_STATUS_NAME[status]}</TableCell>
<TableCell sx={style}>{status === "unconfirmed" ? "" : status_end_date}</TableCell>
<TableCell sx={style}>
{status === "unconfirmed" ? "" : <TimeAgoWithDate dateFirst noTime date={status_end_date} />}
</TableCell>
<TableCell sx={style}>
<DivWithHTML>{rationale}</DivWithHTML>
</TableCell>
Expand Down
13 changes: 11 additions & 2 deletions components/frontend/src/source/SourceEntity.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ it("renders the fixed status", async () => {

it("renders the status end date", async () => {
const { container } = renderSourceEntity({ status: "fixed", status_end_date: "3000-01-01" })
expect(screen.getAllByText(/3000-01-01/).length).toBe(1)
const expectedDate = new Date("3000-01-01").toLocaleDateString([], { dateStyle: "short" })
expect(screen.getAllByText(RegExp(expectedDate)).length).toBe(1)
await expectNoAccessibilityViolations(container)
})

it("does not render the status end date if the status is unconfirmed", async () => {
const { container } = renderSourceEntity({ status: "unconfirmed", status_end_date: "3000-01-01" })
const expectedDate = new Date("3000-01-01").toLocaleDateString([], { dateStyle: "short" })
expect(screen.queryAllByText(RegExp(expectedDate)).length).toBe(0)
await expectNoAccessibilityViolations(container)
})

Expand All @@ -71,7 +79,8 @@ it("renders the status and rationale past end date", async () => {
hide_ignored_entities: true,
rationale: "Because",
})
expect(screen.getAllByText(/2000-01-01/).length).toBe(1)
const expectedDate = new Date("2000-01-01").toLocaleDateString([], { dateStyle: "short" })
expect(screen.getAllByText(RegExp(expectedDate)).length).toBe(1)
expect(screen.getAllByText(/Because/).length).toBe(1)
await expectNoAccessibilityViolations(container)
})
Expand Down
3 changes: 3 additions & 0 deletions components/frontend/src/widgets/TimeAgoWithDate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ function toLocaleString(date, noTime) {
}

export function TimeAgoWithDate({ children, date, dateFirst, noTime }) {
if (!date) {
return null
}
const the_date = new Date(date)
const prefix = children ? children + " " : ""
if (dateFirst) {
Expand Down
1 change: 1 addition & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ If your currently installed *Quality-time* version is not the latest version, pl
- The software documentation was outdated (among other things, the API-server health check endpoint). Fixes [#10858](https://github.com/ICTU/quality-time/issues/10858).
- Keep the footer at the bottom of the page even if the report is very short. Fixes [#10877](https://github.com/ICTU/quality-time/issues/10877).
- Automatically expand long comments when exporting to PDF. Fixes [#10892](https://github.com/ICTU/quality-time/issues/10892).
- Correctly format the measurement entity status end dates in the measurement details table. Fixes [#10907](https://github.com/ICTU/quality-time/issues/10907).

### Removed

Expand Down

0 comments on commit aea3b01

Please sign in to comment.