Skip to content

Commit 618349a

Browse files
committed
test(record-page): the record-tabs e2e reads the pinned details instead of the retired rail
Claude-Session: https://claude.ai/code/session_01L6bhgUZTwDqtEFzNFCVTri Co-authored-by: Claude <noreply@anthropic.com>
1 parent fbe6e33 commit 618349a

1 file changed

Lines changed: 102 additions & 92 deletions

File tree

‎ui/e2e/record-tabs-rail-35595.spec.ts‎

Lines changed: 102 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,24 @@ import { uiRoot } from '../scripts/ui-root.mjs';
1010

1111
/**
1212
* GEOMETRY and INTERACTION pin for objectstack#35595 (the record page's tab
13-
* row) and objectstack#35596 (the 概览 tab's right rail), zh-CN.
13+
* row) and objectstack#35890 (the pinned details; the 概览 right rail of
14+
* objectstack#35596 is retired), zh-CN.
1415
*
1516
* - The tab row folds by WIDTH only: a row sized from its own measured
1617
* tabs to hold the first eight draws exactly those and folds the tail
1718
* into 「更多 N ▾」, whose items keep their counts; CONTROL, the same page
1819
* at the 1184 px a 1440 window leaves draws every tab.
19-
* - On 概览 the stage path and the key fields are at the top across the
20-
* whole width — both columns; CONTROL, the details column beside the rail
21-
* is narrower than they are. Since objectstack#35891 the default page
22-
* draws no strip, so the fixture places one in the `highlights` slot, as
23-
* an authored page does.
24-
* - The rail is the 概览 tab's: another tab open draws no rail and no
25-
* strip; CONTROL, back on 概览 both are drawn again.
26-
* - A rail card's title opens its tab; CONTROL, the 概览 tab returns.
27-
* - A card measures radius 8, a 13 px title with a grey count, 26 px rows.
20+
* - Not a full page (the drawer): one column. The stage path and the key
21+
* fields sit at the top of 「详情」 across the details' width, and no
22+
* page draws a rail. Since objectstack#35891 the default page draws no
23+
* strip, so the fixture places one in the `highlights` slot, as an
24+
* authored page does.
25+
* - The strip is 「详情」's: another tab open draws no strip; CONTROL, back
26+
* on 「详情」 it is drawn again.
27+
* - objectstack#35890: a full page wide enough pins the details 400 px on
28+
* the left and draws the other tabs beside them, opening on the first
29+
* list; dragging the separator widens the details and never leaves the
30+
* tabs less than 400 px.
2831
* - objectstack#35783: an open list's tab is its menu — 「左移」 / 「右移」
2932
* move it, 「隐藏」 sends it to 「更多」 — and 「更多」's 「恢复默认顺序」
3033
* brings the default back. Order only: no width is read.
@@ -36,8 +39,7 @@ import { uiRoot } from '../scripts/ui-root.mjs';
3639
*
3740
* ## What is real here and what is a fixture
3841
*
39-
* REAL: plugin-detail's `RecordPageColumns`, `RecordTabRow` and
40-
* `RecordSummaryRail`, the page synthesizer (`buildDefaultPageSchema` →
42+
* REAL: plugin-detail's `RecordPageColumns` and `RecordTabRow`, the page synthesizer (`buildDefaultPageSchema` →
4143
* `buildDefaultPageColumns`), the related-count store and the zh-Hans pack
4244
* through `I18nProvider`, bundled by Vite from their source files and mounted
4345
* in Chromium with React's client renderer; the stylesheet is real Tailwind,
@@ -58,7 +60,8 @@ import { uiRoot } from '../scripts/ui-root.mjs';
5860
* fold, a width computed from what the row measures its own tabs at
5961
* (below); 1184 px (a 1440 window with the sidebar open) for its
6062
* CONTROL; and 1024 px (a 1280 × 800 window with the sidebar open) for
61-
* the 概览 placement and the rail.
63+
* the 「详情」 placement and the pinned layout. The host is the drawer's
64+
* (`fullPage` off) unless the case says `fullPage`.
6265
* - Fonts are whatever the machine has, and the fold does not depend on
6366
* them. A CJK label is about 13 px a glyph where a CJK font is installed
6467
* and about 8 px where none is (measured: 概览 26 px against 16 px), so
@@ -99,6 +102,8 @@ interface Case {
99102
name: string;
100103
viewport: number;
101104
frame: number;
105+
/** objectstack#35890 — the full record page, which pins its details when it fits. */
106+
fullPage?: boolean;
102107
}
103108

104109
const ENTRY = '\0record-tabs-rail:entry';
@@ -219,6 +224,7 @@ function Host() {
219224
const [open, setOpen] = React.useState(undefined);
220225
return h(RecordPageColumns, {
221226
tier: recordPageTierFor(c.frame),
227+
fullPage: !!c.fullPage,
222228
columns,
223229
enlargedRelated: open,
224230
onEnlargeRelated: setOpen,
@@ -330,11 +336,8 @@ const face = (page: Page) =>
330336
page.evaluate(() => {
331337
const tabs = [...document.querySelectorAll('[role="tab"]')].map((el) => el.textContent).join('|');
332338
const more = document.querySelector('[data-record-tab-more]')?.textContent ?? '';
333-
const cards = [...document.querySelectorAll('[data-record-summary-card]')]
334-
.filter((el) => !(el as HTMLElement).hidden)
335-
.map((el) => el.textContent)
336-
.join('|');
337-
return `${tabs}#${more}#${cards}`;
339+
const columns = document.querySelector('[data-record-columns]')?.getAttribute('style') ?? '';
340+
return `${tabs}#${more}#${columns}`;
338341
});
339342

340343
async function settle(page: Page, compiled: Set<string>): Promise<void> {
@@ -348,7 +351,7 @@ async function settle(page: Page, compiled: Set<string>): Promise<void> {
348351
await styleUntilStable(page, compiled);
349352
}
350353

351-
/** Mount the case, style it, and wait until the row and the rail hold still. */
354+
/** Mount the case, style it, and wait until the row and the columns hold still. */
352355
async function mount(page: Page, c: Case): Promise<Set<string>> {
353356
await page.setViewportSize({ width: c.viewport, height: 800 });
354357
await page.setContent('<!doctype html><html lang="zh-CN"><head><style>html,body{margin:0}</style></head><body><div id="root"></div></body></html>');
@@ -403,7 +406,7 @@ const readRow = (page: Page): Promise<RowReading> =>
403406
};
404407
});
405408

406-
/** Every tab the page offers, in order: 概览, the eight lists, 附件, 审批, 动态. */
409+
/** Every tab the page offers, in order: 详情, the eight lists, 附件, 审批, 动态. */
407410
const ALL_TABS = [
408411
'overview',
409412
'contact.account_id',
@@ -432,7 +435,7 @@ const box = (page: Page, selector: string) =>
432435
return { left: Math.round(r.left), right: Math.round(r.right), top: Math.round(r.top), width: Math.round(r.width) };
433436
}, selector);
434437

435-
test.describe('the record page\'s tabs and 概览 rail, zh-CN (objectstack#35595, objectstack#35596)', () => {
438+
test.describe('the record page\'s tabs and pinned details, zh-CN (objectstack#35595, objectstack#35890)', () => {
436439
test.skip(({ browserName }) => browserName !== 'chromium', 'one engine is enough for a layout pin');
437440

438441
test.beforeAll(async () => {
@@ -480,11 +483,13 @@ test.describe('the record page\'s tabs and 概览 rail, zh-CN (objectstack#35595
480483
);
481484
report(testInfo, 'fold-menu', menu);
482485
expect(menu.map((m) => m.id)).toEqual(ALL_TABS.slice(r.shown.length));
483-
// The folded lists keep their numbers; 审批 its dot; 动态 its size.
486+
// The folded lists keep their numbers; 审批 its dot. (动态's number is
487+
// the host's stream count, which this fixture has no discussion for:
488+
// `RecordDetailView.timelineCount-28737` pins it on the real host.)
484489
const byId = Object.fromEntries(menu.map((m) => [m.id, m]));
485490
expect(byId['task.what_id']?.count).toBe('6');
486491
expect(byId['approvals']?.dot).toBe(true);
487-
expect(byId['timeline']?.count).toBe('4');
492+
expect(byId['timeline']).toBeTruthy();
488493
});
489494

490495
test('CONTROL: the same page at 1184 px draws every tab, the empty ones muted, and no 「更多」', async ({ page }, testInfo) => {
@@ -504,99 +509,104 @@ test.describe('the record page\'s tabs and 概览 rail, zh-CN (objectstack#35595
504509
expect(await page.locator('[data-record-tab="case.account_id"] [data-record-tab-count]').count()).toBe(0);
505510
});
506511

507-
test('1280 × 800: on 概览 the stage path and the key fields span both columns, above them', async ({ page }, testInfo) => {
512+
test('not a full page, 1024 px: one column, the strip at the top of 「详情」 across the details, and no rail', async ({ page }, testInfo) => {
508513
test.setTimeout(120_000);
509514
await mount(page, { name: 'overview1280', viewport: 1280, frame: PAGE_1280 });
510515
const strip = await box(page, '[data-record-overview-strip]');
511516
const details = await box(page, '[data-record-column="details"]');
512-
const rail = await box(page, '[data-record-column="right"]');
513517
const row = await box(page, '[data-record-tab-row]');
514-
report(testInfo, 'overview1280', { strip, details, rail, row });
515-
expect(strip && details && rail && row).toBeTruthy();
516-
// Across the whole width: from the details' left edge to the rail's right edge.
518+
const rail = await page.evaluate(() => ({
519+
right: document.querySelectorAll('[data-record-column="right"]').length,
520+
cards: document.querySelectorAll('[data-record-summary-card]').length,
521+
pinned: document.querySelectorAll('[data-record-page-pinned]').length,
522+
shown: document.querySelector('[data-record-columns]')?.getAttribute('data-record-columns-shown') ?? null,
523+
}));
524+
report(testInfo, 'overview1280', { strip, details, row, rail });
525+
expect(strip && details && row).toBeTruthy();
526+
expect(rail).toEqual({ right: 0, cards: 0, pinned: 0, shown: 'details' });
527+
// Across the details' width, below the tab row.
517528
expect(Math.abs(strip!.left - details!.left)).toBeLessThanOrEqual(1);
518-
expect(Math.abs(strip!.right - rail!.right)).toBeLessThanOrEqual(1);
519-
// Below the tab row, above both columns.
529+
expect(Math.abs(strip!.right - details!.right)).toBeLessThanOrEqual(1);
520530
expect(strip!.top).toBeGreaterThanOrEqual(row!.top);
521-
expect(details!.top).toBeGreaterThan(strip!.top);
522-
expect(rail!.top).toBeGreaterThan(strip!.top);
523-
// CONTROL: the details column beside the rail is narrower than the strip.
524-
expect(details!.width).toBeLessThan(strip!.width - 200);
531+
await expect(page.locator('[data-record-tab="overview"]')).toHaveAttribute('aria-selected', 'true');
532+
await expect(page.locator('[data-record-tab="overview"]')).toContainText('详情');
525533
});
526534

527-
test('the rail and the strip are 概览\'s: another tab draws neither; CONTROL, 概览 brings both back', async ({ page }, testInfo) => {
535+
test('the strip is 「详情」\'s: another tab draws none; CONTROL, 「详情」 brings it back', async ({ page }, testInfo) => {
528536
test.setTimeout(120_000);
529537
const compiled = await mount(page, { name: 'otherTab1280', viewport: 1280, frame: PAGE_1280 });
530-
// CONTROL first: on 概览 both are drawn.
531-
await expect(page.locator('[data-record-column="right"]')).toHaveCount(1);
538+
// CONTROL first: on 「详情」 the strip is drawn.
532539
await expect(page.locator('[data-record-overview-strip]')).toHaveCount(1);
533540
await page.locator('[data-record-tab="contact.account_id"]').click();
534541
await expect(page.locator('[data-record-tab="contact.account_id"]')).toHaveAttribute('aria-selected', 'true');
535542
await settle(page, compiled);
536543
const opened = await page.evaluate(() => ({
537-
rail: document.querySelectorAll('[data-record-column="right"]').length,
538-
cards: document.querySelectorAll('[data-record-summary-card]').length,
539544
strip: document.querySelectorAll('[data-record-overview-strip], [data-node="record:highlights"], [data-node="record:path"]').length,
540545
face: document.querySelector('[data-related-enlarged]')?.getAttribute('data-related-enlarged') ?? null,
541546
}));
542547
report(testInfo, 'otherTab1280', opened);
543-
expect(opened).toEqual({ rail: 0, cards: 0, strip: 0, face: 'contact.account_id' });
548+
expect(opened).toEqual({ strip: 0, face: 'contact.account_id' });
544549
await page.locator('[data-record-tab="overview"]').click();
545-
await expect(page.locator('[data-record-column="right"]')).toHaveCount(1);
546550
await expect(page.locator('[data-record-overview-strip]')).toHaveCount(1);
547551
});
548552

549-
test('a rail card\'s title opens its tab; the rail reads 审批, 附件, 最近动态, 其他相关, sized 8 / 13 / 26', async ({ page }, testInfo) => {
553+
test('a full page at 1024 px pins the details 400 px left, the tabs beside them on the first list; the separator drags, the tabs keep 400 px (objectstack#35890)', async ({ page }, testInfo) => {
550554
test.setTimeout(120_000);
551-
await mount(page, { name: 'railClick1280', viewport: 1280, frame: PAGE_1280 });
552-
const rail = await page.evaluate(() => {
553-
const cards = [...document.querySelectorAll<HTMLElement>('[data-record-summary-card]')].filter((el) => !el.hidden);
554-
const first = cards[0];
555-
const title = first.querySelector<HTMLElement>('[data-record-summary-card-title]')!;
556-
const row = document.querySelector<HTMLElement>('[data-record-summary-row]')!;
557-
const count = document.querySelector<HTMLElement>('[data-record-summary-card-count]')!;
558-
return {
559-
order: cards.map((el) => el.getAttribute('data-record-summary-card')),
560-
rows: cards.map((el) => el.querySelectorAll('[data-record-summary-row]').length),
561-
radius: getComputedStyle(first).borderTopLeftRadius,
562-
titleSize: getComputedStyle(title).fontSize,
563-
rowHeight: Math.round(row.getBoundingClientRect().height),
564-
countColor: getComputedStyle(count).color,
565-
titleColor: getComputedStyle(title).color,
566-
other: document.querySelector('[data-record-summary-other]')?.textContent ?? null,
567-
emptyLine: /还有\s*\d+\s*个空关联/.test(document.body.textContent ?? ''),
568-
};
569-
});
570-
report(testInfo, 'railClick1280', rail);
571-
// 审批, 附件, 最近动态, then 其他相关: the six lists with records, in their order.
572-
expect(rail.order).toEqual([
573-
'approvals',
574-
'attachments',
575-
'timeline',
576-
'contact.account_id',
577-
'opportunity.account_id',
578-
'contract.account_id',
579-
'quote.account_id',
580-
'campaign_member.account_id',
581-
'task.what_id',
582-
]);
583-
expect(Math.max(...rail.rows)).toBeLessThanOrEqual(3);
584-
expect(rail.radius).toBe('8px');
585-
expect(rail.titleSize).toBe('13px');
586-
expect(rail.rowHeight).toBe(26);
587-
expect(rail.countColor).not.toBe(rail.titleColor);
588-
expect(rail.other).toBe('其他相关');
589-
expect(rail.emptyLine).toBe(false);
590-
// The whole title opens the tab.
591-
await page.locator('[data-record-summary-card="quote.account_id"] [data-record-summary-card-title]').click();
592-
await expect(page.locator('[data-record-tab="quote.account_id"]')).toHaveAttribute('aria-selected', 'true');
593-
await expect(page.locator('[data-related-enlarged="quote.account_id"]')).toHaveCount(1);
594-
// CONTROL: 概览 returns, and the rail with it.
595-
await page.locator('[data-record-tab="overview"]').click();
596-
await expect(page.locator('[data-record-tab="overview"]')).toHaveAttribute('aria-selected', 'true');
597-
await expect(page.locator('[data-record-summary-card="quote.account_id"]')).toHaveCount(1);
598-
await page.locator('[data-record-summary-card="approvals"] [data-record-summary-card-title]').click();
599-
await expect(page.locator('[data-record-tab="approvals"]')).toHaveAttribute('aria-selected', 'true');
555+
const compiled = await mount(page, { name: 'pinned1280', viewport: 1280, frame: PAGE_1280, fullPage: true });
556+
const read = () =>
557+
page.evaluate(() => {
558+
const r = (sel: string) => {
559+
const el = document.querySelector(sel);
560+
if (!el) return null;
561+
const b = el.getBoundingClientRect();
562+
return { left: Math.round(b.left), right: Math.round(b.right), top: Math.round(b.top), width: Math.round(b.width) };
563+
};
564+
return {
565+
pinned: !!document.querySelector('[data-record-page-pinned]'),
566+
shown: document.querySelector('[data-record-columns]')?.getAttribute('data-record-columns-shown') ?? null,
567+
details: r('[data-record-column="details"]'),
568+
handle: r('[data-record-details-resize]'),
569+
tabs: r('[data-record-column="tabs"]'),
570+
row: r('[data-record-tab-row]'),
571+
tabIds: [...document.querySelectorAll('[data-record-tab-row] [role="tab"]')].map((el) => el.getAttribute('data-record-tab')),
572+
active: document.querySelector('[data-record-tab-row] [aria-selected="true"]')?.getAttribute('data-record-tab') ?? null,
573+
face: document.querySelector('[data-record-column="tabs"] [data-related-enlarged]')?.getAttribute('data-related-enlarged') ?? null,
574+
strip: document.querySelector('[data-record-column="details"] [data-record-overview-strip]') ? 'in details' : null,
575+
rail: document.querySelectorAll('[data-record-summary-card], [data-record-column="right"]').length,
576+
};
577+
});
578+
const at = await read();
579+
report(testInfo, 'pinned1280', at);
580+
expect(at.pinned).toBe(true);
581+
expect(at.shown).toBe('details tabs');
582+
expect(at.rail).toBe(0);
583+
expect(at.details!.width).toBe(400);
584+
expect(at.handle!.width).toBe(24);
585+
expect(at.handle!.left).toBe(at.details!.right);
586+
expect(at.tabs!.left).toBe(at.handle!.right);
587+
// The tab row is the right column's; 「详情」 is the left column, so it has no tab.
588+
expect(at.row!.left).toBeGreaterThanOrEqual(at.tabs!.left);
589+
expect(at.tabIds).not.toContain('overview');
590+
expect(at.active).toBe('contact.account_id');
591+
expect(at.face).toBe('contact.account_id');
592+
expect(at.strip).toBe('in details');
593+
// Drag the separator 300 px right: the details widen until the tabs have 400 px left.
594+
const h = at.handle!;
595+
await page.mouse.move(h.left + h.width / 2, h.top + 40);
596+
await page.mouse.down();
597+
await page.mouse.move(h.left + h.width / 2 + 150, h.top + 40, { steps: 5 });
598+
await page.mouse.move(h.left + h.width / 2 + 300, h.top + 40, { steps: 5 });
599+
await page.mouse.up();
600+
await settle(page, compiled);
601+
const dragged = await read();
602+
report(testInfo, 'pinned1280-dragged', dragged);
603+
expect(dragged.details!.width).toBeGreaterThan(400);
604+
expect(dragged.tabs!.width).toBe(400);
605+
expect(dragged.details!.width + 24 + 400).toBe(at.details!.width + 24 + at.tabs!.width);
606+
// CONTROL: another tab opens in the right column, the details stay.
607+
await page.locator('[data-record-tab="quote.account_id"]').click();
608+
await expect(page.locator('[data-record-column="tabs"] [data-related-enlarged="quote.account_id"]')).toHaveCount(1);
609+
await expect(page.locator('[data-record-column="details"]')).toHaveCount(1);
600610
});
601611
});
602612

@@ -635,7 +645,7 @@ test.describe('a related tab\'s menu moves and hides it, and 「更多」 restor
635645
expect(moved.slice(0, 2)).toEqual(['opportunity.account_id', 'contact.account_id']);
636646
await arrange(page, 'contact.account_id', '左移');
637647
expect(await listTabs(page)).toEqual(lists);
638-
// CONTROL: 概览 opens no menu.
648+
// CONTROL: 「详情」 opens no menu.
639649
await page.locator('[role="tab"][data-record-tab="overview"]').click();
640650
await page.locator('[role="tab"][data-record-tab="overview"]').click();
641651
await expect(page.locator('[data-record-tab-arrange-menu]')).toHaveCount(0);

0 commit comments

Comments
 (0)