diff --git a/.changeset/list-filter-sort-wiring.md b/.changeset/list-filter-sort-wiring.md new file mode 100644 index 00000000000..6791a58ef72 --- /dev/null +++ b/.changeset/list-filter-sort-wiring.md @@ -0,0 +1,12 @@ +--- +'@object-ui/plugin-list': patch +'@object-ui/components': patch +'@object-ui/i18n': patch +--- + +feat(plugin-list): the list's Filter and Sort open the shared field list, and the conditions show as chips under the view bar + +Clause-②: no +Metadata-protocol: none + +The toolbar's Filter opens a searchable field list (the fields the view shows first, a type icon on each), then the values by field type; every pick applies at once. Sort opens the same list with the direction on top. Under the view bar, the condition row shows the sort chips first (click to reverse, drag or Alt+Arrow to reorder, × to remove), then the view's own conditions as locked chips, then the reader's filter chips, 「Add filter」 and 「Reset」, which puts the filter and sort back to the view as saved. A column header click shows up there as a sort chip. The full FilterBuilder and SortBuilder stay one click away, behind 「Advanced filter」 and 「All sort levels」. The FilterBuilder no longer draws its 「Where」 label: `filterBuilder.where` is retired from the locale packs, and `listConditions.sort.advanced` is added. No filter storage format, `uf_*` parameter or server sort changes. diff --git a/docs/qa/platform-checklist/areas/records-forms.json b/docs/qa/platform-checklist/areas/records-forms.json index 70c3b74aee3..df423412050 100644 --- a/docs/qa/platform-checklist/areas/records-forms.json +++ b/docs/qa/platform-checklist/areas/records-forms.json @@ -2884,7 +2884,7 @@ "title": "User-built FilterBuilder/SortBuilder toolbar merges with the view filter, restores across nav, and reproduces rows from the URL", "since": "v16", "status": "active", - "revision": 10, + "revision": 11, "priority": "P1", "surface": "browser", "personas": [ @@ -2903,7 +2903,7 @@ }, "steps": [ "sign in as admin; open showcase_task and switch to the in_progress saved view (stored filter status=in_progress); screenshot", - "open the FilterBuilder toolbar (an icon button, aria-label 'Filter', data-testid toolbar-filter-trigger, whose accessible name gains the badge count once a condition is active; the SortBuilder is the 'Sort' icon button beside it, ui/packages/plugin-list/src/ListView.tsx); add 2 conditions that leave at least TWO rows, so the sort clause has an order to read — on the stock seed priority = high AND estimate_hours > 4 leaves ONE row on in_progress, a single-datapoint for acceptance[1] (QA run #24616): check the count first and pick a pair that keeps ≥ 2; open the SortBuilder and add a sort (due_date desc); type a term into the list's quick search that keeps rows (acceptance[2] reads it back; QA run #29890 used 'pipeline'); capture the data request", + "open the toolbar's Filter (a text trigger from sm up, data-testid toolbar-filter-trigger, whose accessible name gains the badge count once a condition is active; Sort is the trigger beside it, ui/packages/plugin-list/src/ListView.tsx). Since objectstack#35549 / #35550 each opens the shared field list (the fields the view shows first, a search box, a type icon per row): Filter → a field → its values applies at once, with no Apply, and each condition shows as a chip in the condition row under the view bar; Sort → the direction on top → a field adds a level, shown as a sort chip before the filter chips. The full builders are one click further, behind the field list's footer: 「Advanced filter」 opens the FilterBuilder (no 「Where」 label any more) and 「All sort levels」 the SortBuilder. Add 2 conditions that leave at least TWO rows, so the sort clause has an order to read — on the stock seed priority = high AND estimate_hours > 4 leaves ONE row on in_progress, a single-datapoint for acceptance[1] (QA run #24616): check the count first and pick a pair that keeps ≥ 2; open the SortBuilder and add a sort (due_date desc); type a term into the list's quick search that keeps rows (acceptance[2] reads it back; QA run #29890 used 'pipeline'); capture the data request", "assert the request's `filter` param is the MERGE of the view's stored rule AND the two toolbar conditions (buildEffectiveFilter/mergeFilterNodes), and `sort` carries the toolbar sort (e.g. sort=-due_date) — the console spells its list params without a `$`; the returned rows satisfy view-filter AND toolbar conditions", "navigate away via an in-app nav link to another object (the link carries no query string, so the URL state is dropped), then navigate back to showcase_task in_progress through the Tasks nav entry and the view switcher (it lands on /view/showcase_task.in_progress). ⛔ Not the sidebar's 'In-Progress Tasks' Data Slices link: it opens /showcase_task/data?filter[status]=in_progress, a different surface from the saved view; screenshot; confirm the toolbar filter + sort restored", "read where the toolbar filter and sort are kept: the signed-in user's own sys_user_preference row keyed ui.list.showcase_task (GET /api/v1/data/sys_user_preference filtered to that key; its value's perView. carries the filters and the sort — objectui ListPreferencesProvider.tsx, objectui#12418), and its localStorage write-through cache list-state::showcase_task. Confirm both are the signed-in user's: the row's user_id, and the cache key's user segment. (Only the search term stays under the older list-filters::showcase_task: key)", @@ -2927,7 +2927,7 @@ { "clause": "the toolbar filter + search survive a FULL in-app navigation away and back — restored from the user's own list preference (sys_user_preference ui.list., cached in localStorage list-state::; URL params alone are lost on an in-app nav link that carries no query string, which is what the preference bridges)", "oracle": "dom", - "verify": "after a screenshot confirms the list rendered, the FilterBuilder shows the two conditions, the SortBuilder the sort and the quick search box the term (kept under list-filters::showcase_task:, steps[4]); the request re-issued on return carries the same merged `filter` param (the console spells it without a `$`; objectui app-shell/src/context/ListPreferencesProvider.tsx)", + "verify": "after a screenshot confirms the list rendered, the condition row under the view bar shows the two conditions as filter chips and the sort as a sort chip (objectstack#35549 / #35550; the same rows also show in the FilterBuilder and SortBuilder behind the field list's footers), and the quick search box shows the term (kept under list-filters::showcase_task:, steps[4]); the request re-issued on return carries the same merged `filter` param (the console spells it without a `$`; objectui app-shell/src/context/ListPreferencesProvider.tsx)", "evidence": "before/after screenshots + the re-issued request" }, { @@ -3025,6 +3025,12 @@ "date": "2026-11-14", "change": "steps[1], steps[3] and steps[5] re-pointed to the console as QA run #33048 met it (comment 6846028996): the FilterBuilder / SortBuilder are icon buttons (toolbar-filter-trigger, ui/packages/plugin-list/src/ListView.tsx); the sidebar's In-Progress Tasks link is a Data Slices surface, so the return to the saved view goes through Tasks and the view switcher; and Log out sweeps the signed-out user's list-state / list-filters keys (ui/packages/auth/src/ActiveOrganizationStorage.ts purgeSignedOutUserClientState), so a runner should not expect the first account's keys beside the second's. No clause changed. Read at base 87330e89", "ref": "#33329" + }, + { + "revision": 11, + "date": "2026-11-19", + "change": "steps[1] and acceptance[2].verify re-pointed to the list redo (objectstack#35549 filter, objectstack#35550 sort): Filter and Sort open the shared field list, conditions show as chips in the condition row under the view bar, and the FilterBuilder / SortBuilder sit behind the field list's 「Advanced filter」 / 「All sort levels」 footers; the FilterBuilder's 「Where」 label is gone. The clauses are unchanged: the merge, the sort param, the restore and the user scope read the same state", + "ref": "#35549" } ] }, diff --git a/ui/e2e/list-condition-row-35549.spec.ts b/ui/e2e/list-condition-row-35549.spec.ts new file mode 100644 index 00000000000..d11f59615db --- /dev/null +++ b/ui/e2e/list-condition-row-35549.spec.ts @@ -0,0 +1,368 @@ +import { test, expect, type Page } from '@playwright/test'; +import { compile } from 'tailwindcss'; +import { build, type Plugin, type Rollup } from 'vite'; +import { readFileSync } from 'node:fs'; +import { createRequire } from 'node:module'; +import os from 'node:os'; +import path from 'node:path'; +import { pathToFileURL } from 'node:url'; +import { uiRoot } from '../scripts/ui-root.mjs'; + +/** + * GEOMETRY and INTERACTION pin for the list's condition row (objectstack#35549 + * filter, objectstack#35550 sort), on the REAL list: `ListView` with its + * toolbar, the `list-condition-row` slot objectstack#35548 laid under the view + * bar, and the grid. The Filter and Sort triggers open the shared field list; + * the slot holds the sort chips, then the reader's filter chips, 「Add filter」 + * and 「Reset」; with nothing to show it takes no height at all. + * + * ## Why a Playwright spec and not a vitest test + * + * "Takes no height", "one row of 24 px chips" and "a real drag reorders" are + * layout and pointer facts; happy-dom lays nothing out and fires no native + * drag. The vitest pins (`plugin-list/src/conditions/__tests__/ + * listConditions.test.tsx`, `ListView.conditionRow-35549.test.tsx`) hold the + * logic; this spec holds it in Chromium. The bundling follows + * `e2e/list-header-narrow-35446.spec.ts`. + * + * ## What is real here and what is a fixture + * + * REAL: `ListView` and `ObjectGrid` from source (plugin-list, plugin-grid), + * the condition controls, the Radix popovers, bundled by Vite and mounted with + * React's client renderer under `SchemaRendererProvider`; the stylesheet is + * real Tailwind, compiled for the classes on the page. Every step is a real + * pointer click. + * + * FIXTURES, declared so nobody reads more into a green run than it says: + * + * - The data source is in memory: one object definition and twelve records. + * It records every `find` it is asked, and answers the stage filter + * (`in`) and the sort the list sends, so the count bar and the row order + * move as they do against a server. + * - The translator is the English defaults table (no provider). + * - Animations are off, so a closed popover leaves the page at once rather + * than after its exit animation. + */ + +const REPO_ROOT = uiRoot(); +const source = (rel: string) => path.join(REPO_ROOT, rel); + +const THEME_CSS = source('packages/components/src/index.css'); +const LIST = source('packages/plugin-list/src/index.tsx'); +const GRID = source('packages/plugin-grid/src/index.tsx'); +const REACT = source('packages/react/src/index.ts'); + +const ENTRY = '\0list-condition-row:entry'; + +function workspaceSources(): Plugin { + return { + name: 'list-condition-row-workspace-src', + enforce: 'pre', + async resolveId(id, importer) { + const m = /^@object-ui\/([a-z0-9-]+)(?:\/(.+))?$/.exec(id); + if (!m) return null; + const [, pkg, sub] = m; + const target = + pkg === 'types' && sub === 'zod' + ? source('packages/types/src/zod/index.zod.ts') + : source(`packages/${pkg}/src${sub ? `/${sub}` : ''}`); + const resolved = await this.resolve(target, importer, { skipSelf: true }); + if (!resolved) throw new Error(`${id} did not resolve to a source file under ${target}`); + return resolved; + }, + }; +} + +function entry(): Plugin { + const code = ` +import * as React from 'react'; +import { createRoot } from 'react-dom/client'; +import { SchemaRendererProvider } from ${JSON.stringify(REACT)}; +import ${JSON.stringify(GRID)}; +import { ListView } from ${JSON.stringify(LIST)}; + +const h = React.createElement; +const STAGES = [ + { value: 'prospecting', label: 'Prospecting', color: 'blue' }, + { value: 'proposal', label: 'Proposal', color: 'amber' }, + { value: 'negotiation', label: 'Negotiation', color: 'green' }, + { value: 'closed_won', label: 'Closed won', color: 'gray' }, +]; +const DEFINITION = { + name: 'deal', + label: 'Deal', + fields: { + name: { type: 'text', label: 'Name' }, + stage: { type: 'select', label: 'Stage', options: STAGES }, + amount: { type: 'number', label: 'Amount' }, + close_date: { type: 'date', label: 'Close date' }, + }, +}; +const ROWS = Array.from({ length: 12 }, (_, i) => ({ + id: 'r' + i, + name: 'Deal ' + i, + stage: STAGES[i % 4].value, + amount: (i * 7919) % 50000, + close_date: '2026-0' + ((i % 9) + 1) + '-15', +})); + +// The stage values the filter names ('in', or '=' per value, ORed for two), +// wherever the AST nests them; null when it names none. +function stageIn(node, found = []) { + if (!Array.isArray(node)) return found.length ? found : null; + if (node[0] === 'stage' && node[1] === 'in' && Array.isArray(node[2])) found.push(...node[2]); + else if (node[0] === 'stage' && node[1] === '=') found.push(node[2]); + else for (const child of node) stageIn(child, found); + return found.length ? found : null; +} + +window.__finds = []; +const dataSource = { + async find(_object, params) { + window.__finds.push(JSON.parse(JSON.stringify(params ?? {}))); + const stages = stageIn(params?.$filter); + let rows = stages ? ROWS.filter((r) => stages.includes(r.stage)) : [...ROWS]; + const order = params?.$orderby ?? params?.sort; + const levels = Array.isArray(order) ? order : order && typeof order === 'object' ? Object.entries(order).map(([field, dir]) => ({ field, order: dir })) : []; + rows.sort((a, b) => { + for (const l of levels) { + const d = a[l.field] < b[l.field] ? -1 : a[l.field] > b[l.field] ? 1 : 0; + if (d) return l.order === 'desc' ? -d : d; + } + return 0; + }); + return { data: rows, total: rows.length }; + }, + async findOne() { return null; }, + async create(_o, d) { return d; }, + async update(_o, _id, d) { return d; }, + async delete() { return true; }, + async getObjectSchema() { return JSON.parse(JSON.stringify(DEFINITION)); }, +}; + +const schema = { + type: 'list-view', + objectName: 'deal', + viewType: 'grid', + columns: [{ field: 'name' }, { field: 'stage' }, { field: 'amount' }], +}; + +function Harness() { + const [sort, setSort] = React.useState([]); + window.__sort = sort; + return h('div', { className: 'h-[700px] w-[1280px] bg-background text-foreground' }, + h(SchemaRendererProvider, { dataSource }, + h(ListView, { schema, dataSource, onSortChange: setSort }))); +} + +createRoot(document.getElementById('root')).render(h(Harness)); +`; + return { + name: 'list-condition-row-entry', + resolveId: (id) => (id === 'list-condition-row:entry' ? ENTRY : null), + load: (id) => (id === ENTRY ? code : null), + }; +} + +async function bundlePage(): Promise { + const result = await build({ + configFile: false, + root: REPO_ROOT, + cacheDir: path.join(os.tmpdir(), 'objectui-list-condition-row-real'), + logLevel: 'error', + mode: 'production', + define: { 'process.env.NODE_ENV': JSON.stringify('production') }, + plugins: [workspaceSources(), entry()], + build: { + write: false, + minify: false, + target: 'es2022', + modulePreload: false, + reportCompressedSize: false, + rollupOptions: { + input: 'list-condition-row:entry', + output: { format: 'es', codeSplitting: false }, + }, + }, + }); + const outputs = (Array.isArray(result) ? result : [result]) as Rollup.RollupOutput[]; + const chunks = outputs.flatMap((o) => o.output).filter((o): o is Rollup.OutputChunk => o.type === 'chunk'); + if (chunks.length !== 1) throw new Error(`expected one bundled chunk, got ${chunks.length}`); + return chunks[0].code; +} + +async function tailwindFor(candidates: string[]): Promise { + const requireFromComponents = createRequire(source('packages/components/package.json')); + const twEntry = requireFromComponents.resolve('tailwindcss/index.css'); + const compiler = await compile(readFileSync(THEME_CSS, 'utf8'), { + base: path.dirname(THEME_CSS), + loadStylesheet: async (id: string, base: string) => { + const file = id === 'tailwindcss' ? twEntry : path.resolve(base, id); + return { path: file, base: path.dirname(file), content: readFileSync(file, 'utf8') }; + }, + loadModule: async (id: string) => { + const file = requireFromComponents.resolve(id); + const mod = await import(pathToFileURL(file).href); + return { path: file, base: path.dirname(file), module: mod.default ?? mod }; + }, + }); + return compiler.build(candidates); +} + +let bundle = ''; +// Seeded with the popover's stacking class: Radix copies the content's +// computed z-index onto its positioned wrapper when it mounts, so the rule +// has to be on the page before the first popover opens, or the grid's sticky +// header (z-10) paints over it. +const compiled = new Set(['z-50']); + +/** Compile the stylesheet for every class now on the page (popovers included). */ +async function style(page: Page): Promise { + for (let round = 0; ; round++) { + const candidates: string[] = await page.evaluate(() => [ + ...new Set( + [...document.querySelectorAll('[class]')].flatMap((el) => (el.getAttribute('class') ?? '').split(/\s+/)).filter(Boolean), + ), + ]); + if (round > 0 && candidates.every((cls) => compiled.has(cls))) break; + if (round === 5) throw new Error('the page kept adding classes; the stylesheet never caught up'); + candidates.forEach((cls) => compiled.add(cls)); + const css = await tailwindFor([...compiled]); + await page.evaluate((text) => { + let sheet = document.getElementById('tailwind'); + if (!sheet) { + sheet = document.createElement('style'); + sheet.id = 'tailwind'; + document.head.appendChild(sheet); + } + sheet.textContent = text; + }, css); + await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)))); + } +} + +async function mount(page: Page): Promise { + await page.setViewportSize({ width: 1280, height: 800 }); + // Served from a localhost URL rather than `setContent`'s about:blank, which + // is not a secure context: the list mints ids with `crypto.randomUUID`, which + // only a secure context has (the Console is served over https or localhost). + // No animations: a closing popover then unmounts at once, as it does once its exit animation ends. + await page.route('http://localhost/list-condition-row', (route) => + route.fulfill({ + contentType: 'text/html', + body: '
', + }), + ); + await page.goto('http://localhost/list-condition-row'); + await page.addScriptTag({ content: bundle, type: 'module' }); + await page.getByTestId('toolbar-filter-trigger').waitFor({ state: 'attached', timeout: 30_000 }); + await page.getByTestId('record-count-bar').waitFor({ state: 'attached', timeout: 30_000 }); + await style(page); +} + +/** Click, then style whatever the click opened. */ +async function click(page: Page, testId: string): Promise { + await page.getByTestId(testId).click(); + await style(page); +} + +const slot = (page: Page) => page.getByTestId('list-condition-row'); +const slotHeight = (page: Page) => slot(page).evaluate((el) => el.getBoundingClientRect().height); +/** The number the count bar reads, once the list has answered. */ +const count = async (page: Page) => (await page.getByTestId('record-count-bar').textContent())?.match(/\d+/)?.[0]; +const sortNow = (page: Page) => + page.evaluate(() => (window as unknown as { __sort: Array<{ field: string; order: string }> }).__sort.map((s) => `${s.field}:${s.order}`)); + +test.describe('list condition row under the view bar (objectstack#35549, objectstack#35550)', () => { + test.beforeAll(async () => { + test.setTimeout(240_000); + bundle = await bundlePage(); + }); + + test('CONTROL: with no sort and no filter the row takes no height', async ({ page }) => { + test.setTimeout(120_000); + await mount(page); + await expect.poll(() => count(page)).toBe('12'); + expect(await slotHeight(page)).toBe(0); + expect(await slot(page).evaluate((el) => el.childElementCount)).toBe(0); + }); + + test('filter: Filter → Stage → Negotiation is three clicks; the chip names field and value, reopens on click, × removes', async ({ page }) => { + test.setTimeout(120_000); + await mount(page); + await expect.poll(() => count(page)).toBe('12'); + await click(page, 'toolbar-filter-trigger'); + await click(page, 'filter-panel-fields-item-stage'); + await page.getByTestId('filter-panel-values-option-negotiation').getByRole('checkbox').click(); + await style(page); + // applied on the pick: no Apply button, the list asks again at once + await expect.poll(() => count(page)).toBe('3'); + const chip = page.getByTestId('filter-chip-stage'); + await expect(chip).toHaveText(/Stage: Negotiation/); + // the row is one line of 24 px chips: 24 + 2 × 6 padding + 1 border + const h = await slotHeight(page); + expect(h).toBeGreaterThanOrEqual(36); + expect(h).toBeLessThanOrEqual(38); + const chipBox = await chip.boundingBox(); + expect(Math.round(chipBox!.height)).toBe(24); + await page.keyboard.press('Escape'); + // a click on the chip reopens that condition's values, already ticked + await click(page, 'filter-chip-open-stage'); + await expect(page.locator('[data-testid$="-values-option-negotiation"][data-checked="true"]')).toBeVisible(); + await page.locator('[data-testid$="-values-option-proposal"]').getByRole('checkbox').click(); + await expect(chip).toHaveText(/Stage: Negotiation, Proposal/); + await expect.poll(() => count(page)).toBe('6'); + await page.keyboard.press('Escape'); + await click(page, 'filter-chip-remove-stage'); + await expect.poll(() => count(page)).toBe('12'); + expect(await slotHeight(page)).toBe(0); + }); + + test('sort: Sort → Descending → Amount is three clicks; chips come before filter chips; a drag reorders; a header click shows as a chip; Reset restores', async ({ page }) => { + test.setTimeout(120_000); + await mount(page); + await expect.poll(() => count(page)).toBe('12'); + await click(page, 'toolbar-sort-trigger'); + await click(page, 'sort-panel-order-desc'); + await click(page, 'sort-panel-fields-item-amount'); + expect(await sortNow(page)).toEqual(['amount:desc']); + await expect(page.getByTestId('sort-chip-toggle-amount')).toHaveText('Amount'); + await expect(page.getByTestId('sort-chip-toggle-amount')).toHaveAttribute('title', 'High → Low'); + // a second level + await click(page, 'toolbar-sort-trigger'); + await click(page, 'sort-panel-fields-item-stage'); + expect(await sortNow(page)).toEqual(['amount:desc', 'stage:asc']); + // a filter chip joins after the sort chips + await click(page, 'toolbar-filter-trigger'); + await click(page, 'filter-panel-fields-item-stage'); + await page.getByTestId('filter-panel-values-option-proposal').getByRole('checkbox').click(); + await page.keyboard.press('Escape'); + await style(page); + const order = await page.getByTestId('condition-chips').evaluate((row) => + [...row.querySelectorAll('[data-testid^="sort-chip-"][data-priority], [data-testid^="filter-chip-"]:not([data-testid*="-open-"]):not([data-testid*="-remove-"])')] + .map((el) => el.getAttribute('data-testid')), + ); + expect(order).toEqual(['sort-chip-amount', 'sort-chip-stage', 'filter-chip-stage']); + // all chips on one line, Reset at the right end of the slot + const tops = await page.getByTestId('condition-chips').evaluate((row) => + [...new Set([...row.children].map((el) => Math.round(el.getBoundingClientRect().top)))], + ); + expect(tops).toHaveLength(1); + const reset = await page.getByTestId('condition-reset').boundingBox(); + const slotBox = await slot(page).boundingBox(); + expect(slotBox!.x + slotBox!.width - (reset!.x + reset!.width)).toBeLessThanOrEqual(17); + // a real drag: the second sort chip onto the first + await page.getByTestId('sort-chip-stage').dragTo(page.getByTestId('sort-chip-amount')); + expect(await sortNow(page)).toEqual(['stage:asc', 'amount:desc']); + // Reset puts the list back as saved: no sort, no filter + await click(page, 'condition-reset'); + expect(await sortNow(page)).toEqual([]); + await expect.poll(() => count(page)).toBe('12'); + expect(await slotHeight(page)).toBe(0); + // a click on a column header sorts, and the row shows it as a chip + await page.getByRole('columnheader', { name: /Amount/ }).click(); + await style(page); + await expect(page.getByTestId('sort-chip-amount')).toBeVisible(); + expect((await sortNow(page))[0]).toMatch(/^amount:/); + }); +}); diff --git a/ui/examples/schema-catalog/test/filter-builder-mirror-6939.test.tsx b/ui/examples/schema-catalog/test/filter-builder-mirror-6939.test.tsx index 6bb012bae04..cf890a48a7a 100644 --- a/ui/examples/schema-catalog/test/filter-builder-mirror-6939.test.tsx +++ b/ui/examples/schema-catalog/test/filter-builder-mirror-6939.test.tsx @@ -93,37 +93,42 @@ type Reading = { * and not the renderer; what moved the renderer was a different card, and * keeping a stale "before" here would only make the next reader hunt a * regression that is a deliberate, ruled repair. + * + * ⛔ objectstack#35549 moved all five again, by one element: the builder's + * 「Where」 label span is gone (seat ruling Q3), so `elements` and the `SPAN` + * count drop by one, `Where` leaves `text`, and `sha256` is re-measured through + * this same `measure()`. Nothing else moved. */ const PRE_REPAIR: Record<(typeof IDS)[number], Reading> = { 'components-complex-filter-builder/empty-filter-builder': { - elements: 11, - tags: { DIV: 5, LABEL: 1, SPAN: 1, BUTTON: 1, svg: 1, path: 2 }, - text: 'Build FilterWhereAdd filter', - sha256: '4f7116e49e263e517c7d54451327413dc9f8b8513c07f52d9c2686f2b2a381aa', + elements: 10, + tags: { DIV: 5, LABEL: 1, BUTTON: 1, svg: 1, path: 2 }, + text: 'Build FilterAdd filter', + sha256: 'd4edfab29376ec040ab518140d509b5b631bcb7eb655e5b0cc074d92c68ec090', }, 'components-complex-filter-builder/product-search': { - elements: 76, - tags: { DIV: 20, LABEL: 1, SPAN: 10, BUTTON: 12, svg: 11, path: 19, INPUT: 3 }, - text: 'Product Search FiltersWhereANDClear allCategoryEqualsRemove conditionPriceLess thanRemove conditionStock QuantityGreater thanRemove conditionAdd filter', - sha256: 'aa398c23811cc40717d632ff5feac486796e01bce738df72e3ea53e83e628d10', + elements: 75, + tags: { DIV: 20, LABEL: 1, SPAN: 9, BUTTON: 12, svg: 11, path: 19, INPUT: 3 }, + text: 'Product Search FiltersANDClear allCategoryEqualsRemove conditionPriceLess thanRemove conditionStock QuantityGreater thanRemove conditionAdd filter', + sha256: '0fb598f1be494e2b3c7428d1f90ff222a041eec186a3d9819afc3f1a83265fe6', }, 'components-complex-filter-builder/search-interface': { - elements: 65, - tags: { DIV: 17, SPAN: 10, BUTTON: 12, svg: 9, path: 16, INPUT: 1 }, - text: 'Advanced SearchBuild complex queries with multiple conditionsWhereANDClear allPublishedEqualsTrueRemove conditionViewsGreater thanRemove conditionAdd filterApply FiltersClear', - sha256: '17c0b9f574fe89cc80d8be92c53917be73c8a561461dbe7db5a3e0899d4c86ab', + elements: 64, + tags: { DIV: 17, SPAN: 9, BUTTON: 12, svg: 9, path: 16, INPUT: 1 }, + text: 'Advanced SearchBuild complex queries with multiple conditionsANDClear allPublishedEqualsTrueRemove conditionViewsGreater thanRemove conditionAdd filterApply FiltersClear', + sha256: '25b998e0c6cd1559298976cab51e67b1212af06d3904b32334ab14668212649c', }, 'components-complex-filter-builder/user-filters': { - elements: 11, - tags: { DIV: 5, LABEL: 1, SPAN: 1, BUTTON: 1, svg: 1, path: 2 }, - text: 'Find UsersWhereAdd filter', - sha256: 'bc346672868113c9a7ba6ff47057ccaa1b865707f5b99c24234e1a9e3e46e9bc', + elements: 10, + tags: { DIV: 5, LABEL: 1, BUTTON: 1, svg: 1, path: 2 }, + text: 'Find UsersAdd filter', + sha256: '125701967597da14d9f36d7274c5912ebabc157cb8fcec2bc6a762efde782998', }, 'components-complex-filter-builder/with-conditions': { - elements: 57, - tags: { DIV: 15, LABEL: 1, SPAN: 7, BUTTON: 9, svg: 8, path: 15, INPUT: 2 }, - text: 'User FiltersWhereANDClear allAgeGreater thanRemove conditionDepartmentEqualsRemove conditionAdd filter', - sha256: '685ae845f1ebc57c5054ec80da37582a3d387091f203b2c4166c4800cc110853', + elements: 56, + tags: { DIV: 15, LABEL: 1, SPAN: 6, BUTTON: 9, svg: 8, path: 15, INPUT: 2 }, + text: 'User FiltersANDClear allAgeGreater thanRemove conditionDepartmentEqualsRemove conditionAdd filter', + sha256: '32484ae9b631006d910189f31096ab2d71b7f885957dba0c106816f10b3cc835', }, }; @@ -237,8 +242,12 @@ describe('objectui#6939 — the repair moved the validator, not the renderer', ( const m = measure(asAuthored(id)); expect(m.text).not.toContain('failed to render'); expect(m.text).toContain('Add filter'); - expect(m.text).toContain('Where'); - expect(m.elements).toBeGreaterThan(10); + // objectstack#35549 dropped the builder's 「Where」 label: the condition + // rows start the panel. + expect(m.text).not.toContain('Where'); + // An empty builder draws 10 elements since its 「Where」 span went + // (objectstack#35549); an empty box or the error boundary draws far fewer. + expect(m.elements).toBeGreaterThanOrEqual(10); // Where the entry authors rows, the label of the column each row points at // must be ON SCREEN — the lookup that produces it is the `f.value === …` // match, so this is the reading that says `fields` arrived through the diff --git a/ui/packages/app-shell/src/views/ObjectView.personalViews-29635.test.tsx b/ui/packages/app-shell/src/views/ObjectView.personalViews-29635.test.tsx index 6b2a4cf0f25..7f5825cadcb 100644 --- a/ui/packages/app-shell/src/views/ObjectView.personalViews-29635.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.personalViews-29635.test.tsx @@ -32,6 +32,10 @@ */ import * as React from 'react'; +// The view config panel this file mounts reaches `import('@objectstack/lint')` +// inside a function body; paid here, at collection, rather than inside the +// first case's clocked window (check:test-source-alias). +import '@objectstack/lint'; import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest'; import { render, cleanup, screen, waitFor, within, fireEvent } from '@testing-library/react'; import { @@ -575,6 +579,9 @@ describe('objectstack#30073 — a personal view\'s conditions are Filter panel r expect(switcher()).toHaveTextContent('Paris leads'); await waitFor(() => expect(filterTrigger()).toHaveAttribute('aria-label', 'Filter, 1 active')); fireEvent.click(filterTrigger()); + // The trigger opens the shared field list (objectstack#35549); the panel + // rows are its advanced step. + fireEvent.click(await screen.findByTestId('filter-panel-open-advanced')); expect(await screen.findByDisplayValue('Paris')).toBeInTheDocument(); // The panel row is the condition: it is not laid under the list as well. await waitFor(() => expect(lastLeadRead(dataSource)).toContain('Paris')); diff --git a/ui/packages/components/src/custom/filter-builder.tsx b/ui/packages/components/src/custom/filter-builder.tsx index b48b717e0e1..2810b3a84c2 100644 --- a/ui/packages/components/src/custom/filter-builder.tsx +++ b/ui/packages/components/src/custom/filter-builder.tsx @@ -1186,7 +1186,6 @@ function toPairBounds( const useSafeFilterTranslation = createSafeTranslation( { - 'filterBuilder.where': 'Where', 'filterBuilder.and': 'AND', 'filterBuilder.or': 'OR', 'filterBuilder.clearAll': 'Clear all', @@ -1271,7 +1270,7 @@ const useSafeFilterTranslation = createSafeTranslation( // missing side. 'validation.required': '{{field}} is required', }, - 'filterBuilder.where', + 'filterBuilder.and', ) /** @@ -2279,7 +2278,6 @@ function FilterBuilder({
- {t('filterBuilder.where')} {visibleConditions.length > 1 && ( - -
-
-

{t('list.filterRecords')}

-
- { - // The panel keeps every row; the host stores only the - // filter that applies (objectstack#27520). - setCurrentFilters(newFilters); - if (onFilterChange) onFilterChange(appliedFilterGroup(newFilters)); - }} - /> -
+ + )} @@ -7264,8 +7332,16 @@ export const ListView = React.forwardRef(({ )} - - {sortPanelBody} + + setShowSort(false)} + footer={sortPanelNote} + renderAdvanced={() => sortPanelBody} + /> )} @@ -7737,7 +7813,25 @@ export const ListView = React.forwardRef(({ data-slot="list-condition-row" data-testid="list-condition-row" className="empty:hidden flex flex-wrap items-center gap-1.5 border-b px-4 py-1.5 bg-background" - /> + > + {/* objectstack#35549 / #35550: sort chips, the view's own + conditions as locked chips, the reader's filter chips, then + 「Add filter」 and 「Reset」. It draws nothing while there is + nothing to show, so the slot stays empty and takes no height. */} + +
)} {/* Filters Panel - Removed as it is now in Popover */} diff --git a/ui/packages/plugin-list/src/__tests__/ListView.columnsOnlyOptions-10547.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.columnsOnlyOptions-10547.test.tsx index 2f0da8572df..3f4f2f3d15b 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.columnsOnlyOptions-10547.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.columnsOnlyOptions-10547.test.tsx @@ -52,6 +52,7 @@ vi.mock('@object-ui/components', async (importOriginal) => { }); import { ListView } from '../ListView'; +import { openAdvancedFilter } from './conditionPanels'; const STATUS_OPTIONS = [ { value: 'open', label: 'Open' }, @@ -92,7 +93,7 @@ async function renderAndOpenFilter(columns: unknown[], getObjectSchema: () => Pr ); await waitFor(() => expect(dataSource.getObjectSchema).toHaveBeenCalled()); fireEvent.click(screen.getByRole('button', { name: /^filter/i })); - await screen.findByText('Filter Records'); + await openAdvancedFilter(); await waitFor(() => expect(captured.fields.length).toBeGreaterThan(0)); } diff --git a/ui/packages/plugin-list/src/__tests__/ListView.columnsOnlyRelationalReads-7531.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.columnsOnlyRelationalReads-7531.test.tsx index d9d377b11e2..cc0a1466475 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.columnsOnlyRelationalReads-7531.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.columnsOnlyRelationalReads-7531.test.tsx @@ -56,6 +56,7 @@ vi.mock('@object-ui/components', async (importOriginal) => { }); import { ListView } from '../ListView'; +import { openAdvancedFilter } from './conditionPanels'; /** The five spellings the fallback used to read, none declared on a column. */ const UNDECLARED_RELATIONAL_KEYS = { @@ -103,7 +104,7 @@ async function renderAndOpenFilter(columns: unknown[], getObjectSchema: () => Pr ); await waitFor(() => expect(dataSource.getObjectSchema).toHaveBeenCalled()); fireEvent.click(screen.getByRole('button', { name: /^filter/i })); - await screen.findByText('Filter Records'); + await openAdvancedFilter(); await waitFor(() => expect(captured.fields.length).toBeGreaterThan(0)); return dataSource; } diff --git a/ui/packages/plugin-list/src/__tests__/ListView.conditionRow-35549.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.conditionRow-35549.test.tsx new file mode 100644 index 00000000000..d9a25b3bfd4 --- /dev/null +++ b/ui/packages/plugin-list/src/__tests__/ListView.conditionRow-35549.test.tsx @@ -0,0 +1,140 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * The list's filter and sort redo, wired into `ListView` (objectstack#35549, + * objectstack#35550): the Filter and Sort triggers open the shared field list, + * and the condition row fills the `list-condition-row` slot objectstack#35548 + * laid under the view bar. The controls' own behaviour is pinned in + * `conditions/__tests__/listConditions.test.tsx`; layout and a real drag in + * `ui/e2e/list-condition-row-35549.spec.ts`. This file pins the seams: what + * `ListView` hands the controls and what it does with what they hand back. + */ +import { describe, it, expect, vi, afterEach } from 'vitest'; +import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import React from 'react'; +import type { DataSource, ListViewSchema } from '@object-ui/types'; +import { SchemaRendererProvider } from '@object-ui/react'; +import { ListView } from '../ListView'; + +const OBJECT = 'deal_35549'; +const DEFINITION = { + name: OBJECT, + label: 'Deal', + fields: { + name: { type: 'text', label: 'Name' }, + stage: { + type: 'select', + label: 'Stage', + options: [ + { value: 'proposal', label: 'Proposal' }, + { value: 'negotiation', label: 'Negotiation' }, + ], + }, + amount: { type: 'number', label: 'Amount' }, + close_date: { type: 'date', label: 'Close date' }, + }, +}; + +function mount(node: Record = {}, props: Partial> = {}) { + const ds = { + find: vi.fn().mockResolvedValue({ data: [{ id: '1', name: 'A', stage: 'proposal', amount: 3 }], total: 1 }), + findOne: vi.fn(), + create: vi.fn(), + update: vi.fn(), + delete: vi.fn(), + getObjectSchema: vi.fn(async () => structuredClone(DEFINITION)), + }; + const schema = { + type: 'list-view', + objectName: OBJECT, + viewType: 'grid', + columns: [{ field: 'name' }, { field: 'amount' }, { field: 'stage' }], + ...node, + } as unknown as ListViewSchema; + render( + + + , + ); + return ds; +} + +const slot = () => screen.getByTestId('list-condition-row'); + +afterEach(() => cleanup()); + +describe('ListView condition row and panels (objectstack#35549, objectstack#35550)', () => { + it('CONTROL: with no sort and no filter the slot stays empty', async () => { + const ds = mount(); + await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); + expect(slot()).toBeEmptyDOMElement(); + }); + + it('the Filter trigger opens the field list, the fields the view shows first; a pick applies at once and draws a chip', async () => { + const onFilterChange = vi.fn(); + const ds = mount({}, { onFilterChange }); + await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); + fireEvent.click(screen.getByTestId('toolbar-filter-trigger')); + const shown = await screen.findByTestId('filter-panel-fields-shown'); + expect(within(shown).getAllByRole('option').map((o) => o.getAttribute('data-field'))).toEqual(['name', 'amount', 'stage']); + fireEvent.click(screen.getByTestId('filter-panel-fields-item-stage')); + fireEvent.click(within(await screen.findByTestId('filter-panel-values-option-negotiation')).getByRole('checkbox')); + await waitFor(() => expect(onFilterChange).toHaveBeenCalled()); + const applied = onFilterChange.mock.calls.at(-1)![0]; + expect(applied.conditions).toEqual([expect.objectContaining({ field: 'stage', operator: 'in', value: ['negotiation'] })]); + expect(within(slot()).getByTestId('filter-chip-stage')).toHaveTextContent('Stage: Negotiation'); + }); + + it('the Sort trigger adds a level in the chosen direction, and the chip reads it; × hands back the sort without it', async () => { + const onSortChange = vi.fn(); + const ds = mount({}, { onSortChange }); + await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); + fireEvent.click(screen.getByTestId('toolbar-sort-trigger')); + fireEvent.click(await screen.findByTestId('sort-panel-order-desc')); + fireEvent.click(screen.getByTestId('sort-panel-fields-item-amount')); + await waitFor(() => expect(onSortChange).toHaveBeenCalled()); + expect(onSortChange.mock.calls.at(-1)![0].map((s: { field: string; order: string }) => [s.field, s.order])).toEqual([['amount', 'desc']]); + const chip = within(slot()).getByTestId('sort-chip-amount'); + expect(chip).toHaveAttribute('data-order', 'desc'); + fireEvent.click(within(slot()).getByTestId('sort-chip-remove-amount')); + await waitFor(() => expect(onSortChange.mock.calls.at(-1)![0]).toEqual([])); + }); + + it("the view's own filter is a locked chip, and Reset is disabled while the list matches the view", async () => { + const ds = mount({ filter: [['stage', '=', 'proposal']] }); + await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); + const locked = await within(slot()).findByTestId('view-condition-chip'); + expect(locked).toHaveAttribute('data-locked', 'true'); + expect(within(locked).queryByRole('button')).toBeNull(); + expect(within(slot()).getByTestId('condition-reset')).toBeDisabled(); + }); + + it('Reset clears the reader\'s filter and returns the sort to the view as saved', async () => { + const onFilterChange = vi.fn(); + const onSortChange = vi.fn(); + const ds = mount( + { sort: [{ field: 'name', order: 'asc' }] }, + { + onFilterChange, + onSortChange, + initialFilters: { id: 'root', logic: 'and', conditions: [{ id: 'c1', field: 'name', operator: 'contains', value: 'a' }] }, + }, + ); + await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); + fireEvent.click(await within(slot()).findByTestId('sort-chip-toggle-name')); + await waitFor(() => expect(onSortChange.mock.calls.at(-1)?.[0]?.[0]?.order).toBe('desc')); + const reset = within(slot()).getByTestId('condition-reset'); + expect(reset).toBeEnabled(); + await act(async () => fireEvent.click(reset)); + expect(onFilterChange.mock.calls.at(-1)![0].conditions).toEqual([]); + expect(onSortChange.mock.calls.at(-1)![0].map((s: { field: string; order: string }) => [s.field, s.order])).toEqual([['name', 'asc']]); + await waitFor(() => expect(within(slot()).queryByTestId('filter-chip-name')).toBeNull()); + }); +}); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.datasetChartAppliedFilter-10512.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.datasetChartAppliedFilter-10512.test.tsx index 9fb918f8e2d..030fdb464c4 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.datasetChartAppliedFilter-10512.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.datasetChartAppliedFilter-10512.test.tsx @@ -151,7 +151,9 @@ const hostFilters = (dataSource: { find: ReturnType }) => dataSource.find.mock.calls.map((c: unknown[]) => (c[1] as Record | undefined)?.$filter); const names = (filter: unknown, field: string) => JSON.stringify(filter ?? null).includes(`"${field}"`); const countBar = () => screen.getByTestId('record-count-bar'); -const filterButton = () => screen.queryByRole('button', { name: /filter/i }); +// The toolbar trigger by its test id: the condition row's 「Add filter」 is a +// second button named for filters (objectstack#35549). +const filterButton = () => screen.queryByTestId('toolbar-filter-trigger'); const settle = () => new Promise((r) => setTimeout(r, 50)); const pick = (name: string) => { diff --git a/ui/packages/plugin-list/src/__tests__/ListView.declaredDisplayField-10545.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.declaredDisplayField-10545.test.tsx index 50ae721b36a..41cb17c44b8 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.declaredDisplayField-10545.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.declaredDisplayField-10545.test.tsx @@ -56,6 +56,7 @@ vi.mock('@object-ui/components', async (importOriginal) => { }); import { ListView } from '../ListView'; +import { openAdvancedFilter } from './conditionPanels'; /** The lookup def with no display spelling at all. */ const BARE_LOOKUP = { type: 'lookup', label: 'Account', reference: 'crm_account' } as const; @@ -103,7 +104,7 @@ async function lookupCandidateFor(accountDef: Record): Promise< , ); fireEvent.click(screen.getByRole('button', { name: /^filter/i })); - await screen.findByText('Filter Records'); + await openAdvancedFilter(); // `referenceTo` is read off the definition only (objectui#7531), so seeing // it proves the candidate below came from the `objectDef.fields` branch. await waitFor(() => { diff --git a/ui/packages/plugin-list/src/__tests__/ListView.fieldListRead-11984.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.fieldListRead-11984.test.tsx index 93209926343..79050f38294 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.fieldListRead-11984.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.fieldListRead-11984.test.tsx @@ -188,6 +188,18 @@ async function inPopover(trigger: HTMLElement, read: (content: HTMLElement) = const toolbarButton = (name: RegExp) => screen.getByRole('button', { name }); +/** The rows of the shared field list (objectstack#35549), in the order it draws them. */ +function fieldListLabels(scope: HTMLElement): string[] { + return Array.from(scope.querySelectorAll('[role="option"][data-field]')).map(text); +} + +/** Step from the field list into its advanced panel (today's builder) and read its first field picker. */ +async function advancedFieldOptions(content: HTMLElement, kind: 'filter' | 'sort'): Promise { + fireEvent.click(within(content).getByTestId(`${kind}-panel-open-advanced`)); + const advanced = await within(content).findByTestId(`${kind}-panel-advanced`); + return comboboxOptions(within(advanced).getAllByRole('combobox')[0]); +} + function checkboxLabels(scope: HTMLElement): string[] { // The Display panel's Edit inline entry is a `role="switch"` button since // objectui#12423, so every checkbox here is a field's. @@ -243,6 +255,9 @@ async function sweepToolbar(): Promise { const content = await openPopover(trigger); const items = [ ...Array.from(content.querySelectorAll('option')).map(text), + // The shared field list the Filter and Sort triggers open + // (objectstack#35549, objectstack#35550): a row per field, `role="option"`. + ...fieldListLabels(content), ...checkboxLabels(content), ]; for (const combobox of Array.from(content.querySelectorAll('[role="combobox"]'))) { @@ -308,12 +323,22 @@ const POSITIONS: Position[] = [ { name: 'the Filter panel (objectui#11925)', props: HELD_FILTER, - read: () => inPopover(toolbarButton(/^filter/i), (c) => comboboxOptions(within(c).getAllByRole('combobox')[0])), + read: () => inPopover(toolbarButton(/^filter/i), fieldListLabels), + }, + { + name: 'the Filter panel, advanced step', + props: HELD_FILTER, + read: () => inPopover(toolbarButton(/^filter/i), (c) => advancedFieldOptions(c, 'filter')), }, { name: 'the Sort picker (objectui#11943)', schemaExtra: { sort: [{ field: 'title', order: 'asc' }] }, - read: () => inPopover(toolbarButton(/^sort/i), (c) => comboboxOptions(within(c).getAllByRole('combobox')[0])), + read: () => inPopover(toolbarButton(/^sort/i), fieldListLabels), + }, + { + name: 'the Sort picker, advanced step', + schemaExtra: { sort: [{ field: 'title', order: 'asc' }] }, + read: () => inPopover(toolbarButton(/^sort/i), (c) => advancedFieldOptions(c, 'sort')), }, { name: 'the hide-fields popover', diff --git a/ui/packages/plugin-list/src/__tests__/ListView.filterDatePicker-12743.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.filterDatePicker-12743.test.tsx index 4e3dcf39f4d..77bcea562a5 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.filterDatePicker-12743.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.filterDatePicker-12743.test.tsx @@ -35,6 +35,7 @@ import { SchemaRendererProvider } from '@object-ui/react'; import { I18nProvider } from '@object-ui/i18n'; import { registerAllFields } from '@object-ui/fields'; import { ListView } from '../ListView'; +import { openAdvancedFilter } from './conditionPanels'; registerAllFields(); @@ -107,11 +108,16 @@ function mount(conditions: Row[], language?: string) { return { dataSource, onFilterChange }; } -/** Open the toolbar's Filter panel once the definition has loaded. */ +/** + * Open the toolbar's Filter panel once the definition has loaded, and step + * into its advanced panel, where these rows are drawn (objectstack#35549). + */ async function openFilterPanel(dataSource: { getObjectSchema: ReturnType }): Promise { await waitFor(() => expect(dataSource.getObjectSchema).toHaveBeenCalled()); fireEvent.click(await screen.findByTestId('toolbar-filter-trigger')); - return screen.findByRole('dialog'); + const dialog = await screen.findByRole('dialog'); + await openAdvancedFilter(); + return dialog; } /** The lazily loaded picker's text box inside the panel. */ diff --git a/ui/packages/plugin-list/src/__tests__/ListView.filterFieldList-11810.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.filterFieldList-11810.test.tsx index 5fa48128054..5efb13c1065 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.filterFieldList-11810.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.filterFieldList-11810.test.tsx @@ -51,6 +51,7 @@ vi.mock('@object-ui/components', async (importOriginal) => { }); import { ListView } from '../ListView'; +import { openAdvancedFilter } from './conditionPanels'; /** The declared fields of the showcase Tasks object, in declaration order. */ const DECLARED: Record> = { @@ -118,7 +119,7 @@ function mount(schemaExtra: Record = {}, props: Record { fireEvent.click(screen.getByRole('button', { name: /^filter/i })); - await screen.findByText('Filter Records'); + await openAdvancedFilter(); await waitFor(() => { const latest = captured.fields[captured.fields.length - 1] ?? []; // `estimate_hours` is no column, so seeing it proves the definition loaded. diff --git a/ui/packages/plugin-list/src/__tests__/ListView.filterFieldRead-11925.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.filterFieldRead-11925.test.tsx index f26f6f5700c..867f234048d 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.filterFieldRead-11925.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.filterFieldRead-11925.test.tsx @@ -46,6 +46,7 @@ vi.mock('@object-ui/components', async (importOriginal) => { }); import { ListView } from '../ListView'; +import { openAdvancedFilter } from './conditionPanels'; const OBJECT = 'fls_ticket'; @@ -121,7 +122,7 @@ function mount({ perms, schemaExtra = {}, props = {}, noDefinitionFields = false */ async function openFilterFieldList(): Promise { fireEvent.click(screen.getByRole('button', { name: /^filter/i })); - await screen.findByText('Filter Records'); + await openAdvancedFilter(); await waitFor(() => { const latest = captured.fields[captured.fields.length - 1] ?? []; expect(latest.some((f) => f.value === 'priority')).toBe(true); @@ -192,7 +193,7 @@ describe('the Filter panel field list asks the column read check (objectui#11925 it('the declared-columns fallback (no fields in the definition) drops it too', async () => { mount({ perms: RESTRICTED, noDefinitionFields: true }); fireEvent.click(screen.getByRole('button', { name: /^filter/i })); - await screen.findByText('Filter Records'); + await openAdvancedFilter(); await waitFor(() => { const latest = (captured.fields[captured.fields.length - 1] ?? []).map((f) => f.value); expect(latest).toEqual(['title', 'status']); @@ -202,7 +203,7 @@ describe('the Filter panel field list asks the column read check (objectui#11925 it('control: the declared-columns fallback still offers every column to a user who may read them all', async () => { mount({ perms: FULL_READ, noDefinitionFields: true }); fireEvent.click(screen.getByRole('button', { name: /^filter/i })); - await screen.findByText('Filter Records'); + await openAdvancedFilter(); await waitFor(() => { const latest = (captured.fields[captured.fields.length - 1] ?? []).map((f) => f.value); expect(latest).toEqual(COLUMNS); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx index 1b837806fc4..3f58d49cbff 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx @@ -62,6 +62,7 @@ import { MePermissionsProvider, type MePermissionsAuthenticatedResponse } from ' import type { ListViewSchema } from '@object-ui/types'; import { ListView, LIST_DEFAULT_TRANSLATIONS, viewFilterRequiresOwner } from '../ListView'; import { filterNamesCurrentUser } from '../ListEmptyState'; +import { openAdvancedSort } from './conditionPanels'; /** * Puts back, after the calling block's last test, what the block's hooks and @@ -1968,7 +1969,13 @@ describe('ListView.draftOnlyColumn-34807', () => { const content = document.getElementById(trigger.getAttribute('aria-controls') ?? ''); if (!content) throw new Error(`no popover content for "${text(trigger)}"`); try { - return await comboboxOptions(within(content).getAllByRole('combobox')[0]); + // The trigger opens the shared field list (objectstack#35549); its + // advanced step is the builder, whose first picker reads the same list. + // Both are read, so a field either offers is caught. + const listed = Array.from(content.querySelectorAll('[role="option"][data-field]')).map(text); + fireEvent.click(within(content).getByTestId(/^(filter|sort)-panel-open-advanced$/)); + const advanced = await within(content).findByTestId(/^(filter|sort)-panel-advanced$/); + return [...listed, ...(await comboboxOptions(within(advanced).getAllByRole('combobox')[0]))]; } finally { fireEvent.click(trigger); await waitFor(() => expect(trigger).toHaveAttribute('aria-expanded', 'false')); @@ -2822,7 +2829,7 @@ describe('ListView.resetSortToDefaultNoProviderFallback', () => { ); await waitFor(() => expect(dataSource.getObjectSchema).toHaveBeenCalled()); fireEvent.click(screen.getByRole('button', { name: /^sort/i })); - await screen.findByText('Sort Records'); + await openAdvancedSort(); } describe('ListView reset-sort control — English fallback with no provider (objectui#4396)', () => { diff --git a/ui/packages/plugin-list/src/__tests__/ListView.personalization-28950.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.personalization-28950.test.tsx index 28ad31b625e..bc43aebacbd 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.personalization-28950.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.personalization-28950.test.tsx @@ -26,6 +26,7 @@ import { ComponentRegistry } from '@object-ui/core'; import { SchemaRendererProvider } from '@object-ui/react'; import type { ListViewSchema } from '@object-ui/types'; import { ListView, type ListViewProps } from '../ListView'; +import { openAdvancedSort } from './conditionPanels'; const RECORDS = [{ id: '1', name: 'Acme', stage: 'won', amount: 3 }]; const OBJECT_DEF = { @@ -208,7 +209,7 @@ describe('with the callback wired, the host owns the one reset (objectstack#2895 await screen.findByTestId('grid-stub'); await waitFor(() => expect(dataSource.getObjectSchema).toHaveBeenCalled()); fireEvent.click(screen.getByRole('button', { name: /^sort/i })); - await screen.findByText('Sort Records'); + await openAdvancedSort(); expect(screen.getByTestId('sort-reset-default')).toBeEnabled(); }); }); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.phoneWidth-29074.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.phoneWidth-29074.test.tsx index b042d3377dc..25abc35e10f 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.phoneWidth-29074.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.phoneWidth-29074.test.tsx @@ -31,6 +31,7 @@ import { SchemaRendererProvider } from '@object-ui/react'; import type { ListViewSchema } from '@object-ui/types'; import { ListView } from '../ListView'; import { PHONE_TOUCH_TARGET, useBelowSm } from '../components/ViewSettingsPopover'; +import { openAdvancedSort } from './conditionPanels'; const RECORDS = [{ id: '1', name: 'Acme', stage: 'won' }]; @@ -125,7 +126,7 @@ describe('an active sort shows on the phone bar (objectstack#29057)', () => { expect(trigger).toHaveAccessibleName('Sort'); fireEvent.click(trigger); - expect(await screen.findByText('Sort Records')).toBeVisible(); + expect(await openAdvancedSort()).toBeVisible(); }); it('narrow, sorted: the open search field takes the Sort trigger slot, which comes back when it folds', async () => { diff --git a/ui/packages/plugin-list/src/__tests__/ListView.relationalSort.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.relationalSort.test.tsx index 48d082f54e8..f94ea3c40c2 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.relationalSort.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.relationalSort.test.tsx @@ -26,6 +26,7 @@ import React from 'react'; import { ListView } from '../ListView'; import type { ListViewSchema } from '@object-ui/types'; import { SchemaRendererProvider } from '@object-ui/react'; +import { openAdvancedSort } from './conditionPanels'; const objectDef = { name: 'contacts', @@ -77,7 +78,7 @@ async function openSortPopover(schema: ListViewSchema) { ); await waitFor(() => expect(dataSource.getObjectSchema).toHaveBeenCalled()); fireEvent.click(screen.getByRole('button', { name: /^sort/i })); - return await screen.findByText('Sort Records'); + return await openAdvancedSort(); } /** Labels offered by the sort field