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 7953a66
Show file tree
Hide file tree
Showing 4 changed files with 30 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
25 changes: 23 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,23 @@ 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(undefined, {
day: "2-digit",
month: "2-digit",
year: "numeric",
})
expect(screen.getAllByText(RegExp(expectedDate)).length).toBe(1)

Check failure on line 56 in components/frontend/src/source/SourceEntity.test.jsx

View workflow job for this annotation

GitHub Actions / build (22.x)

src/source/SourceEntity.test.jsx > renders the status end date

TestingLibraryElementError: Unable to find an element with the text: /01\/01\/3000/. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body> <div> <table class="MuiTable-root css-1xwxv7r-MuiTable-root" > <tbody class="MuiTableBody-root css-gmh7jj-MuiTableBody-root" > <tr class="MuiTableRow-root MuiTableRow-hover warning_status css-14s2h72-MuiTableRow-root" style="max-height: 100px; overflow: auto;" > <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter MuiTableCell-sizeMedium css-5uomc5-MuiTableCell-root" > <button aria-label="Expand/collapse" class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-53g0n7-MuiButtonBase-root-MuiIconButton-root" tabindex="0" type="button" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-2rvbj4-MuiSvgIcon-root" data-testid="ArrowRightIcon" focusable="false" title="expand" viewBox="0 0 24 24" > <path d="m10 17 5-5-5-5z" /> </svg> </button> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > Fixed </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > 1/1/00 ( <time datetime="3000-01-01T00:00:00.000Z" title="3000-01-01 00:00" > 975 years from now </time> ) </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > <div class="with-html" style="word-break: break-word; overflow: auto; min-height: 15px; height: 0px;" /> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" /> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > <div style="word-break: break-word;" > good </div> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > <div style="word-break: break-word;" > bad </div> </td> </tr> </tbody> </table> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ getAllByText node_modules/@testing-library/dom/dist/query-helpers.js:109:15 ❯ src/source/SourceEntity.test.jsx:56:19

Check failure on line 56 in components/frontend/src/source/SourceEntity.test.jsx

View workflow job for this annotation

GitHub Actions / build (23.x)

src/source/SourceEntity.test.jsx > renders the status end date

TestingLibraryElementError: Unable to find an element with the text: /01\/01\/3000/. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body> <div> <table class="MuiTable-root css-1xwxv7r-MuiTable-root" > <tbody class="MuiTableBody-root css-gmh7jj-MuiTableBody-root" > <tr class="MuiTableRow-root MuiTableRow-hover warning_status css-14s2h72-MuiTableRow-root" style="max-height: 100px; overflow: auto;" > <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter MuiTableCell-sizeMedium css-5uomc5-MuiTableCell-root" > <button aria-label="Expand/collapse" class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-53g0n7-MuiButtonBase-root-MuiIconButton-root" tabindex="0" type="button" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-2rvbj4-MuiSvgIcon-root" data-testid="ArrowRightIcon" focusable="false" title="expand" viewBox="0 0 24 24" > <path d="m10 17 5-5-5-5z" /> </svg> </button> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > Fixed </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > 1/1/00 ( <time datetime="3000-01-01T00:00:00.000Z" title="3000-01-01 00:00" > 975 years from now </time> ) </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > <div class="with-html" style="word-break: break-word; overflow: auto; min-height: 15px; height: 0px;" /> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" /> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > <div style="word-break: break-word;" > good </div> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > <div style="word-break: break-word;" > bad </div> </td> </tr> </tbody> </table> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ getAllByText node_modules/@testing-library/dom/dist/query-helpers.js:109:15 ❯ src/source/SourceEntity.test.jsx:56:19

Check failure on line 56 in components/frontend/src/source/SourceEntity.test.jsx

View workflow job for this annotation

GitHub Actions / sonarcloud

src/source/SourceEntity.test.jsx > renders the status end date

TestingLibraryElementError: Unable to find an element with the text: /01\/01\/3000/. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body> <div> <table class="MuiTable-root css-1xwxv7r-MuiTable-root" > <tbody class="MuiTableBody-root css-gmh7jj-MuiTableBody-root" > <tr class="MuiTableRow-root MuiTableRow-hover warning_status css-14s2h72-MuiTableRow-root" style="max-height: 100px; overflow: auto;" > <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter MuiTableCell-sizeMedium css-5uomc5-MuiTableCell-root" > <button aria-label="Expand/collapse" class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-53g0n7-MuiButtonBase-root-MuiIconButton-root" tabindex="0" type="button" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-2rvbj4-MuiSvgIcon-root" data-testid="ArrowRightIcon" focusable="false" title="expand" viewBox="0 0 24 24" > <path d="m10 17 5-5-5-5z" /> </svg> </button> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > Fixed </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > 1/1/00 ( <time datetime="3000-01-01T00:00:00.000Z" title="3000-01-01 00:00" > 975 years from now </time> ) </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > <div class="with-html" style="word-break: break-word; overflow: auto; min-height: 15px; height: 0px;" /> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" /> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > <div style="word-break: break-word;" > good </div> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-1txchmq-MuiTableCell-root" > <div style="word-break: break-word;" > bad </div> </td> </tr> </tbody> </table> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ getAllByText node_modules/@testing-library/dom/dist/query-helpers.js:109:15 ❯ src/source/SourceEntity.test.jsx:56:19
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(undefined, {
day: "2-digit",
month: "2-digit",
year: "numeric",
})
expect(screen.queryAllByText(RegExp(expectedDate)).length).toBe(0)
await expectNoAccessibilityViolations(container)
})

Expand All @@ -71,7 +87,12 @@ 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(undefined, {
day: "2-digit",
month: "2-digit",
year: "numeric",
})
expect(screen.getAllByText(RegExp(expectedDate)).length).toBe(1)

Check failure on line 95 in components/frontend/src/source/SourceEntity.test.jsx

View workflow job for this annotation

GitHub Actions / build (22.x)

src/source/SourceEntity.test.jsx > renders the status and rationale past end date

TestingLibraryElementError: Unable to find an element with the text: /01\/01\/2000/. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body> <div> <table class="MuiTable-root css-1xwxv7r-MuiTable-root" > <tbody class="MuiTableBody-root css-gmh7jj-MuiTableBody-root" > <tr class="MuiTableRow-root MuiTableRow-hover warning_status css-14s2h72-MuiTableRow-root" style="max-height: 100px; overflow: auto;" > <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter MuiTableCell-sizeMedium css-5uomc5-MuiTableCell-root" > <button aria-label="Expand/collapse" class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-53g0n7-MuiButtonBase-root-MuiIconButton-root" tabindex="0" type="button" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-2rvbj4-MuiSvgIcon-root" data-testid="ArrowRightIcon" focusable="false" title="expand" viewBox="0 0 24 24" > <path d="m10 17 5-5-5-5z" /> </svg> </button> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > Fixed </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > 1/1/00 ( <time datetime="2000-01-01T00:00:00.000Z" title="2000-01-01 00:00" > 25 years ago </time> ) </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > <div class="with-html" style="word-break: break-word; overflow: auto; min-height: 15px; height: 0px;" > Because </div> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" /> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > <div style="word-break: break-word;" > good </div> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > <div style="word-break: break-word;" > bad </div> </td> </tr> </tbody> </table> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ getAllByText node_modules/@testing-library/dom/dist/query-helpers.js:109:15 ❯ src/source/SourceEntity.test.jsx:95:19

Check failure on line 95 in components/frontend/src/source/SourceEntity.test.jsx

View workflow job for this annotation

GitHub Actions / build (23.x)

src/source/SourceEntity.test.jsx > renders the status and rationale past end date

TestingLibraryElementError: Unable to find an element with the text: /01\/01\/2000/. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body> <div> <table class="MuiTable-root css-1xwxv7r-MuiTable-root" > <tbody class="MuiTableBody-root css-gmh7jj-MuiTableBody-root" > <tr class="MuiTableRow-root MuiTableRow-hover warning_status css-14s2h72-MuiTableRow-root" style="max-height: 100px; overflow: auto;" > <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter MuiTableCell-sizeMedium css-5uomc5-MuiTableCell-root" > <button aria-label="Expand/collapse" class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-53g0n7-MuiButtonBase-root-MuiIconButton-root" tabindex="0" type="button" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-2rvbj4-MuiSvgIcon-root" data-testid="ArrowRightIcon" focusable="false" title="expand" viewBox="0 0 24 24" > <path d="m10 17 5-5-5-5z" /> </svg> </button> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > Fixed </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > 1/1/00 ( <time datetime="2000-01-01T00:00:00.000Z" title="2000-01-01 00:00" > 25 years ago </time> ) </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > <div class="with-html" style="word-break: break-word; overflow: auto; min-height: 15px; height: 0px;" > Because </div> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" /> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > <div style="word-break: break-word;" > good </div> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > <div style="word-break: break-word;" > bad </div> </td> </tr> </tbody> </table> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ getAllByText node_modules/@testing-library/dom/dist/query-helpers.js:109:15 ❯ src/source/SourceEntity.test.jsx:95:19

Check failure on line 95 in components/frontend/src/source/SourceEntity.test.jsx

View workflow job for this annotation

GitHub Actions / sonarcloud

src/source/SourceEntity.test.jsx > renders the status and rationale past end date

TestingLibraryElementError: Unable to find an element with the text: /01\/01\/2000/. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body> <div> <table class="MuiTable-root css-1xwxv7r-MuiTable-root" > <tbody class="MuiTableBody-root css-gmh7jj-MuiTableBody-root" > <tr class="MuiTableRow-root MuiTableRow-hover warning_status css-14s2h72-MuiTableRow-root" style="max-height: 100px; overflow: auto;" > <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter MuiTableCell-sizeMedium css-5uomc5-MuiTableCell-root" > <button aria-label="Expand/collapse" class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-53g0n7-MuiButtonBase-root-MuiIconButton-root" tabindex="0" type="button" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-2rvbj4-MuiSvgIcon-root" data-testid="ArrowRightIcon" focusable="false" title="expand" viewBox="0 0 24 24" > <path d="m10 17 5-5-5-5z" /> </svg> </button> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > Fixed </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > 1/1/00 ( <time datetime="2000-01-01T00:00:00.000Z" title="2000-01-01 00:00" > 25 years ago </time> ) </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > <div class="with-html" style="word-break: break-word; overflow: auto; min-height: 15px; height: 0px;" > Because </div> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" /> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > <div style="word-break: break-word;" > good </div> </td> <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-mbbdxc-MuiTableCell-root" > <div style="word-break: break-word;" > bad </div> </td> </tr> </tbody> </table> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ getAllByText node_modules/@testing-library/dom/dist/query-helpers.js:109:15 ❯ src/source/SourceEntity.test.jsx:95:19
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 7953a66

Please sign in to comment.