Skip to content

Commit cd7f785

Browse files
fix(app-shell): offer the 变更 chip only when the reader's audit read answers (#30451)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuXpPPZiBKyj1HzrdQ6La3ZH)_ domain:ui#6 · os-sales · session_01L6bhgUR8Nu4M7tbtgES7q2 Fixes #30344 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:记录页「动态」的「变更」筛选,以及活动面板下拉里的「字段变更」选项,只在当前读者对审计日志的读取成功之后才出现;读取被拒(403)或失败时都不出现,与关闭字段历史时一样。 - 为什么改:没有审计日志读权限的销售打开开启了字段历史的线索,点「变更」永远是空的,会误以为「没人改过这条记录」或筛选坏了。 - 风险与回滚:只改前端两处判断(记录页一处、活动面板下拉一处,共用同一条规则),不加请求、不让页面等待;能读的用户在审计读取返回后才看到「变更」;没有宿主声明时下拉照旧四项。回滚即还原本 PR。 - 先看:`ui/packages/app-shell/src/views/RecordDetailView.tsx` 中 `fieldHistoryShown` 与审计读取 `.catch`;`ui/packages/plugin-detail/src/RecordActivityTimeline.tsx` 中 `getFilterOptions` 与 `activeFilter`;两个测试文件的新用例。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/app-shell/src/views/RecordDetailView.recordPageTiers-26678.test.tsx packages/plugin-detail/src/__tests__/recordTimelineStream-27055.test.tsx`,预期全过(未修复时 403 用例多出 `changes`,下拉用例多出 Field Changes)。 - 需要你做的:无,席位落地。 ## What changes `RecordDetailView` told the timeline stream whether the record shows its field history (`RecordFieldHistoryContext`, which decides the 变更 chip) from `historyEnabled` alone: `enable.trackHistory` plus whether `sys_audit_log` is registered. It never asked whether this reader's audit read answered. A member the server refuses that read to got a 变更 chip that always filtered to nothing. Now the context carries `fieldHistoryShown = historyEnabled && historyEntries !== null`: - The audit read's `.catch` (a refusal, or any other failure) now leaves `historyEntries` at `null` instead of `[]`. `null` is what the code already means by "no answer" (`timelineFieldChanges` documents it so), and the stream merges `null` and `[]` the same way, so no row changes. - So the chip is offered only once the read has answered, and a refused read draws no chip, as history off does (ruling C on #30074 is unchanged). **The panel dropdown.** `RecordActivityTimeline`'s filter dropdown (the panel face, `getFilterOptions`) now reads `RecordFieldHistoryContext` and offers `changes_only` exactly when `timelineStreamFilters(fieldHistory)` offers the stream's `changes` chip. It reuses the stream's rule instead of adding a second one. The context's default stays `true`, so a host with no provider keeps all four options. A chosen or controlled `changes_only` that is no longer offered reads as `all`, the way the stream's chips fall back. **Why this shape (no wait).** Nothing waits on the audit read. `historyEnabled` still gates the read itself (`historyPage` / `historyWanted`, so the read still goes out only when the stream is on screen) and still asks the page payload's `timeline.fieldChanges`. Only the chip waits: on the 动态 tab it joins the other three chips when the read answers. Two other shapes were considered and not taken: - Hide the chip on a refusal only, and offer it while the read is pending. A refused reader then sees the chip appear and disappear, and a failed (5xx) read still offers an always-empty chip. The card asks for "offered only when this reader's audit read succeeds". - Hold the 动态 tab until the read lands. That makes the page wait, which the code today avoids. **The 动态 count.** No change is needed. With a payload, the server counts each source as the caller does (`record-page-routes.ts` `answerTimeline`: "a refused ledger count is no field change"), and with zero field changes it keeps the `updated` activity rows. On the client, `mergeTimelineStream` also keeps `updated` rows when there are no field changes. Without a payload, the stream counts its own rows. Either way, a refused read counts no field change. ## Tests One new case in the shared harness `RecordDetailView.recordPageTiers-26678.test.tsx`, in the existing #30074 `describe` (the harness rule: a new pin goes into the component's shared harness file): - `a reader whose audit read is refused (403): no 变更 chip, as with history off`. The `sys_audit_log` read rejects in the client's shape (`httpStatus: 403`, `code: 'PERMISSION_DENIED'`). The case waits for the read to go out and settle, then asserts the chips are exactly `all / activity / discussion`. - Positive control: the existing `trackHistory` case now asserts the four chips after the read has answered (zero rows): history on and readable keeps 变更. - The existing history-off case is unchanged: no 变更, and no audit read. - New top-level describe in the stream harness `recordTimelineStream-27055.test.tsx`: "the panel's `changes_only` is offered by the same rule as the 变更 chip". It covers four cases. History shown offers four options. History not shown offers no Field Changes. No provider offers four options (control). A `changes_only` that is not offered reads as All Activity and every entry draws. A history-shown `changes_only` control still filters to the field change only. ## Acceptance notes - The panel dropdown was first left out because it was outside the claimed surface. The seat's amendment 6657436301 widened the surface, and this PR now carries the dropdown too. - A failed (non-refusal) audit read now withholds the chip too, since it also answers nothing. The read is not retried. This is unchanged from before, when it showed an empty 变更. ## Verification <details><summary>Red on the unfixed view, green with the fix</summary> Unfixed: `RecordDetailView.tsx` restored from `a91409c4` in the tree only (marker `fieldHistoryShown` count 0). Then restored with `git checkout HEAD --`, hash-checked against the HEAD blob (RESTORED-OK), and `git diff HEAD` was empty. ``` × a reader whose audit read is refused (403): no 变更 chip, as with history off - Expected + Received [ "all", "activity", "discussion", + "changes", ] Tests 1 failed | 8 passed (9) os-verify-lock: VERDICT command-exit 1 ``` Fixed: ``` pnpm --dir ui exec vitest run --maxWorkers=2 (recordPageTiers-26678, timelineCount-28737, auditDisplayLocale-10442, auditTenantCurrency-27640, recordOpenWaves-13010) Test Files 5 passed (5) Tests 41 passed (41) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Panel dropdown: red without the plugin-detail change, green with it</summary> Unfixed: `RecordActivityTimeline.tsx` restored in the tree from the merge commit `b4b0fb6157` (marker `changesOffered` count 0). Then restored with `git checkout HEAD --`, hash-checked against the HEAD blob (RESTORED-OK), and the status was clean. ``` × history not shown (history off, or a reader whose audit read did not answer): no `changes_only` × a `changes_only` the dropdown does not offer reads as 全部: every entry draws Tests 2 failed | 30 passed (32) os-verify-lock: VERDICT command-exit 1 ``` Fixed: `Tests 32 passed (32)`, VERDICT command-exit 0. The two CONTROL cases pass on both legs. </details> <details><summary>Package and gates (head 6a04550, after merging origin/main b4b0fb6)</summary> All of the following were measured on head `6a045506`, in one lock hold. - Tests, narrowed: every `RecordDetailView.*.test.tsx` file (102) plus `packages/plugin-detail/src/`. Result: `Test Files 473 passed | 1 skipped (474)`, `Tests 3968 passed | 18 skipped (3986)`, exit 0. This narrowing is declared. The full `app-shell/src/views/` suite (1,477 files) belongs to CI's `Test UI`. - `pnpm --filter @object-ui/app-shell run type-check`: exit 0. `pnpm --filter @object-ui/plugin-detail run type-check`: exit 0. Both ran after `turbo run build --filter='@object-ui/app-shell^...'` (67/67 tasks). - `eslint` on the four changed source and test files: 0 errors. The warnings are all on lines already on main. - `pnpm --dir ui run check:new-line-citations`: `0 new citation(s)`. - `node scripts/pm/dispatch-gates.mjs --ran`: `35 derived famil(ies) accounted for — 35 run, 0 NOT-MEASURED (a DERIVED zero)`. Each command and its exit code: ``` node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0 node scripts/check-adr-0087-registration.mjs --self-test :: exit 0 node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-empty-changeset.mjs --base origin/main :: exit 0 node scripts/check-empty-changeset.mjs --self-test :: exit 0 node scripts/check-sdui-manifest.mjs :: exit 0 node scripts/check-sdui-manifest.mjs --self-test :: exit 0 node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0 node scripts/release-pending-publish.mjs --self-test :: exit 0 pnpm --dir ui exec vitest run scripts/ :: exit 0 pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0 pnpm check:changeset-gate-self-tests :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:dispatcher-error-vocabulary :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:engine-double-contract :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:published-files :: exit 0 pnpm check:query-options-erasure :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:registry-log-declared :: exit 0 pnpm check:rest-log-spy-declared :: exit 0 pnpm check:skill-identifier-liveness :: exit 0 pnpm check:test-source-alias :: exit 0 pnpm check:tier-file-adoption :: exit 0 pnpm check:type-check-coverage :: exit 0 pnpm check:type-check-debt :: exit 0 pnpm check:undeclared-dep-imports :: exit 0 pnpm check:watch-hint-literal :: exit 0 pnpm check:where-matcher :: exit 0 pnpm check:changeset-fixed :: exit 0 ``` </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01L6bhgUR8Nu4M7tbtgES7q2)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgUR8Nu4M7tbtgES7q2 <!-- signed: domain:ui#6 · os-sales · session_01L6bhgUR8Nu4M7tbtgES7q2 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent e760204 commit cd7f785

5 files changed

Lines changed: 144 additions & 16 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/plugin-detail': patch
4+
---
5+
6+
fix(app-shell,plugin-detail): the record page offers its 变更 (Field changes) chip, and the activity panel its Field Changes option, only to a reader whose audit-log read answers
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
On an object with `enable.trackHistory`, the record page's 动态 (Activity) tab offered the chips 全部 / 活动 / 讨论 / 变更 whenever `sys_audit_log` was registered, whatever this reader was allowed to read. A member the server refuses the audit read to (403) got a 变更 chip that always showed nothing, which reads as "nobody changed this record". The page now offers 变更 only once this reader's `sys_audit_log` read has answered. A refused or failed read offers no 变更 chip, exactly as history off does, and the chip joins the others when the read answers. Nothing else waits on the read: the page payload still asks the field changes as before, and the stream's count already counts a refused audit read as no field change.
12+
13+
The activity panel's filter dropdown follows the same rule: it offers Field Changes (`changes_only`) only when the stream would offer its 变更 chip. A host that says nothing keeps every option, as before. A `changes_only` filter that is no longer offered reads as All Activity.

‎ui/packages/app-shell/src/views/RecordDetailView.recordPageTiers-26678.test.tsx‎

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
import * as React from 'react';
3636
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
37-
import { render, screen, cleanup, waitFor } from '@testing-library/react';
37+
import { act, render, screen, cleanup, waitFor } from '@testing-library/react';
3838
import { MemoryRouter } from 'react-router-dom';
3939
import { MetadataCtx } from '@object-ui/react';
4040
import { RelatedCountStore } from '@object-ui/components';
@@ -140,9 +140,18 @@ let dataSource: { find: ReturnType<typeof vi.fn> } & Record<string, unknown>;
140140
*/
141141
const RELATED_TOTALS: Record<string, number> = { showcase_task: 2, showcase_note: 1 };
142142

143-
function makeDataSource() {
143+
/**
144+
* A rejected read in the shape the ObjectStack client throws it: the HTTP
145+
* status on `httpStatus` and the ADR-0112 code on `code`.
146+
*/
147+
const rejection = (httpStatus: number, code: string) =>
148+
Object.assign(new Error(`${httpStatus} ${code}`), { httpStatus, code });
149+
150+
function makeDataSource(auditRead?: () => Promise<unknown>) {
144151
return {
145-
find: vi.fn(async (objectName: string) => ({ data: [], total: RELATED_TOTALS[objectName] ?? 0 })),
152+
find: vi.fn(async (objectName: string) =>
153+
objectName === 'sys_audit_log' && auditRead ? auditRead() : { data: [], total: RELATED_TOTALS[objectName] ?? 0 },
154+
),
146155
create: vi.fn(async (_o: string, row: unknown) => row),
147156
findOne: vi.fn(async (_o: string, recordId: string) => ({
148157
id: recordId,
@@ -161,10 +170,19 @@ function renderPage({
161170
search = '',
162171
windowWidth = 1440,
163172
objects = OBJECTS,
164-
}: { width: number; embedded?: boolean; search?: string; windowWidth?: number; objects?: typeof OBJECTS }) {
173+
auditRead,
174+
}: {
175+
width: number;
176+
embedded?: boolean;
177+
search?: string;
178+
windowWidth?: number;
179+
objects?: typeof OBJECTS;
180+
/** How this reader's `sys_audit_log` read answers; omitted, it answers no rows. */
181+
auditRead?: () => Promise<unknown>;
182+
}) {
165183
rootWidth = width;
166184
Object.defineProperty(window, 'innerWidth', { value: windowWidth, configurable: true, writable: true });
167-
dataSource = makeDataSource();
185+
dataSource = makeDataSource(auditRead);
168186
const metadata = {
169187
objects,
170188
pages: [],
@@ -377,9 +395,19 @@ describe('RecordDetailView — the 动态 tab offers 变更 only while the recor
377395
{ timeout: 5000 },
378396
);
379397

380-
it('an object with `enable.trackHistory`: 全部 / 活动 / 讨论 / 变更', async () => {
398+
/** The chips once this reader's audit read has gone out and settled. */
399+
const streamChipsAfterAuditRead = async (container: HTMLElement) => {
400+
await streamChips(container);
401+
await waitFor(() => expect(auditReads()).toBeGreaterThan(0), { timeout: 5000 });
402+
await act(async () => {
403+
await new Promise((resolve) => setTimeout(resolve, 0));
404+
});
405+
return streamChips(container);
406+
};
407+
408+
it('an object with `enable.trackHistory`, its audit read answered: 全部 / 活动 / 讨论 / 变更', async () => {
381409
const { container } = renderPage({ width: 1440, search: '?related=timeline' });
382-
expect(await streamChips(container)).toEqual(['all', 'activity', 'discussion', 'changes']);
410+
expect(await streamChipsAfterAuditRead(container)).toEqual(['all', 'activity', 'discussion', 'changes']);
383411
});
384412

385413
it('the same object without it: no 变更 chip, and no audit read', async () => {
@@ -388,4 +416,16 @@ describe('RecordDetailView — the 动态 tab offers 变更 only while the recor
388416
expect(await streamChips(container)).toEqual(['all', 'activity', 'discussion']);
389417
expect(auditReads()).toBe(0);
390418
});
419+
420+
// objectstack#30344 — the field history this record page shows is the one
421+
// THIS reader's audit read answers: a reader the server refuses it to has
422+
// nothing for 变更 to hold, so the chip is not offered, as with history off.
423+
it('a reader whose audit read is refused (403): no 变更 chip, as with history off', async () => {
424+
const { container } = renderPage({
425+
width: 1440,
426+
search: '?related=timeline',
427+
auditRead: () => Promise.reject(rejection(403, 'PERMISSION_DENIED')),
428+
});
429+
expect(await streamChipsAfterAuditRead(container)).toEqual(['all', 'activity', 'discussion']);
430+
});
391431
});

‎ui/packages/app-shell/src/views/RecordDetailView.tsx‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,7 +2906,10 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
29062906
.catch((err: any) => {
29072907
if (cancelled) return;
29082908
console.warn('[RecordDetailView] Failed to fetch sys_audit_log:', err);
2909-
setHistoryEntries([]);
2909+
// No answer, no field history: a refused (or failed) read holds
2910+
// nothing for the stream's 变更 chip, which `fieldHistoryShown`
2911+
// below withholds while the entries are `null`.
2912+
setHistoryEntries(null);
29102913
})
29112914
.finally(() => {
29122915
if (!cancelled) setHistoryLoading(false);
@@ -4147,9 +4150,18 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
41474150
// ride this list at all — objectui#3055 moved them to the declared-action
41484151
// bar, which reads the pending row directly.)
41494152
}, [objectDef?.name, childRelations, t, objectPluralLabel, objects, approvals.available, approvals.pendingRequest, approvals.requests, user?.id]);
4153+
// objectstack#30344 — whether this record page shows the record's field
4154+
// history: the history gate, AND this reader's audit read answered. A read
4155+
// the server refuses (or that fails) answers nothing, so the stream offers
4156+
// no 变更 chip, as with history off (objectstack#30074); the chip joins
4157+
// the others once the read answers. Nothing waits on it: the page payload
4158+
// still asks the field changes by `historyEnabled`, and the server counts a
4159+
// refused ledger read as no field change (objectstack#28737).
4160+
const fieldHistoryShown = historyEnabled && historyEntries !== null;
41504161
// objectstack#27055, Target 3 — the record's field changes, as feed items of
41514162
// the timeline stream. `null` while there are none to give (no
4152-
// `trackHistory`, an authored page, the read not made or not landed).
4163+
// `trackHistory`, an authored page, the read not made, not landed or not
4164+
// answered).
41534165
const timelineFieldChanges = useMemo(
41544166
() =>
41554167
historyEnabled && historyEntries
@@ -5069,9 +5081,10 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
50695081
{/* objectstack#27055 — the field changes of the timeline stream,
50705082
for the synthesized page's `record:activity`. */}
50715083
<RecordFieldChangesContext.Provider value={assignedPage ? null : timelineFieldChanges}>
5072-
{/* objectstack#30074 — whether this record shows its field history:
5084+
{/* objectstack#30074 — whether this record shows its field history
5085+
(objectstack#30344: to this reader, whose audit read answered):
50735086
the stream offers its 变更 chip only while it does. */}
5074-
<RecordFieldHistoryContext.Provider value={historyEnabled}>
5087+
<RecordFieldHistoryContext.Provider value={fieldHistoryShown}>
50755088
{/* objectstack#28737 — the whole stream's count, for the 动态 panel,
50765089
its tab and the tab row's probe. */}
50775090
<RecordTimelineTotalContext.Provider value={assignedPage ? null : timelineTotal}>

‎ui/packages/plugin-detail/src/RecordActivityTimeline.tsx‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ import {
4848
type ActivityTimelineEntry,
4949
} from './renderers/recordActivityFeed';
5050
import {
51+
RecordFieldHistoryContext,
5152
TIMELINE_STREAM_FILTERS,
5253
fieldHistoryEntriesOf,
5354
fieldHistoryOf,
5455
filterTimelineStream,
5556
isSystemStreamEntry,
57+
timelineStreamFilters,
5658
type TimelineStreamFilter,
5759
} from './recordTimelineStream';
5860

@@ -219,11 +221,21 @@ const FEED_TYPE_COLORS: Record<FeedItemType, string> = {
219221
approval: 'bg-violet-100 text-violet-600',
220222
};
221223

222-
function getFilterOptions(t: (key: string) => string): { value: FeedFilterMode; label: string }[] {
224+
/**
225+
* The dropdown's options, given whether the record's field history is shown
226+
* (`RecordFieldHistoryContext`): `changes_only` is offered exactly when the
227+
* stream offers its 变更 chip — the one rule, `timelineStreamFilters`
228+
* (objectstack#30074, objectstack#30344).
229+
*/
230+
function getFilterOptions(
231+
t: (key: string) => string,
232+
fieldHistory: boolean,
233+
): { value: FeedFilterMode; label: string }[] {
234+
const changesOffered = timelineStreamFilters(fieldHistory).includes('changes');
223235
return [
224236
{ value: 'all', label: t('detail.allActivity') },
225237
{ value: 'comments_only', label: t('detail.commentsOnly') },
226-
{ value: 'changes_only', label: t('detail.fieldChangesFilter') },
238+
...(changesOffered ? [{ value: 'changes_only' as const, label: t('detail.fieldChangesFilter') }] : []),
227239
{ value: 'tasks_only', label: t('detail.tasksOnly') },
228240
];
229241
}
@@ -464,7 +476,11 @@ export const RecordActivityTimeline: React.FC<RecordActivityTimelineProps> = ({
464476
</>
465477
) : null;
466478

467-
const activeFilter = controlledFilter ?? internalFilter;
479+
// A filter the dropdown does not offer filters nothing: it reads as `all`,
480+
// as the stream's chips do.
481+
const filterOptions = getFilterOptions(t, React.useContext(RecordFieldHistoryContext));
482+
const chosenFilter = controlledFilter ?? internalFilter;
483+
const activeFilter: FeedFilterMode = filterOptions.some((opt) => opt.value === chosenFilter) ? chosenFilter : 'all';
468484
const showFilter = config?.showFilterToggle !== false;
469485
const showCommentInput = config?.showCommentInput !== false && !!onAddComment;
470486
const enableReactions = config?.enableReactions ?? false;
@@ -1069,7 +1085,7 @@ export const RecordActivityTimeline: React.FC<RecordActivityTimelineProps> = ({
10691085
<SelectValue />
10701086
</SelectTrigger>
10711087
<SelectContent>
1072-
{getFilterOptions(t).map((opt) => (
1088+
{filterOptions.map((opt) => (
10731089
<SelectItem key={opt.value} value={opt.value}>
10741090
{opt.label}
10751091
</SelectItem>

‎ui/packages/plugin-detail/src/__tests__/recordTimelineStream-27055.test.tsx‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import React from 'react';
1919
import { describe, it, expect, afterEach } from 'vitest';
20-
import { render, screen, cleanup, fireEvent } from '@testing-library/react';
20+
import { render, screen, cleanup, fireEvent, within } from '@testing-library/react';
2121
import { DiscussionContextProvider } from '@object-ui/react';
2222
import type { FeedItem } from '@object-ui/types';
2323
import {
@@ -194,6 +194,52 @@ describe('the 变更 chip is offered only while the record shows its field histo
194194
});
195195
});
196196

197+
describe("the panel's `changes_only` is offered by the same rule as the 变更 chip (objectstack#30344)", () => {
198+
const panel = (fieldHistory: boolean | undefined, filterMode?: 'all' | 'changes_only') => {
199+
const timeline = <RecordActivityTimeline items={[call, comment, ...audit]} filterMode={filterMode} />;
200+
return fieldHistory === undefined ? (
201+
timeline
202+
) : (
203+
<RecordFieldHistoryContext.Provider value={fieldHistory}>{timeline}</RecordFieldHistoryContext.Provider>
204+
);
205+
};
206+
/** The dropdown's options, in order, read off the opened list. */
207+
const options = async () => {
208+
fireEvent.keyDown(screen.getByRole('combobox'), { key: 'ArrowDown' });
209+
const listbox = await screen.findByRole('listbox');
210+
return within(listbox).getAllByRole('option').map((option) => option.textContent);
211+
};
212+
213+
it('history shown: all four options, Field Changes among them', async () => {
214+
render(panel(true));
215+
expect(await options()).toEqual(['All Activity', 'Comments Only', 'Field Changes', 'Tasks Only']);
216+
});
217+
218+
it('history not shown (history off, or a reader whose audit read did not answer): no `changes_only`', async () => {
219+
render(panel(false));
220+
expect(await options()).toEqual(['All Activity', 'Comments Only', 'Tasks Only']);
221+
});
222+
223+
it('CONTROL: no host saying, every option draws, as before', async () => {
224+
render(panel(undefined));
225+
expect(await options()).toEqual(['All Activity', 'Comments Only', 'Field Changes', 'Tasks Only']);
226+
});
227+
228+
it('a `changes_only` the dropdown does not offer reads as 全部: every entry draws', () => {
229+
render(panel(false, 'changes_only'));
230+
expect(screen.getByRole('combobox').textContent).toContain('All Activity');
231+
expect(screen.getByText('Logged a call')).toBeTruthy();
232+
expect(screen.getByText('Budget is set')).toBeTruthy();
233+
});
234+
235+
it('CONTROL: with history shown, the same `changes_only` holds the field change only', () => {
236+
render(panel(true, 'changes_only'));
237+
expect(screen.getByText('Status')).toBeTruthy();
238+
expect(screen.queryByText('Logged a call')).toBeNull();
239+
expect(screen.queryByText('Budget is set')).toBeNull();
240+
});
241+
});
242+
197243
describe('an activity row sits under 活动 whatever the history flag; 变更 holds the audit only (objectstack#30074, ruling C)', () => {
198244
// The five activity types that share the `field_change` presentation.
199245
const events = (['created', 'updated', 'deleted', 'assigned', 'shared'] as const).map(

0 commit comments

Comments
 (0)