Skip to content

Commit 95734fe

Browse files
fix(plugin-list): date condition chips read as dates; showcase zh-CN region labels (#37154)
repo:objectstack#4 · os-justin · session_01QSeKYnagJvGbCtNg2PhvgW Fixes #37034 Clause-②: no Metadata-protocol: none ## 维护者速读 - 中文界面下,仪表盘钻取弹窗、所有列表的筛选条件(电脑端的条件标签和手机端的筛选面板)里的日期,从「≥ 2026-10-01T00:00:00.000Z」变为「≥ 2026年10月1日 00:00」这类本地日期;示例应用的发票「区域」、客户「销售区域」字段及其选项显示中文。 - 属于「仪表盘与报表」专项的验收发现,目的是让中文界面不再夹杂原始日期串和英文字段名。 - 若出错,只影响筛选条件上日期的显示文字,查询本身不变;可直接撤回。 - 无。 ## What changes Sightings 1 and 2 of the card are fixed here. Sightings 3 and 4 are closed as by design under ruling record 7145739965 (the maintainer: 「同意」), and this PR does not touch them: the in-page edit state's filter bar shows the stored text, and a new widget's default 「New TYPE」 title is English author data (objectui#10678 / objectui#10651). - **Date conditions read as dates (`@object-ui/plugin-list`).** `describeConditionValue` printed a date-family condition value with `String()`. It now formats the value with the new `formatConditionDate` (`conditions/conditionDates.ts`), on every condition row: the reader's chips, the view's locked chips, related-field view chips, and the phone filter sheet's rows. `formatConditionDate` is a thin selector over the console's one date display path, `formatDate` / `formatDateTime` from `@object-ui/core`; no second formatter is written. The locale comes from `useDisplayLocale()`, and `describeConditionValue`'s `locale` is now required, so no caller can fall back to the runtime's default locale by leaving it out. - A `date` field's bound is written on the wire as `YYYY-MM-DD` and shows that day with its year. An instant at UTC midnight on a date field shows the same calendar day in every zone. - A `datetime` field's bound is an ISO instant and shows the date and time in the display zone. - A `time` field, or a value the display path cannot read, is shown as written. - The filter sent to the server is unchanged. - **The phone filter sheet (`phone/PhoneListPanels.tsx`).** Its condition rows now pass `useDisplayLocale()`. Before this, a zh-CN session on an English browser would have read 「Oct 1, 2026」 there. - **The drilled month bucket.** The drill's condition writer (`plugin-dashboard` `drillConditions.ts`) already writes a bucket's `{ $gte, $lt }` as two rows, `greater_than_or_equal` and `before`. Both now read as dates: on the card's `created_at` they read 「创建时间:≥ 2026年10月1日 00:00」 and 「创建时间:早于 2026年11月1日 00:00」 (display zone UTC). The writer is unchanged, and a new test pins its two rows. No date-family operator means "on or after", and `after` (`>`) would drop the records at the bound, so the lower bound keeps `>=` (L1 accepted). A month bucket shows as its date range, not as 「2026-10」, because the row carries no granularity (ruling item 1). - **Missing showcase translation.** `examples/app-showcase/src/system/translations/index.ts` zh-CN gains `fields.showcase_invoice.region` (区域, with option labels 美洲 / 欧洲、中东和非洲 / 亚太, matching the dashboard filter's own translation) and `fields.showcase_account.sales_region` (销售区域, same options). The drill chip already reads the translated field label. It does not read the dashboard filter's name (ruling item 2). `scripts/i18n-coverage-baseline.json` lowers app-showcase's ceiling from 449 to 441, a one-line hand edit with no `--update`. ## Tests - `listConditions.test.tsx` gains a top-level `describe` for objectstack#37034. It mounts the real `ConditionChipRow` and `PhoneFilterSheet` under the real zh-CN `I18nProvider`, with the display zone pinned by `setDisplayTimeZone('UTC')`, and checks: - the sighting: a `created_at` datetime month bucket shows ≥ / 早于 chips reading 2026年10月1日 00:00 and 2026年11月1日 00:00; - a date field's `YYYY-MM-DD` bounds read as days; - a date field compared with a UTC-midnight instant reads as that day; - a datetime reads in the display zone; - a date `between` reads both ends as dates; - the phone sheet's row reads 「≥ 2026年10月1日」 while the runtime's own locale is English; - control: a `time` value and an unreadable date are shown as written. - `drillConditions-36256.test.ts` pins the month bucket's two rows (operator and exact value). - Ablation (one-off, source path; the test imports the module relatively, so no `dist/` is involved): readings are in the block below. <details><summary>Ablations and readings at head a582829 (worktree; overlap-check against origin/main 49c8e0f and PR 37059: clean)</summary> - Formatter ablation (`scripts/ablation-replace.mjs` on `ListConditionControls.tsx`): `(v: unknown) => formatConditionDate(v, field?.type, locale) : String` became `String : String`. Result: 6 failed and 1 passed (the control). The sighting case received exactly 「创建时间:≥ 2026-10-01T00:00:00.000Z」, the card's sighting. The other failures received 「开具日期:≥ 2026-10-01」, 「开具日期:≥ 2026-10-01T00:00:00.000Z」, 「开具日期:介于 2026-10-01 – 2026-10-31」 and, on the phone row, 「≥ 2026-10-01」. Restore: blob 50a6518 after restore equals HEAD, and `git diff HEAD` was empty. - Phone-row ablation (`PhoneListPanels.tsx`, the row's `locale` replaced with `undefined`): the phone case failed with 「≥ Oct 1, 2026」, the mixed-language row L1 predicted. Restore: blob 0b70cd7 equals HEAD, and `git diff HEAD` was empty. - In the previous round, a first formatter ablation used too narrow an anchor, which turned the selector into a function returning `String`. It was invalid and was discarded. - `cd ui && pnpm exec vitest run --maxWorkers=2 packages/plugin-list/ packages/plugin-dashboard/`: Test Files 404 passed (404), Tests 4167 passed and 6 skipped; lock VERDICT command-exit 0. - type-check for `@object-ui/plugin-list` and `@object-ui/plugin-dashboard`: exit 0. - `pnpm check:i18n`: exit 0. `pnpm check:i18n-coverage`: exit 0 ("OK (14 config(s), 577 baselined untranslated string(s), none new)"), with the app-showcase ceiling at 441. - Derived gate list (66 commands): 65 exit 0, 1 NOT MEASURED. `check:dual-build-cjs-loads` exited 3 (PREREQUISITE NOT MET: no full `pnpm build` here); CI runs it. `--ran` reconciliation: 66 derived, 65 run, 1 NOT-MEASURED, 0 UNRUN. - `playwright test --project=chromium --list`: exit 0, 202 tests in 35 files. No spec reads the changed text. - Not run locally: `test:repo`, the full turbo suite and the browser check. </details> ## Acceptance notes - A naive `datetime-local` value (no offset, such as `2026-10-01T09:00`, which the advanced panel's datetime input writes) parses in the browser's zone but is shown in the display zone. When a host declares a display zone that differs from the browser's, such a chip can read a different hour than was typed. This is the existing behaviour of the shared date display path, not a change here. - The drill writer keeps `>=` for a bucket's lower bound (see What changes). ## Verification Two-minute check: in a zh-CN session, open the showcase's 营收概览(带筛选) dashboard and click a month bar on 「Invoices by Month」. The drill dialog's chips should read 「区域:欧洲、中东和非洲」-style (with a region picked) and 「开具日期:≥ 2026年…月1日」 / 「开具日期:早于 …」, with no ISO string. On a datetime field such as `created_at`, the chips show the date and time. Read first: `ui/packages/plugin-list/src/conditions/conditionDates.ts` (the type-to-face rule, and the UTC-midnight day rule) and the `describeConditionValue` hunk in `ListConditionControls.tsx` (`locale` is now required). --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 6cfd04d commit 95734fe

8 files changed

Lines changed: 234 additions & 22 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@object-ui/plugin-list': patch
3+
---
4+
5+
fix(plugin-list): a date condition's value reads as a date in the viewer's language
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A list condition chip on a date field printed the stored value as written, so a
11+
drilled dashboard bucket read 「创建时间:≥ 2026-10-01T00:00:00.000Z」 in a zh-CN
12+
session. Every condition row (the reader's chips and the view's locked chips) now
13+
formats a date-family value by the field's type through the console's one date
14+
display path (`formatDate` / `formatDateTime` from `@object-ui/core`), in the
15+
display locale: a `date` field shows the day with its year (an instant at UTC
16+
midnight shows that calendar day in every zone), a `datetime` field shows the
17+
date and time in the display zone, and a `time` field or an unreadable value is
18+
shown as written. The filter the list sends is unchanged.

‎examples/app-showcase/src/system/translations/index.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,10 @@ export const ShowcaseTranslationBundle = {
624624
billing_email: { label: '账单邮箱' },
625625
support_config: { label: '支持配置' },
626626
churn_reason: { label: '流失原因' },
627+
// The account side of the Revenue Pulse region filter
628+
// (`filterBindings: { region: 'sales_region' }`), worded as the
629+
// dataset's dimension describes it (销售区域).
630+
sales_region: { label: '销售区域', options: { amer: '美洲', emea: '欧洲、中东和非洲', apac: '亚太' } },
627631
},
628632
// The zh-CN mirror of the `en` `_validations` block — see the note
629633
// there. Vocabulary is the one this bundle already established:
@@ -758,6 +762,10 @@ export const ShowcaseTranslationBundle = {
758762
owner: { label: '负责人邮箱' },
759763
status: { label: '状态' },
760764
issued_on: { label: '开具日期' },
765+
// The Revenue Pulse dashboard's region filter lands on this field, so
766+
// a drilled list's chip names it: the same words as the dashboard's
767+
// own filter label and options (`dashboards.showcase_revenue_pulse`).
768+
region: { label: '区域', options: { amer: '美洲', emea: '欧洲、中东和非洲', apac: '亚太' } },
761769
tax_rate: { label: '税率 (%)' },
762770
paid_on: { label: '付款日期' },
763771
total: { label: '小计' },

‎scripts/i18n-coverage-baseline.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"examples/app-crm/objectstack.config.ts": 0,
33
"examples/app-multi-package/objectstack.config.ts": 0,
4-
"examples/app-showcase/objectstack.config.ts": 449,
4+
"examples/app-showcase/objectstack.config.ts": 441,
55
"examples/app-todo/objectstack.config.ts": 136,
66
"packages/platform-objects/scripts/i18n-extract.config.ts": 0,
77
"packages/plugins/plugin-approvals/scripts/i18n-extract.config.ts": 0,

‎ui/packages/plugin-dashboard/src/__tests__/drillConditions-36256.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@ describe('drillListConditions', () => {
5757
]);
5858
});
5959

60+
it("writes a dataset month bucket's range as two date rows that compare exactly what the bucket counted (objectstack#37034)", () => {
61+
// The dataset answer's drill range for 2026-10: `{ $gte, $lt }`, ISO
62+
// instants (core's dataset-format). The list's chip reads each bound as a
63+
// date (plugin-list `formatConditionDate`); the value stays the one the
64+
// query compares. No date-family operator says "on or after", and `after`
65+
// (>) would drop the records at the bound, so the lower bound keeps `>=`.
66+
const { chips, rest } = drillListConditions(
67+
{ issued_on: { $gte: '2026-10-01T00:00:00.000Z', $lt: '2026-11-01T00:00:00.000Z' } },
68+
{ dateFields: new Set(['issued_on']) },
69+
);
70+
expect(rest).toBeUndefined();
71+
expect(chips.conditions.map((c) => [c.field, c.operator, c.value])).toEqual([
72+
['issued_on', 'greater_than_or_equal', '2026-10-01T00:00:00.000Z'],
73+
['issued_on', 'before', '2026-11-01T00:00:00.000Z'],
74+
]);
75+
});
76+
6077
it("lowers a page block's rule array, and an AST node, to chips", () => {
6178
// HotCRM's 销售主页 KPI tile: the spec's rule-array form, handed as written.
6279
expect(drillListConditions([{ field: 'stage', operator: 'equals', value: 'closed_won' }]).chips.conditions

‎ui/packages/plugin-list/src/conditions/ListConditionControls.tsx‎

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ import {
4343
type SortItem,
4444
} from '@object-ui/components';
4545
import { referencedRecordTitle } from '@object-ui/core';
46+
import { formatConditionDate } from './conditionDates';
4647
import type { DataSource } from '@object-ui/types';
47-
import { useSafeFieldLabel } from '@object-ui/i18n';
48+
import { useDisplayLocale, useSafeFieldLabel } from '@object-ui/i18n';
4849
import { ArrowDown, ArrowUp, ArrowUpDown, ListFilter, Lock, Plus, RotateCcw, SlidersHorizontal, X } from 'lucide-react';
4950
import { FieldList, type FieldListItem } from './FieldList';
5051
import { FilterValuePanel, isQuickRowApplied, quickDateWindowOf } from './FilterValuePanel';
@@ -84,14 +85,17 @@ export type LookupValueName = (field: string, id: string) => string | undefined;
8485
/**
8586
* The value half of a chip: 「Negotiation, Proposal」, 「≥ 100」, 「Today」.
8687
* A lookup's value is the referenced record's name when `nameOf` has it, and
87-
* its id only when the name cannot be read.
88+
* its id only when the name cannot be read. A date field's value reads as a
89+
* date in `locale` (`formatConditionDate`), never as the stored ISO string.
8890
*/
8991
export function describeConditionValue(
9092
field: ConditionField | undefined,
9193
operator: string,
9294
value: unknown,
9395
t: Translate,
94-
nameOf?: LookupValueName,
96+
nameOf: LookupValueName | undefined,
97+
// Required, so no caller formats a date in the runtime's default locale by omission.
98+
locale: string,
9599
): string {
96100
const opLabel = quickOperatorLabel(operator, t);
97101
if (isValuelessOperator(operator)) return opLabel;
@@ -102,16 +106,17 @@ export function describeConditionValue(
102106
// A named window says what it is on its own: 「Today」, not 「between Today」.
103107
const window = family === 'date' && operator === 'between' ? quickDateWindowOf(value as FilterBuilderRow['value']) : undefined;
104108
if (window) return quickDateWindowLabel(window, t);
109+
const shown = family === 'date' ? (v: unknown) => formatConditionDate(v, field?.type, locale) : String;
105110
if (family === 'boolean') {
106111
text = list.map((v) => (v === true || v === 'true' ? t('listConditions.filter.yes') : t('listConditions.filter.no'))).join(joiner);
107112
} else if (operator === 'between') {
108-
text = list.map(String).join(' – ');
113+
text = list.map(shown).join(' – ');
109114
} else if (family === 'option') {
110115
text = list.map((v) => optionLabel(field, v)).join(joiner);
111116
} else if (family === 'lookup' && field && nameOf) {
112117
text = list.map((v) => nameOf(field.value, String(v)) ?? String(v)).join(joiner);
113118
} else {
114-
text = list.map(String).join(joiner);
119+
text = list.map(shown).join(joiner);
115120
}
116121
// 「is any of」 is what a value list means on its own; every other operator is
117122
// named, and with no value it is the operator alone, never one with a trailing space.
@@ -125,23 +130,25 @@ function chipText(
125130
operator: string,
126131
value: unknown,
127132
t: Translate,
128-
nameOf?: LookupValueName,
133+
nameOf: LookupValueName | undefined,
134+
locale: string,
129135
) {
130136
return t('listConditions.chips.pattern', {
131137
field: field?.label ?? fieldName ?? '',
132-
value: describeConditionValue(field, operator, value, t, nameOf),
138+
value: describeConditionValue(field, operator, value, t, nameOf, locale),
133139
});
134140
}
135141

136142
function viewChipText(
137143
chip: ViewConditionChip,
138144
fields: ReadonlyArray<ConditionField>,
139145
t: Translate,
140-
nameOf?: LookupValueName,
141-
relatedFieldOf?: RelatedFieldOf,
146+
nameOf: LookupValueName | undefined,
147+
relatedFieldOf: RelatedFieldOf | undefined,
148+
locale: string,
142149
): string {
143150
if (chip.anyOf) {
144-
return chip.anyOf.map((member) => viewChipText(member, fields, t, nameOf, relatedFieldOf)).join(t('listConditions.chips.or'));
151+
return chip.anyOf.map((member) => viewChipText(member, fields, t, nameOf, relatedFieldOf, locale)).join(t('listConditions.chips.or'));
145152
}
146153
if (!chip.field || !chip.operator) return t('listConditions.chips.viewFilter');
147154
const path = relationPathOf(chip.field);
@@ -156,11 +163,11 @@ function viewChipText(
156163
});
157164
return t('listConditions.chips.pattern', {
158165
field: label,
159-
value: describeConditionValue(related, chip.operator, chip.value, t),
166+
value: describeConditionValue(related, chip.operator, chip.value, t, undefined, locale),
160167
});
161168
}
162169
const field = fields.find((f) => f.value === chip.field);
163-
return chipText(field, chip.field, chip.operator, chip.value, t, nameOf);
170+
return chipText(field, chip.field, chip.operator, chip.value, t, nameOf, locale);
164171
}
165172

166173
// ---------------------------------------------------------------------------
@@ -659,6 +666,7 @@ export function ConditionChipRow({
659666
className,
660667
}: ConditionChipRowProps) {
661668
const { t } = useListConditionTranslation();
669+
const locale = useDisplayLocale();
662670
const [openChip, setOpenChip] = React.useState<string | null>(null);
663671

664672
// Keyed on the names, not on the array the host may rebuild every render.
@@ -773,7 +781,7 @@ export function ConditionChipRow({
773781
)}
774782

775783
{viewChips.map((chip) => {
776-
const text = viewChipText(chip, filterFields, t, nameOf, relatedFieldOf);
784+
const text = viewChipText(chip, filterFields, t, nameOf, relatedFieldOf, locale);
777785
return (
778786
<span
779787
key={chip.key}
@@ -793,7 +801,7 @@ export function ConditionChipRow({
793801
{independent
794802
? appliedRows.map((row) => {
795803
const field = fieldOf(filterFields, row.field);
796-
const text = chipText(field, row.field, row.operator, row.value, t, nameOf);
804+
const text = chipText(field, row.field, row.operator, row.value, t, nameOf, locale);
797805
return (
798806
<span
799807
key={row.id}

‎ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx‎

Lines changed: 107 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* which the host owns: one click is spent before any of these panels mounts.
1515
*/
1616

17-
import { describe, it, expect, vi } from 'vitest';
17+
import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest';
1818
import * as React from 'react';
1919
import { act, fireEvent, render, screen, within } from '@testing-library/react';
2020
import type { FilterBuilderRowGroup, SortItem } from '@object-ui/components';
@@ -40,6 +40,8 @@ import { builtInLocales, en as enPack, zh as zhPack } from '@object-ui/i18n/loca
4040
import { I18nProvider } from '@object-ui/i18n';
4141
import { parseFilterAST } from '@objectstack/spec/data';
4242
import { convertFilterGroupToAST } from '../../ListView';
43+
import { PhoneFilterSheet } from '../../phone/PhoneListPanels';
44+
import { setDisplayTimeZone } from '@object-ui/core';
4345

4446
// The server's JSON-column refusal set, read from the module every server face
4547
// imports it from (`@objectstack/core`, which no UI package depends on): the
@@ -550,7 +552,7 @@ describe('multi-value fields — the quick filter and the advanced panel offer o
550552
const enQuick = enPack.listConditions.operators as Record<string, string>;
551553
expect(MULTI_OFFER.map((op) => enQuick[op])).toEqual(['contains', 'does not contain', 'is empty', 'is not empty']);
552554
const t = (key: string) => LIST_CONDITION_DEFAULT_TRANSLATIONS[key] ?? key;
553-
expect(describeConditionValue(MULTI_VALUE[0], 'contains', 'quality_lead', t as never)).toBe('contains Quality lead');
555+
expect(describeConditionValue(MULTI_VALUE[0], 'contains', 'quality_lead', t as never, undefined, 'en-US')).toBe('contains Quality lead');
554556
});
555557
});
556558

@@ -763,10 +765,10 @@ describe('condition model', () => {
763765
it('describes a chip value by operator: a bare list for 「is any of」, the operator named otherwise', () => {
764766
const t = (key: string, o?: Record<string, unknown>) =>
765767
(LIST_CONDITION_DEFAULT_TRANSLATIONS[key] ?? key).replace(/\{\{(\w+)\}\}/g, (_, k) => String(o?.[k] ?? ''));
766-
expect(describeConditionValue(STAGE, 'in', ['proposal', 'negotiation'], t as never)).toBe('Proposal, Negotiation');
767-
expect(describeConditionValue(FIELDS[2], 'greater_than_or_equal', 100, t as never)).toBe('≥ 100');
768-
expect(describeConditionValue(FIELDS[3], 'between', quickDateWindowValue('today'), t as never)).toBe('Today');
769-
expect(describeConditionValue(STAGE, 'is_empty', undefined, t as never)).toBe('is empty');
768+
expect(describeConditionValue(STAGE, 'in', ['proposal', 'negotiation'], t as never, undefined, 'en-US')).toBe('Proposal, Negotiation');
769+
expect(describeConditionValue(FIELDS[2], 'greater_than_or_equal', 100, t as never, undefined, 'en-US')).toBe('≥ 100');
770+
expect(describeConditionValue(FIELDS[3], 'between', quickDateWindowValue('today'), t as never, undefined, 'en-US')).toBe('Today');
771+
expect(describeConditionValue(STAGE, 'is_empty', undefined, t as never, undefined, 'en-US')).toBe('is empty');
770772
});
771773
});
772774

@@ -1104,3 +1106,102 @@ describe('ConditionChipRow — an operator only the advanced panel writes (objec
11041106
expect(chipTexts()).toEqual(['Deal Value: >= 10', 'Deal Value: != 0']);
11051107
});
11061108
});
1109+
1110+
// objectstack#37034 — a date condition's value reads as a date in the viewer's
1111+
// language, by the field's type, on every condition row (the desktop chips and
1112+
// the phone filter sheet's rows). On the wire a `date` bound is `YYYY-MM-DD`
1113+
// and a `datetime` bound an ISO instant: the card's sighting was a drilled
1114+
// month bucket on `created_at`, 「创建时间:≥ 2026-10-01T00:00:00.000Z」.
1115+
// The display zone is pinned to UTC, so an instant's day and time do not
1116+
// depend on the zone the runner sits in.
1117+
describe('date condition values read as dates (objectstack#37034)', () => {
1118+
beforeAll(() => setDisplayTimeZone('UTC'));
1119+
afterAll(() => setDisplayTimeZone(undefined));
1120+
1121+
const ISSUED_ON: ConditionField = { value: 'issued_on', label: '开具日期', type: 'date' };
1122+
const CREATED_AT: ConditionField = { value: 'created_at', label: '创建时间', type: 'datetime' };
1123+
const STARTS_AT: ConditionField = { value: 'starts_at', label: 'Starts at', type: 'time' };
1124+
const rows = (conditions: Array<[string, string, unknown]>): FilterBuilderRowGroup => ({
1125+
id: 'root',
1126+
logic: 'and',
1127+
conditions: conditions.map(([field, operator, value], i) => ({ id: `r${i}`, field, operator, value }) as FilterBuilderRow),
1128+
});
1129+
const inZh = (node: React.ReactNode) => (
1130+
<I18nProvider config={{ defaultLanguage: 'zh-CN', detectBrowserLanguage: false }} persistLanguage={false}>{node}</I18nProvider>
1131+
);
1132+
function zhChips(filters: FilterBuilderRowGroup, field: string): string[] {
1133+
render(inZh(
1134+
<ConditionChipRow
1135+
sort={[]}
1136+
sortFields={[ISSUED_ON, CREATED_AT]}
1137+
onSortChange={() => {}}
1138+
filters={filters}
1139+
filterFields={[ISSUED_ON, CREATED_AT]}
1140+
onFiltersChange={() => {}}
1141+
renderAdvanced={() => <div />}
1142+
renderSortLevels={() => <div />}
1143+
/>,
1144+
));
1145+
return screen.getAllByTestId(`filter-chip-open-${field}`).map((b) => b.textContent ?? '');
1146+
}
1147+
const NOT_ISO = /T\d\d:\d\d|\d{4}-\d{2}-\d{2}/;
1148+
1149+
it('the sighting: a drilled month bucket on a datetime field reads as two localized date-times, not ISO', () => {
1150+
const chips = zhChips(rows([
1151+
['created_at', 'greater_than_or_equal', '2026-10-01T00:00:00.000Z'],
1152+
['created_at', 'before', '2026-11-01T00:00:00.000Z'],
1153+
]), 'created_at');
1154+
expect(chips).toHaveLength(2);
1155+
expect(chips[0]).toMatch(/^创建时间:≥ 2026年10月1日.*00:00$/);
1156+
expect(chips[1]).toMatch(/^创建时间:.*2026年11月1日.*00:00$/);
1157+
for (const chip of chips) expect(chip).not.toMatch(NOT_ISO);
1158+
});
1159+
1160+
it('a date field bound, as the wire writes it (YYYY-MM-DD), reads as its day', () => {
1161+
const chips = zhChips(rows([
1162+
['issued_on', 'greater_than_or_equal', '2026-10-01'],
1163+
['issued_on', 'before', '2026-11-01'],
1164+
]), 'issued_on');
1165+
expect(chips).toHaveLength(2);
1166+
expect(chips[0]).toBe('开具日期:≥ 2026年10月1日');
1167+
expect(chips[1]).toContain('2026年11月1日');
1168+
for (const chip of chips) expect(chip).not.toMatch(NOT_ISO);
1169+
});
1170+
1171+
it('a date field compared with an instant at UTC midnight reads as that day', () => {
1172+
const [chip] = zhChips(rows([['issued_on', 'greater_than_or_equal', '2026-10-01T00:00:00.000Z']]), 'issued_on');
1173+
expect(chip).toBe('开具日期:≥ 2026年10月1日');
1174+
});
1175+
1176+
it('a datetime reads in the display zone', () => {
1177+
const [chip] = zhChips(rows([['created_at', 'greater_than_or_equal', '2026-10-15T12:00:00.000Z']]), 'created_at');
1178+
expect(chip).toMatch(/^创建时间:≥ 2026年10月15日.*12:00$/);
1179+
});
1180+
1181+
it('a date between reads both ends as dates', () => {
1182+
const [chip] = zhChips(rows([['issued_on', 'between', ['2026-10-01', '2026-10-31']]]), 'issued_on');
1183+
expect(chip).toContain('2026年10月1日 – 2026年10月31日');
1184+
});
1185+
1186+
it("the phone filter sheet's row reads the date in the viewer's language, not the runtime default", () => {
1187+
// The runtime's own locale here is English: a row that left the locale out
1188+
// would read 「Oct 1, 2026」 on a zh-CN session.
1189+
expect(new Intl.DateTimeFormat().resolvedOptions().locale).toMatch(/^en/);
1190+
render(inZh(
1191+
<PhoneFilterSheet
1192+
open
1193+
onOpenChange={() => {}}
1194+
fields={[ISSUED_ON, CREATED_AT]}
1195+
value={rows([['issued_on', 'greater_than_or_equal', '2026-10-01']])}
1196+
onApply={() => {}}
1197+
/>,
1198+
));
1199+
expect(screen.getByTestId('phone-filter-item-condition').textContent).toBe('≥ 2026年10月1日');
1200+
});
1201+
1202+
it('CONTROL: a time field and an unreadable value are shown as written', () => {
1203+
const { t } = { t: (k: string) => LIST_CONDITION_DEFAULT_TRANSLATIONS[k] ?? k };
1204+
expect(describeConditionValue(STARTS_AT, 'after', '09:30', t as never, undefined, 'zh-CN')).toBe('after 09:30');
1205+
expect(describeConditionValue(ISSUED_ON, 'after', 'not a date', t as never, undefined, 'zh-CN')).toBe('after not a date');
1206+
});
1207+
});

0 commit comments

Comments
 (0)