Skip to content

Commit b37d813

Browse files
committed
fix(nightly): green the showcase live tiers on main — the currency picker reads in a form host, and four specs read the product as merged
The New Invoice line grid read the header's currency picker as empty, so a home-currency invoice withheld a picked product's price; the picker's trigger now carries its code and bubbles a change. Three specs and one smoke case pinned surfaces that moved: the sidebar's docking model, the record page's sectioned face at 1280 px, the collapsed System information footer and the retired summary rail. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbanvK21nJKgGjvE9XL
1 parent ad50d61 commit b37d813

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)