Skip to content

Commit 1a2a8a9

Browse files
fix(nightly): green the showcase live tiers — the currency picker reads in a form host, four specs read the product as merged (#36578)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ88Tcs1L1zT2fWqjj2xTzFXM)_ Fixes #36321 Clause-②: no repo:objectstack#1 dispatch · os-warren · session_01JQwxbanvK21nJKgGjvE9XL ## 维护者速读 - 用户可见变化:新建发票时,本币发票在填过表头后选产品,单价会照常自动带出;之前一律留空并提示「还没选币种」,而表头明明显示着美元。其余改动只是夜间测试的写法,用户无感。 - 为什么做:夜间浏览器测试在 main 上连红多日,卡片要求找出回归并修好,不许跳过或删测试。 - 出错会怎样:只影响新建主从单据里币种选择框被表单读取的方式;不对可以直接撤回这一个合并。 - 要你做什么:无。 ## What changes The nightly `live` tier's two showcase files were red on main for four reasons. One is a product regression, three are specs that pinned a surface a merged pull request moved. **Product: the currency code picker is readable by a form host that reads the DOM** (`@object-ui/components`, `CurrencyCodePicker`). The master-detail form reads its header's live values off the header's named elements (`scrapeHeaderRecord`) on each bubbling `input` / `change`. The picker's only element in the form is its trigger button, which carries the field's `name`, and a button's `value` was the empty string. Since #36351 (merged 2026-11-22 22:18Z) the line grid withholds a picked amount from a line whose currency it cannot tell, so on a New Invoice whose Currency shows "USD — US Dollar", picking Widget A left Unit Price empty with "Unit Price was not filled: the picked amount is $29.99, but no currency is chosen here yet." The trigger now carries the selected code as its `value`, and a changed code bubbles one `change` event from the trigger, as a native select does (Radix Select's hidden select does the same). Opening on a code announces nothing. **Specs that read the product as merged** (no test renamed, skipped or deleted; every assertion still pins what it pinned): - `ui/e2e/live/phone-nav-drawer-back-29131.spec.ts`, desktop CONTROL: since #36297 a 1280 px window starts with the sidebar expanded, and the collapsed sidebar's own button stays in the DOM, off screen. `.first()` on the shared trigger selector clicked it and timed out "element is outside of the viewport". The two presses are now the collapse button, then the page header's expand button, each by its test id, with the visible state checked between. - `ui/e2e/live/inline-edit-polish-2572.spec.ts`: the shared inline-edit session it pins is entered by a double-click on the record page's sectioned face, titled "Double-click to edit". At 1280 px with the sidebar expanded that is the face drawn (measured); the "Click to edit" field-list face now edits one field in place with no session and no save bar (#36475), which is not what this file pins. - `examples/app-showcase/e2e/detail-shapes.spec.ts` (related-heavy): the meta footer is now a "System information" section that starts collapsed (#36147), so the case opens it before reading "Created"; and the summary rail is retired in every tier (#35890), so Contoso's contacts are read from the Contacts tab instead of the rail's card. The vacuous right-column count (no right column exists) is dropped with the rail. Already repaired on main before this branch, so not touched: the `New` button's name (#36303) and the retired "Keep sidebar open" toggle in `detail-shapes` (#36297). ## Tests - New `ui/packages/components/src/__tests__/currency-code-picker-form-read-36321.test.tsx` (3 cases): the named trigger's value is the code; with no code it is empty; a pick bubbles one `change` from the trigger, read after the new code is on it, and opening on a code announces nothing. - Ablation on the committed tree, each leg by `scripts/ablation-replace.mjs` and restored to the HEAD blob `a5fe02c11426` with `git diff HEAD` empty: the trigger's `value` removed gives `Tests 2 failed | 1 passed (3)`; the `dispatchEvent` removed gives `Tests 1 failed | 2 passed (3)`. ## Acceptance notes - A line picked BEFORE any header edit on a New Invoice still withholds the price with the same note: the form's create feed opens on the caller's initial record, not on the schema defaults the header seeds, so the seeded home currency reaches the grid only with the first header event. Withholding is the safe direction (no cross-currency copy). Same family as the #36351 follow-ups on #36412. ## Verification <details><summary>The two nightly files, whole, at b37d813</summary> `os-verify-lock.sh -c 'pnpm console:build && cd examples/app-showcase && OS_TEST_TIERS=nightly pnpm exec vitest run test/showcase-smoke.live.test.ts test/console-live-specs.live.test.ts'`: smoke `56 passed (2.7m)`, Console live specs `28 passed (2.0m)`, `Test Files 2 passed (2)`, `Tests 2 passed (2)`, VERDICT command-exit 0. Control at main d463c46 (same command): `Test Files 2 failed (2)`; Console live `3 of 28` failed (form-view-subforms, inline-edit-polish-2572, phone-nav CONTROL), smoke `1 of 56` failed (detail-shapes related-heavy). </details> <details><summary>Gates</summary> All at b37d813. - `dispatch-gates --commands` derived 56 families; 53 lock-free ones run one by one, each exit 0. `dispatch-gates --ran` with every exit recorded: `56 derived, 56 run, 0 NOT-MEASURED, 0 UNRUN`. - Under `os-verify-lock` (one hold, parts sequenced, each part's own exit read): `pnpm --filter @object-ui/components run type-check` exit 0; `vitest run packages/components/` (from `ui/`) `Test Files 506 passed | 1 skipped (507)`, `Tests 4936 passed | 24 skipped (4960)`; `pnpm check:type-check-debt` exit 0; `vitest run scripts/` (from `ui/`) `Test Files 172 passed | 2 skipped (174)`, `Tests 5127 passed | 2 skipped (5129)`; `pnpm check:dual-build-cjs-loads` exit 0. - The acceptance note measured in the browser (backend + Console preview at the head): a New Invoice opens with the trigger `value=USD`; an Add line and a Widget A pick with no header edit leaves Unit Price `""` with the note. - Declared to CI: `test:repo` and the full lint farm. </details> ## Two-minute check `pnpm --dir ui exec vitest run packages/components/src/__tests__/currency-code-picker-form-read-36321.test.tsx`: 3 passed. In the Console, New Invoice, type a name, Add line, pick Widget A: Unit Price reads 29.99. --- _Generated by [Claude Code](https://claude.ai/code/session_01JQwxbanvK21nJKgGjvE9XL)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JQwxbanvK21nJKgGjvE9XL Co-authored-by: Claude <noreply@anthropic.com>
1 parent 20d025f commit 1a2a8a9

6 files changed

Lines changed: 146 additions & 26 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@object-ui/components': patch
3+
---
4+
5+
fix(components): a New Invoice in the home currency fills a picked product's price on its line again
6+
7+
Clause-②: no
8+
9+
The currency code picker's trigger now carries the selected code as its `value`, and a changed code bubbles a `change` event from it, as a native select does. The master-detail form reads its header's live values off the header's named elements, and read this one as empty: since the line grid withholds a picked amount from a line whose currency it cannot tell (objectstack#36249), a New Invoice in the home currency left Unit Price empty with the note "no currency is chosen here yet". The grid now reads the header's code once the header has been edited, and reads a picked code when it is picked. A line picked before any header edit still withholds the price and says so.

‎examples/app-showcase/e2e/detail-shapes.spec.ts‎

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import { test, expect } from '@playwright/test';
2121
* one-column stack tier (objectstack#27524): a
2222
* `relatedList: 'primary'` list is a body table in the
2323
* details (objectstack#27055, Target 8) and takes no tab;
24-
* the rest are tabs of the tab row (objectstack#35595),
25-
* and one with records is a card of the 概览 tab's rail
26-
* below the details (objectstack#35596)
24+
* the rest are tabs of the tab row (objectstack#35595);
25+
* the 概览 tab's rail that summarized them is retired
26+
* (objectstack#35890), so the case opens the Contacts tab
2727
*
2828
* Runs against the console the backend serves at /_console (baseURL from
2929
* playwright.config.ts; storageState carries the admin session). The
@@ -170,8 +170,8 @@ test('related-heavy: body tables, the tab row and the rail on Contoso', async ({
170170
// The synthesized record page lays itself out by the width of the view it
171171
// occupies, by one rule (objectstack#26678, objectstack#27524): details |
172172
// the right column from `RECORD_PAGE_TWO_COLUMN_MIN_WIDTH` (760 px,
173-
// `@object-ui/plugin-detail`), and ONE column below it — the details, then
174-
// the 概览 tab's rail. The tab row (objectstack#35595) is drawn in every
173+
// `@object-ui/plugin-detail`), and ONE column below it — the details on
174+
// the tab row's first tab. The tab row (objectstack#35595) is drawn in every
175175
// tier. The case stays in that stack tier on purpose: the column tiers are
176176
// what every other page of this smoke draws at the Desktop Chrome viewport,
177177
// and the stack is also what the split pane (720 px) and a phone draw.
@@ -207,7 +207,9 @@ test('related-heavy: body tables, the tab row and the rail on Contoso', async ({
207207
await expect(page.locator(HIGHLIGHT_STRIP)).toHaveCount(0);
208208
await expect(page.locator(stageTag('status')).first()).toBeVisible();
209209

210-
// One column: the details, then the rail. The tab row opens on 概览.
210+
// One column, on the tab row, which opens on its first tab (详情 / Details,
211+
// `overview`). The right summary rail is retired in every tier
212+
// (objectstack#35890): the other related lists are the row's tabs.
211213
await expect(page.locator('[data-record-page-tier]')).toHaveAttribute('data-record-page-tier', 'stack');
212214
await expect(page.locator('[data-record-columns]')).toHaveAttribute('data-record-columns-shown', 'details');
213215
await expect(page.locator('[data-record-tab="overview"]')).toHaveAttribute('aria-selected', 'true');
@@ -216,8 +218,7 @@ test('related-heavy: body tables, the tab row and the rail on Contoso', async ({
216218
// them (objectstack#27055, Target 8): Invoices and Projects are
217219
// `relatedList: 'primary'` (CORE relationships), so each is a body table in
218220
// the details, with its rows read at open, and takes no tab of its own; the
219-
// rest of Contoso's lists (Contacts and the Field Zoo lookups) are tabs, and
220-
// one with records is a card of the rail (objectstack#35596).
221+
// rest of Contoso's lists (Contacts and the Field Zoo lookups) are tabs.
221222
// CONTROL for the absence below: an ordinary list's tab is drawn under the
222223
// same `OBJECT.FIELD` id, so a renamed id scheme reds here, not silently.
223224
await expect(page.locator('[data-record-tab="showcase_contact.account"]')).toHaveCount(1);
@@ -231,8 +232,6 @@ test('related-heavy: body tables, the tab row and the rail on Contoso', async ({
231232
.filter({ has: page.getByRole('columnheader', { name: 'Project Name' }) });
232233
await expect(invoicesTable.getByRole('cell', { name: 'INV-1002', exact: true })).toBeVisible();
233234
await expect(projectsTable.getByRole('cell', { name: 'Data Platform', exact: true })).toBeVisible();
234-
const rightColumn = page.locator('[data-record-column="right"]');
235-
await expect(rightColumn.getByRole('region', { name: /^(Invoices|Projects)$/ })).toHaveCount(0);
236235

237236
// Contoso's own groups render in the details (ADR-0085 §5), its highlighted
238237
// fields among their members.
@@ -244,15 +243,23 @@ test('related-heavy: body tables, the tab row and the rail on Contoso', async ({
244243
await expect(details.getByText('$25,000,000', { exact: false }).first()).toBeVisible();
245244
const footer = page.locator('[data-testid="record-meta-footer"]');
246245
await expect(footer).toBeVisible();
246+
// On the field list the footer is a "System information" section that
247+
// starts collapsed (objectstack#36147): open it, then read its rows
248+
// (objectstack#36321).
249+
const systemInfo = footer.getByRole('button', { name: 'System information' });
250+
await systemInfo.click();
251+
await expect(systemInfo).toHaveAttribute('aria-expanded', 'true');
247252
const footerText = (await footer.innerText()).replace(/\s+/g, ' ');
248253
expect(footerText, 'footer dangles "Created by" without an actor').not.toMatch(/Created by/);
249254
expect(footerText).toMatch(/Created/);
250255

251-
// The rail's Contacts card summarizes the Contacts tab: its first rows,
252-
// Contoso's seeded contacts among them.
253-
const contactsCard = rightColumn.getByRole('region', { name: 'Contacts', exact: true });
254-
await contactsCard.scrollIntoViewIfNeeded();
255-
await expect(contactsCard.locator('[data-record-summary-row]').filter({ hasText: 'Carl Fox' })).toBeVisible();
256+
// Contoso's contacts are the Contacts tab, where the retired rail's card
257+
// summarized them (objectstack#35890, objectstack#36321): the tab lists
258+
// Contoso's seeded contacts.
259+
const contactsTab = page.locator('[data-record-tab="showcase_contact.account"]');
260+
await contactsTab.click();
261+
await expect(contactsTab).toHaveAttribute('aria-selected', 'true');
262+
await expect(page.getByRole('tabpanel').getByText('Carl Fox', { exact: true }).first()).toBeVisible();
256263

257264
expect(errors, 'uncaught page errors on related-heavy detail').toEqual([]);
258265
});

‎ui/e2e/live/inline-edit-polish-2572.spec.ts‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,15 @@ const REPO_ROOT = decodeURIComponent(new URL(import.meta.url).pathname)
5656
.slice(0, -SELF_DEPTH_BELOW_REPO_ROOT)
5757
.join('/');
5858

59-
// The record page's field list enters edit on a click of the value
60-
// (objectstack#36147); the value carries this title.
61-
const EDIT_HINT = 'Click to edit';
59+
// The shared inline-edit session this file pins is entered by a double-click
60+
// on a value of the record page's sectioned face, which carries this title.
61+
// That is the face at this config's 1280 px window, where the sidebar now
62+
// starts expanded (objectstack#36112). The field-list face (the pinned left
63+
// column on a wider page, objectstack#36147) titles a value "Click to edit",
64+
// and a click there edits that one field in place and saves it alone, with no
65+
// session and no save bar (objectstack#36475): not what this file pins
66+
// (objectstack#36321).
67+
const EDIT_HINT = 'Double-click to edit';
6268

6369
function authToken(): string {
6470
const state = JSON.parse(readFileSync(join(REPO_ROOT, 'e2e/live/.auth/state.json'), 'utf8'));
@@ -119,12 +125,12 @@ test('record inline-edit polish (#2572) — showcase Project end-to-end', async
119125
if (/\/api\/v1\/data\/showcase_account\/[^/?]+/.test(r.url())) accountHydrations.push(r.url());
120126
});
121127

122-
// ── Enter the shared inline-edit session (click a details-body field). ──
128+
// ── Enter the shared inline-edit session (double-click a details-body field). ──
123129
const spentGroup = page
124130
.locator('div.group')
125131
.filter({ has: page.getByText('Spent', { exact: true }) })
126132
.last();
127-
await spentGroup.locator(`[title="${EDIT_HINT}"]`).click();
133+
await spentGroup.locator(`[title="${EDIT_HINT}"]`).dblclick();
128134

129135
const saveBtn = page.getByRole('button', { name: 'Save', exact: true });
130136
await expect(saveBtn, 'save bar appears once the session is live').toBeVisible();
@@ -151,7 +157,7 @@ test('record inline-edit polish (#2572) — showcase Project end-to-end', async
151157
.locator('div.group')
152158
.filter({ has: page.getByText('Budget', { exact: true }) })
153159
.last();
154-
await budgetGroup.locator(`[title="${EDIT_HINT}"]`).click();
160+
await budgetGroup.locator(`[title="${EDIT_HINT}"]`).dblclick();
155161
await expect(saveBtn).toBeVisible();
156162
const budgetInput2 = page.locator('input[type="number"][min="0"][step="0.01"]').first();
157163
// Above the flow's 500k decision edge, so approving `manager_review` routes
@@ -222,7 +228,7 @@ test('record inline-edit polish (#2572) — showcase Project end-to-end', async
222228
await expect(approvalTag, 'the header names the pending approval').toBeVisible();
223229
await expect(approvalTag, 'an unlocked approval step does not lock the tag').not.toHaveAttribute('data-record-approval-locked');
224230
// A double-click on the budget still opens an inline-edit session.
225-
await budgetGroupOnPage().locator(`[title="${EDIT_HINT}"]`).click();
231+
await budgetGroupOnPage().locator(`[title="${EDIT_HINT}"]`).dblclick();
226232
await expect(saveBtn, 'inline editing stays live during an unlocked approval').toBeVisible();
227233
await page.keyboard.press('Escape');
228234
await expect(saveBtn).toBeHidden();

‎ui/e2e/live/phone-nav-drawer-back-29131.spec.ts‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ import { test, expect, type Page } from '@playwright/test';
2626
const APP = 'com.example.showcase';
2727
const LIST = `/apps/${APP}/showcase_task`;
2828
const DRAWER = '[data-sidebar="sidebar"][data-mobile="true"]';
29-
const TRIGGER = 'button[data-sidebar="trigger"]';
29+
/** The desktop sidebar's collapse button, and the page header's expand button (objectstack#36112). */
30+
const COLLAPSE = '[data-testid="sidebar-collapse"]';
31+
const EXPAND = '[data-testid="shell-sidebar-expand"]';
3032
/** On a phone list the app bar's 「‹」, there once the page is drawn. */
3133
const PHONE_BACK = '[data-testid="app-bar-phone-home"]';
3234
const FLAG = '__navDrawerOpen';
@@ -142,13 +144,20 @@ for (const width of [375, 390]) {
142144
test.describe('desktop sidebar', () => {
143145
test.use({ viewport: { width: 1280, height: 800 } });
144146

147+
// From 1280 px the sidebar starts expanded, and its collapse button and the
148+
// page header's expand button are each drawn only while they act
149+
// (objectstack#36112); the collapsed sidebar's own button stays in the DOM,
150+
// off the screen. So the two presses are the visible control each time, by
151+
// its test id, never the first trigger in the DOM (objectstack#36321).
145152
test('CONTROL — opening and closing the sidebar writes no history entry', async ({ page }) => {
146-
await openList(page, TRIGGER);
153+
await openList(page, COLLAPSE);
147154
const url = page.url();
148155
const length = await historyLength(page);
149156

150-
await page.locator(TRIGGER).first().click();
151-
await page.locator(TRIGGER).first().click();
157+
await page.locator(COLLAPSE).click();
158+
await expect(page.locator(EXPAND)).toBeVisible();
159+
await page.locator(EXPAND).click();
160+
await expect(page.locator(COLLAPSE)).toBeInViewport();
152161

153162
expect(await historyLength(page)).toBe(length);
154163
expect(page.url()).toBe(url);
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* objectstack#36321 — the currency code picker is readable by a form host that
11+
* reads its fields off the DOM.
12+
*
13+
* The master-detail form's line grid reads the header's live values from the
14+
* header's named elements and re-reads them on each bubbling `input` /
15+
* `change` event (`scrapeHeaderRecord` in `@object-ui/plugin-form`). The
16+
* picker's only element in the form is its trigger, which carries the field's
17+
* `name`: it read as the empty string, so a New Invoice in the home currency
18+
* read as "no currency chosen" and a picked product's price was withheld from
19+
* the line. These pin the two halves of the read: the trigger's `value` is the
20+
* code, and a pick bubbles a `change` from the trigger once the new code is on
21+
* it.
22+
*/
23+
24+
import { describe, it, expect } from 'vitest';
25+
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
26+
import * as React from 'react';
27+
import { CurrencyCodePicker } from '../custom/currency-code-picker';
28+
29+
const labels = { placeholder: 'Pick a currency', search: 'Search', noResults: 'None', available: 'Available', all: 'All' };
30+
31+
function Host({ initial, onRead }: { initial?: string; onRead: (value: string) => void }) {
32+
const [value, setValue] = React.useState(initial);
33+
const ref = React.useRef<HTMLDivElement>(null);
34+
React.useEffect(() => {
35+
const host = ref.current!;
36+
// The form host's read: the named element's value, on a bubbling change.
37+
const read = () => onRead((host.querySelector('[name="currency_code"]') as HTMLButtonElement).value);
38+
host.addEventListener('change', read);
39+
return () => host.removeEventListener('change', read);
40+
}, [onRead]);
41+
return (
42+
<div ref={ref}>
43+
<CurrencyCodePicker name="currency_code" value={value} onChange={setValue} home="USD" locale="en" labels={labels} />
44+
</div>
45+
);
46+
}
47+
48+
describe('CurrencyCodePicker read by a DOM-reading form host (objectstack#36321)', () => {
49+
it('the named trigger carries the selected code as its value', () => {
50+
render(<Host initial="USD" onRead={() => {}} />);
51+
expect((screen.getByRole('combobox') as HTMLButtonElement).value).toBe('USD');
52+
});
53+
54+
it('with no code the trigger value is empty, never a code of its own', () => {
55+
render(<Host onRead={() => {}} />);
56+
expect((screen.getByRole('combobox') as HTMLButtonElement).value).toBe('');
57+
});
58+
59+
it('a pick bubbles one change from the trigger, read after the new code is on it', async () => {
60+
const reads: string[] = [];
61+
render(<Host initial="USD" onRead={(v) => reads.push(v)} />);
62+
// Opening on the seeded code announces nothing: only a changed code does.
63+
expect(reads).toEqual([]);
64+
65+
fireEvent.click(screen.getByRole('combobox'));
66+
fireEvent.click(await screen.findByRole('option', { name: /^EUR/ }));
67+
68+
await waitFor(() => expect(reads).toEqual(['EUR']));
69+
expect((screen.getByRole('combobox') as HTMLButtonElement).value).toBe('EUR');
70+
});
71+
});

‎ui/packages/components/src/custom/currency-code-picker.tsx‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,22 @@ export function CurrencyCodePicker({
144144
const [open, setOpen] = React.useState(false)
145145
const current = typeof value === "string" && value !== "" ? value : undefined
146146
const groups = currencyCodeGroups({ home, rated, used, current })
147+
148+
// The trigger is the picker's one element in the form (its list is portaled
149+
// out), and a form host that reads its header off the DOM finds the field by
150+
// the trigger's `name`: the master-detail form's line grid reads the
151+
// header's currency that way (objectstack#36321). So the trigger carries the
152+
// code as its `value`, and a changed code bubbles a `change` event from it,
153+
// as a native select does when its value changes (Radix Select's hidden
154+
// select does the same). Without them the host read the button's empty
155+
// value, and a header in the home currency read as "no currency chosen".
156+
const triggerRef = React.useRef<HTMLButtonElement>(null)
157+
const announced = React.useRef(current)
158+
React.useEffect(() => {
159+
if (announced.current === current) return
160+
announced.current = current
161+
triggerRef.current?.dispatchEvent(new Event("change", { bubbles: true }))
162+
}, [current])
147163
const item = (code: string) => (
148164
<CommandItem
149165
key={code}
@@ -165,6 +181,8 @@ export function CurrencyCodePicker({
165181
<Button
166182
type="button"
167183
{...triggerProps}
184+
ref={triggerRef}
185+
value={current ?? ""}
168186
variant="outline"
169187
role="combobox"
170188
aria-expanded={open}

0 commit comments

Comments
 (0)