|
14 | 14 | import { describe, it, expect, vi, beforeAll, beforeEach, afterEach } from 'vitest'; |
15 | 15 | import { cleanup, render, waitFor } from '@testing-library/react'; |
16 | 16 | import * as React from 'react'; |
| 17 | +import { formatDate } from '@object-ui/fields'; |
17 | 18 | import { RelatedList } from '../RelatedList'; |
18 | 19 |
|
19 | 20 | beforeAll(() => { |
@@ -79,16 +80,23 @@ const drawCell = (row: Record<string, unknown>) => { |
79 | 80 | const col = (h.schema?.columns ?? []).find((c: any) => c.accessorKey === 'due_date'); |
80 | 81 | const { container } = render(<>{col.cell(row.due_date, row)}</>); |
81 | 82 | const span = container.querySelector('span.tabular-nums') as HTMLElement | null; |
82 | | - return { text: span?.textContent ?? '', red: !!span?.className.includes('text-red-600') }; |
| 83 | + return { |
| 84 | + text: span?.textContent ?? '', |
| 85 | + title: span?.getAttribute('title') ?? '', |
| 86 | + red: !!span?.className.includes('text-red-600'), |
| 87 | + }; |
83 | 88 | }; |
84 | 89 |
|
85 | 90 | describe('RelatedList — each child row is judged on its own (objectui#11815)', () => { |
86 | 91 | it("an open row's declared deadline reads overdue, a done row's reads neutral", async () => { |
87 | 92 | const ds = makeDataSource(); |
88 | 93 | renderList(ds); |
89 | 94 | await waitFor(() => expect((h.schema?.columns ?? []).some((c: any) => c.accessorKey === 'due_date')).toBe(true)); |
90 | | - expect(drawCell(ROWS[0])).toEqual({ text: 'Overdue 5d', red: true }); |
91 | | - expect(drawCell(ROWS[1])).toEqual({ text: '5 days ago', red: false }); |
| 95 | + // A table cell paints the absolute face and carries the relative phrase as |
| 96 | + // its tooltip (objectstack#26344), so the verdict reads in both. |
| 97 | + const absolute = formatDate(ROWS[0].due_date, undefined, { locale: 'en-US' }); |
| 98 | + expect(drawCell(ROWS[0])).toEqual({ text: absolute, title: 'Overdue 5d', red: true }); |
| 99 | + expect(drawCell(ROWS[1])).toEqual({ text: absolute, title: '5 days ago', red: false }); |
92 | 100 | }); |
93 | 101 |
|
94 | 102 | it("asks for the settledWhen's operand when no column shows it", async () => { |
|
0 commit comments