Skip to content

Commit c84f795

Browse files
fix(app-shell): home launcher links and buttons meet the 44 px touch target below sm (#29220)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbTfG58JQWNcS6YFBCzbm7jh)_ Fixes #29147 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:手机宽度(640 px 以下)时,Console 首页的链接和按钮都放大到 44 px 触控尺寸:「从模板开始」「New in Studio」等构建按钮与 AI 按钮、「浏览应用市场」「Setup」、「打开收件箱」、两个「查看全部」、我的工作与最近访问的每一行、待发布草稿的「发布」、「查看全部动态」、「收起」。640 px 以上外观不变。 - **为什么改**:首页是登录后的第一屏。实测 375/390 px 下这些入口只有 16 到 32 px 高,低于 44 px,手机上容易点不中或点错(#29075 的审计发现,#29040 系列)。 - **风险与回滚**:低。只在 `@object-ui/app-shell` 首页三个文件加 `max-sm:` 类名,没有新属性、新键或逻辑改动;1280 px 实测尺寸与 main 相同。「Your apps」条带也被 `app:launcher` 区块复用,它在手机上同样变成 44 px。回滚即 revert 本 PR。 - **先看**:① `ui/packages/app-shell/src/console/home/HomeRail.tsx` 的行与「查看全部」;② `HomePage.tsx` 的 `BuilderChip` 与 `HomeAiActions`;③ `HomeAppsStrip.tsx` 的 `HEADER_LINK_CLASSES`。 - **两分钟验证**:`pnpm dev:showcase`,浏览器调到 390 px 宽打开首页:「Setup」「Open inbox」「View all」和每一行都是约 44 px 高;调回桌面宽度,与改动前一样。 - **需要你做的**:无,席位落地。 ## What changes At phone width the Console home launcher's links and buttons were 16 to 32 px tall. Below `sm` (640 px) each now meets the 44 px touch target, through phone-only `max-sm:` classes, the token form the #29040 children use. From `sm` up the classes are unchanged. - `HomePage.tsx`: the builder chips ("Start with a template", "Build an app", "New in Studio") and the AI buttons ("Build with AI", "Ask AI"), in the greeting row and in the empty state, take `max-sm:h-11`. - `HomeAppsStrip.tsx`: the heading links ("Browse App Marketplace", "Setup") take `max-sm:min-h-11` through `HEADER_LINK_CLASSES`; "Show less" takes `max-sm:min-h-11 max-sm:min-w-11`. The app tiles were already 112 by 128 px. - `HomeRail.tsx`: "Open inbox" and both columns' "View all" take `max-sm:min-h-11 max-sm:min-w-11` (a short label such as "View all" was 42 px wide), and the column header grows to `max-sm:h-11` to hold it. A My-work row's button takes `max-sm:min-h-11` and its list item `max-sm:h-auto`, so the item's 1 px divider sits outside the 44 px button. Recent rows take `max-sm:h-11`; "Publish" in the pending-drafts row takes `max-sm:h-11` in a `max-sm:h-14` row; "View all activity" takes `max-sm:min-h-11`. - Two `data-testid`s are added so the test can name the targets: `apps-show-less` and `home-activity-view-all`. - No prop, export, i18n key or metadata changes. `HomeLayout.tsx` and the app bar (#29075) are not touched. ## Run record Production Console builds served at `/_console` by `pnpm dev:crm` and `pnpm dev:showcase` with `--fresh`: "before" built from main 87d6bae, "after" from the branch at 7a325f0. Chromium with `isMobile` and touch, DPR 2, signed in as the seeded admin. Every visible interactive element on `/home` outside the app bar is measured, scrolled into view or not. | Run | Targets | Under 44 px, before | Under 44 px, after | |---|---|---|---| | crm 375×812 | 12 | 10 | 0 | | crm 390×844 | 12 | 10 | 0 | | showcase 375×812 | 15 | 13 | 0 | | showcase 390×844 | 15 | 13 | 0 | Per target on showcase: before at 390, after at 390, after at 1280 (desktop equals before, so desktop is unchanged). | Target | Before 390 | After 390 | After 1280 | |---|---|---|---| | Start with a template | 170×32 | 170×44 | 170×32 | | New in Studio | 128×32 | 128×44 | 128×32 | | Browse App Marketplace | 159×16 | 159×44 | 159×16 | | Setup | 52×16 | 52×44 | 52×16 | | Open inbox | 63×16 | 63×44 | 63×16 | | Approvals View all | 42×16 | 44×44 | 42×16 | | Approval row | 356×39 | 356×44 | 552×39 | | Notifications View all | 42×16 | 44×44 | 42×16 | | Notification row | 356×39 | 356×44 | 552×39 | | Recent row | 356×40 | 356×44 | 734×40 | | View all activity | 101×16 | 101×44 | 101×16 | Not measured live: "Build an app", "Build with AI", "Ask AI" (row and empty state), "Publish" and "Show less". The `--fresh` backends deploy no AI agent, no unpublished draft and fewer than 20 apps. The test below pins their classes. Screenshots and the script are in the project folder `issue-29147/`. ## Tests - New `HomePage.phoneTapTargets-29147.test.tsx` (11 tests, the real `HomePage` with the strip and rail it renders): each target carries its phone class beside its unchanged desktop class. happy-dom computes no media query, so the class is the pin; the run record above is the browser measurement. - Reverse verification: the three source files restored to main 87d6bae with the test kept: 11 of 11 red. Restored to HEAD, `git diff HEAD` empty. - Run from `ui/` under `scripts/pm/os-verify-lock.sh`, `--maxWorkers=2`, at merged head 4a492f6 (after the app-shell dependency closure rebuild): the 54 test files that name `HomePage`, `HomeAppsStrip`, `HomeRail` or its exports, the new file included: exit 0, 54 files, 665 tests. - `pnpm exec eslint` on the four changed source and test files: no errors; the warnings are the files' existing `any` and hook warnings, none on a changed line. ## Acceptance notes - Claim 6572880616 (file surface: `HomePage.tsx`, `HomeRail.tsx`, `HomeAppsStrip.tsx`, their tests, a root changeset). The diff stays inside it. - `HomeAppsStrip` also renders the `app:launcher` block (`views/app-launcher-renderer.tsx`, `console/blocks/productBlocks.tsx`), so those launchers take the same phone sizes. - The pending-drafts row now stands 56 px tall below `sm` so its 44 px "Publish" fits; at `sm` and up it stays 40 px. ## Verification - `node scripts/pm/dispatch-gates.mjs --ran`: 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN; every recorded exit is 0, at 7a325f0. `pnpm --dir ui exec vitest run scripts/`: 169 files passed, 2 skipped. The merge of main brought no change to the three home files or the test. - `node ui/scripts/check-new-cross-file-line-citations.mjs`: 0 new citations. - `pnpm exec turbo run type-check --filter=@object-ui/app-shell --concurrency=2` at 7a325f0: exit 0, 65 of 65 tasks. - `node scripts/check-sdui-manifest.mjs`: exit 0. - `node scripts/check-changeset-no-major.mjs --base origin/main`, `node scripts/check-adr-0087-registration.mjs --base origin/main`, `node scripts/check-closing-keyword-parity.mjs` and `node scripts/check-partof-closing-keyword.mjs`, with this body as the event: exit 0 each. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. (CI runs the repo lint) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (not touched) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. --- _Generated by [Claude Code](https://claude.ai/code/session_01QsR2jV3Ev5TwvWnbh8j8k7)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 22d0710 commit c84f795

5 files changed

Lines changed: 278 additions & 17 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): below `sm`, every Console home launcher link and button meets the 44 px touch target
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
At phone width the home page's links and buttons were 16 to 32 px tall: the builder chips and AI buttons in the greeting row, the "Your apps" heading links and "Show less", "Open inbox", both "View all" links, the My-work and recent rows, the pending-drafts "Publish" button and "View all activity". Each now takes 44 px below `sm` (`max-sm:` classes), and a short text link is also at least 44 px wide. From `sm` up nothing changes. The strip's classes also reach the `app:launcher` block, which renders the same component.

‎ui/packages/app-shell/src/console/home/HomeAppsStrip.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ import { BRANDED_TILE_CLASSES, appTileColors, appTileStyle } from '../../layout/
5151

5252
const COMPACT_LIMIT = 19;
5353

54-
/** The 12 px links at the heading's right. */
54+
/** The 12 px links at the heading's right; 44 px tall below `sm`, the touch target. */
5555
const HEADER_LINK_CLASSES =
56-
'inline-flex items-center gap-1.5 rounded-sm text-xs transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
56+
'inline-flex items-center gap-1.5 rounded-sm text-xs transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring max-sm:min-h-11';
5757

5858
/**
5959
* One app's 56 px icon square, drawn from the app's branding (see the module
@@ -300,7 +300,8 @@ export function HomeAppsStrip({
300300
<button
301301
type="button"
302302
onClick={() => setShowAll(false)}
303-
className="mt-2.5 text-xs text-primary hover:underline"
303+
className="mt-2.5 text-xs text-primary hover:underline max-sm:min-h-11 max-sm:min-w-11"
304+
data-testid="apps-show-less"
304305
>
305306
{t('home.showLess', { defaultValue: 'Show less' })}
306307
</button>

‎ui/packages/app-shell/src/console/home/HomePage.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function BuilderChip({
150150
onClick={disabled ? undefined : onClick}
151151
data-testid={testId}
152152
className={cn(
153-
'inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg px-3 text-[13px] font-medium transition-colors',
153+
'inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg px-3 text-[13px] font-medium transition-colors max-sm:h-11',
154154
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
155155
'disabled:pointer-events-none disabled:opacity-60',
156156
tone === 'outline'
@@ -222,8 +222,9 @@ function HomeAiActions({
222222
layout === 'stack'
223223
? 'mt-6 flex flex-col sm:flex-row items-center gap-3'
224224
: 'flex shrink-0 items-center gap-2';
225-
// In the greeting row the buttons take the builder chips' 32 px height.
226-
const buttonClass = layout === 'stack' ? undefined : 'h-8 px-3 text-[13px]';
225+
// In the greeting row the buttons take the builder chips' 32 px height;
226+
// below `sm` both layouts take the 44 px touch target.
227+
const buttonClass = layout === 'stack' ? 'max-sm:h-11' : 'h-8 px-3 text-[13px] max-sm:h-11';
227228
return (
228229
<div className={container}>
229230
{showBuild && (

‎ui/packages/app-shell/src/console/home/HomeRail.tsx‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ function CountPill({ count, primary, testId }: { count: number; primary?: boolea
4848
}
4949

5050
/**
51-
* One 40 px row of a My-work column: a 24 px icon tile, the one-line title
52-
* with an ellipsis, and a 12 px muted time at the right.
51+
* One 40 px row of a My-work column (44 px below `sm`, the touch target): a
52+
* 24 px icon tile, the one-line title with an ellipsis, and a 12 px muted time
53+
* at the right.
5354
*/
5455
function WorkRow({
5556
icon: Icon,
@@ -67,12 +68,12 @@ function WorkRow({
6768
testId?: string;
6869
}) {
6970
return (
70-
<li className="h-10 border-t">
71+
<li className="h-10 border-t max-sm:h-auto">
7172
<button
7273
type="button"
7374
onClick={onClick}
7475
data-testid={testId}
75-
className="flex h-full w-full items-center gap-2.5 px-3 text-left text-[13px] transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none"
76+
className="flex h-full w-full items-center gap-2.5 px-3 text-left text-[13px] transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none max-sm:min-h-11"
7677
>
7778
<span className={cn('inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md', tileClass)}>
7879
<Icon className="h-3.5 w-3.5" />
@@ -178,7 +179,7 @@ function WorkColumn({
178179
}) {
179180
return (
180181
<section className="min-w-0 overflow-hidden rounded-lg border bg-card" data-testid={testId}>
181-
<div className="flex h-10 items-center justify-between gap-2 px-3">
182+
<div className="flex h-10 items-center justify-between gap-2 px-3 max-sm:h-11">
182183
<h3 className="inline-flex min-w-0 items-center gap-2 text-[13px] font-semibold">
183184
<span className="truncate">{title}</span>
184185
{count > 0 && <CountPill count={count} primary={primaryPill} testId={`${testId}-count`} />}
@@ -187,7 +188,7 @@ function WorkColumn({
187188
type="button"
188189
onClick={onViewAll}
189190
data-testid={`${testId}-view-all`}
190-
className="shrink-0 text-xs text-primary hover:underline focus-visible:underline focus-visible:outline-none"
191+
className="shrink-0 text-xs text-primary hover:underline focus-visible:underline focus-visible:outline-none max-sm:min-h-11 max-sm:min-w-11"
191192
>
192193
{t('home.myWork.viewAll', { defaultValue: 'View all' })}
193194
</button>
@@ -236,7 +237,7 @@ export function HomePendingDraftsRow({
236237
: t('home.pendingDrafts.waiting', { names: joined, defaultValue: '{{names}} waiting to publish' });
237238
return (
238239
<div
239-
className="flex h-10 items-center gap-2.5 rounded-lg border border-primary/35 bg-primary/5 px-3 dark:bg-primary/10"
240+
className="flex h-10 items-center gap-2.5 rounded-lg border border-primary/35 bg-primary/5 px-3 dark:bg-primary/10 max-sm:h-14"
240241
data-testid="home-pending-drafts"
241242
>
242243
<Rocket className="h-4 w-4 shrink-0 text-primary" aria-hidden />
@@ -248,7 +249,7 @@ export function HomePendingDraftsRow({
248249
</p>
249250
<Button
250251
size="sm"
251-
className="h-7 shrink-0 px-3 text-xs"
252+
className="h-7 shrink-0 px-3 text-xs max-sm:h-11"
252253
onClick={onPublish}
253254
disabled={publishing}
254255
data-testid="pending-drafts-publish"
@@ -360,7 +361,7 @@ export function HomeActionCenter({
360361
type="button"
361362
onClick={onOpenInbox}
362363
data-testid="home-my-work-open-inbox"
363-
className="text-xs text-primary hover:underline focus-visible:underline focus-visible:outline-none"
364+
className="text-xs text-primary hover:underline focus-visible:underline focus-visible:outline-none max-sm:min-h-11 max-sm:min-w-11"
364365
>
365366
{t('home.myWork.openInbox', { defaultValue: 'Open inbox' })}
366367
</button>
@@ -533,7 +534,7 @@ export function HomeContinue({
533534
onClick={() => onOpen(it.href)}
534535
data-testid="home-recent-row"
535536
data-recent-type={it.type}
536-
className="flex h-10 w-full items-center gap-2.5 px-3 text-left text-[13px] transition-colors hover:bg-muted/60"
537+
className="flex h-10 w-full items-center gap-2.5 px-3 text-left text-[13px] transition-colors hover:bg-muted/60 max-sm:h-11"
537538
>
538539
<span
539540
className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground"
@@ -637,7 +638,8 @@ export function HomeActivity({ activity, onViewAll, t }: { activity: ActivityFee
637638
<button
638639
type="button"
639640
onClick={onViewAll}
640-
className="mt-1.5 inline-flex items-center gap-1 text-xs text-primary hover:underline"
641+
className="mt-1.5 inline-flex items-center gap-1 text-xs text-primary hover:underline max-sm:min-h-11"
642+
data-testid="home-activity-view-all"
641643
>
642644
{t('layout.activityFeed.viewAll', { defaultValue: 'View all activity' })}
643645
<ArrowRight className="h-3 w-3" />
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#29147 — below `sm`, every Home launcher link and button meets the
5+
* 44 px touch target; at `sm` and up each keeps its desktop size.
6+
*
7+
* What these cases pin, on the real `HomePage` and the real strip and rail it
8+
* renders: each target carries its phone class (`max-sm:h-11`, or
9+
* `max-sm:min-h-11` where the target has no fixed height) beside its unchanged
10+
* desktop class. A narrow text link also carries `max-sm:min-w-11`, so a short
11+
* label ("View all") is never a target narrower than 44 px.
12+
*
13+
* happy-dom computes no Tailwind media query, so the pin is the class; that the
14+
* classes reach 44 px in a browser is the PR's 375 / 390 px measurement.
15+
*
16+
* `t` echoes the key, so a hardcoded string fails here.
17+
*/
18+
19+
import '@testing-library/jest-dom/vitest';
20+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
21+
import React from 'react';
22+
import { render, screen, cleanup, within } from '@testing-library/react';
23+
import userEvent from '@testing-library/user-event';
24+
25+
const navigateMock = vi.fn();
26+
27+
const state = vi.hoisted(() => ({
28+
apps: [] as Array<Record<string, unknown>>,
29+
/** The catalog's answer, once it has answered. */
30+
agents: [] as Array<{ name: string }>,
31+
askAgent: false,
32+
buildAgent: false,
33+
}));
34+
35+
vi.mock('react-router-dom', async () => {
36+
const { createElement } = await import('react');
37+
return {
38+
useNavigate: () => navigateMock,
39+
Link: ({ to, ...rest }: { to: string } & Record<string, unknown>) =>
40+
createElement('a', { ...rest, href: to }),
41+
};
42+
});
43+
44+
vi.mock('@object-ui/i18n', async (importOriginal) => ({
45+
...(await importOriginal<Record<string, unknown>>()),
46+
useObjectTranslation: () => ({ t: (key: string) => `«${key}»`, language: 'en' }),
47+
useObjectLabel: () => {
48+
const label = (x: { name?: string; label?: string }) => String(x?.label || x?.name || '');
49+
return {
50+
appLabel: label,
51+
objectLabel: label,
52+
objectPluralLabel: label,
53+
dashboardLabel: label,
54+
pageLabel: label,
55+
reportLabel: label,
56+
viewLabel: (_object: string, _view: string, fallback?: string) => fallback ?? '',
57+
};
58+
},
59+
}));
60+
61+
vi.mock('@object-ui/auth', async (importOriginal) => ({
62+
...(await importOriginal<Record<string, unknown>>()),
63+
useAuth: () => ({ user: { id: 'u1', name: 'Dev Admin', email: 'dev.admin@example.com' } }),
64+
useWorkspaceAdminStatus: () => ({ isAdmin: true, isResolved: true }),
65+
}));
66+
67+
// The catalog moves the way the real `useAgents` does: an empty first frame,
68+
// then loading, then the answer.
69+
vi.mock('@object-ui/plugin-chatbot/core', async (importOriginal) => {
70+
const { useEffect, useState } = await import('react');
71+
return {
72+
...(await importOriginal<typeof import('@object-ui/plugin-chatbot/core')>()),
73+
useAgents: () => {
74+
const [phase, setPhase] = useState<'idle' | 'loading' | 'answered'>('idle');
75+
useEffect(() => {
76+
if (phase === 'idle') setPhase('loading');
77+
else if (phase === 'loading') setPhase('answered');
78+
}, [phase]);
79+
return { agents: phase === 'answered' ? state.agents : [], isLoading: phase === 'loading' };
80+
},
81+
isAskAgent: () => state.askAgent,
82+
agentHasCapability: () => state.buildAgent,
83+
};
84+
});
85+
86+
vi.mock('../../../providers/MetadataProvider', () => ({
87+
useMetadata: () => ({ apps: state.apps, objects: [], dashboards: [], pages: [], reports: [], loading: false }),
88+
}));
89+
vi.mock('../../../context/NavigationContext', () => ({
90+
useNavigationContext: () => ({ currentAppName: 'crm' }),
91+
}));
92+
vi.mock('../../../hooks/useCanAuthorMetadata', () => ({
93+
useCanAuthorMetadata: () => true,
94+
useCanReadPendingDrafts: () => true,
95+
}));
96+
vi.mock('../../../runtime-config', () => ({
97+
getRuntimeConfig: () => ({ branding: { productName: 'ObjectStack' } }),
98+
isMarketplaceEnabled: () => true,
99+
isAiStudioEnabled: () => true,
100+
}));
101+
102+
const now = new Date().toISOString();
103+
vi.mock('../../../hooks/useHomeInbox', () => ({
104+
useHomeInbox: () => ({
105+
pendingApprovals: [{ id: 'apr_1', processLabel: 'Discount approval', recordTitle: 'QUO-0007', createdAt: now }],
106+
pendingApprovalsCount: 1,
107+
pendingApprovalsStatus: 'ready',
108+
pendingApprovalsReadable: true,
109+
notifications: [{ id: 'n1', title: 'Lead assigned', createdAt: now }],
110+
unreadTopicCount: 1,
111+
notificationsStatus: 'ready',
112+
notificationsReadable: true,
113+
activity: {
114+
value: [{ id: 'a1', user: 'Ada', description: 'updated a lead', timestamp: now, objectName: 'crm_lead' }],
115+
status: 'ready',
116+
readable: true,
117+
},
118+
}),
119+
}));
120+
vi.mock('../../../hooks/useRecentItems', () => ({
121+
useRecentItems: () => ({
122+
recentItems: [{ id: 'object:crm_lead', type: 'object', name: 'crm_lead', href: '/apps/crm/crm_lead', visitedAt: now }],
123+
}),
124+
}));
125+
vi.mock('../../../hooks/useFavorites', () => ({ useFavorites: () => ({ favorites: [] }) }));
126+
vi.mock('../../../hooks/useAiSurface', () => ({ resolveAiApiBase: () => '' }));
127+
vi.mock('../../../preview/usePendingDrafts', () => ({
128+
usePendingDrafts: () => ({ count: 1, entries: [{ name: 'crm_lead', label: 'Lead' }] }),
129+
}));
130+
vi.mock('../../../preview/usePublishAllDrafts', () => ({
131+
usePublishAllDrafts: () => ({ publishAll: async () => ({ ok: true }), publishing: false }),
132+
}));
133+
vi.mock('../../../hooks/useInboxBell', () => ({ useInboxBell: () => ({ markRead: vi.fn() }) }));
134+
vi.mock('../../../layout/ActivityObjectLabel', () => ({ ActivityObjectLabel: () => null }));
135+
136+
import { HomePage } from '../HomePage';
137+
138+
/** Enough apps that the strip folds the rest behind "More". */
139+
const MANY_APPS = [
140+
{ name: 'setup', label: 'Setup', icon: 'Settings' },
141+
...Array.from({ length: 21 }, (_, i) => ({ name: `app_${i}`, label: `App ${i}`, icon: 'Box' })),
142+
];
143+
144+
/** Asserts a target keeps its desktop class and takes its phone class. */
145+
function expectPhoneTarget(el: HTMLElement, desktop: string[], phone: string[]) {
146+
const classes = el.className.split(/\s+/);
147+
for (const c of desktop) expect(classes, `${el.dataset.testid}: desktop class ${c}`).toContain(c);
148+
for (const c of phone) expect(classes, `${el.dataset.testid}: phone class ${c}`).toContain(c);
149+
}
150+
151+
beforeEach(() => {
152+
navigateMock.mockReset();
153+
state.apps = MANY_APPS;
154+
state.agents = [];
155+
state.askAgent = false;
156+
state.buildAgent = false;
157+
});
158+
159+
afterEach(() => {
160+
cleanup();
161+
});
162+
163+
describe('the greeting row (objectstack#29147)', () => {
164+
it('the builder chips are 44 px below sm and 32 px from sm', async () => {
165+
render(<HomePage />);
166+
expectPhoneTarget(await screen.findByTestId('home-build-in-studio'), ['h-8'], ['max-sm:h-11']);
167+
expectPhoneTarget(screen.getByTestId('home-start-template'), ['h-8'], ['max-sm:h-11']);
168+
});
169+
170+
it('"Build an app" and "Build with AI" are 44 px below sm and 32 px from sm', async () => {
171+
state.agents = [{ name: 'builder' }];
172+
state.buildAgent = true;
173+
render(<HomePage />);
174+
expectPhoneTarget(await screen.findByTestId('home-build-app'), ['h-8'], ['max-sm:h-11']);
175+
expectPhoneTarget(screen.getByTestId('home-build-with-ai'), ['h-8'], ['max-sm:h-11']);
176+
});
177+
178+
it('"Ask AI" is 44 px below sm and 32 px from sm', async () => {
179+
state.agents = [{ name: 'ask' }];
180+
state.askAgent = true;
181+
render(<HomePage />);
182+
expectPhoneTarget(await screen.findByTestId('home-ask-ai'), ['h-8'], ['max-sm:h-11']);
183+
});
184+
185+
it('with no app yet, the empty state\'s "Ask AI" is 44 px below sm', async () => {
186+
state.apps = [];
187+
state.agents = [{ name: 'ask' }];
188+
state.askAgent = true;
189+
render(<HomePage />);
190+
expectPhoneTarget(await screen.findByTestId('home-ask-ai'), ['h-10'], ['max-sm:h-11']);
191+
});
192+
});
193+
194+
describe('"Your apps" (objectstack#29147)', () => {
195+
it('the heading\'s links are 44 px tall below sm', () => {
196+
render(<HomePage />);
197+
expectPhoneTarget(screen.getByTestId('browse-marketplace-btn'), ['inline-flex', 'items-center'], ['max-sm:min-h-11']);
198+
expectPhoneTarget(screen.getByTestId('home-system-settings-link'), ['inline-flex', 'items-center'], ['max-sm:min-h-11']);
199+
});
200+
201+
it('"Show less" is a 44 px target below sm', async () => {
202+
render(<HomePage />);
203+
await userEvent.setup().click(screen.getByTestId('apps-show-all'));
204+
expectPhoneTarget(screen.getByTestId('apps-show-less'), ['text-xs'], ['max-sm:min-h-11', 'max-sm:min-w-11']);
205+
});
206+
});
207+
208+
describe('"My work" (objectstack#29147)', () => {
209+
it('"Open inbox" and both "View all" links are 44 px targets below sm', () => {
210+
render(<HomePage />);
211+
for (const id of ['home-my-work-open-inbox', 'home-my-work-approvals-view-all', 'home-my-work-notifications-view-all']) {
212+
expectPhoneTarget(screen.getByTestId(id), ['text-xs'], ['max-sm:min-h-11', 'max-sm:min-w-11']);
213+
}
214+
// The column header grows with its link, so the link is not clipped.
215+
const header = screen.getByTestId('home-my-work-approvals-view-all').parentElement as HTMLElement;
216+
expectPhoneTarget(header, ['h-10'], ['max-sm:h-11']);
217+
});
218+
219+
it('a row is 44 px below sm, its 1 px divider outside the button', () => {
220+
render(<HomePage />);
221+
for (const id of ['home-my-work-approval-row', 'home-my-work-notification-row']) {
222+
const row = screen.getByTestId(id);
223+
expectPhoneTarget(row, ['h-full'], ['max-sm:min-h-11']);
224+
// A fixed 44 px item would leave the button 43 px under its border-top.
225+
expectPhoneTarget(row.parentElement as HTMLElement, ['h-10', 'border-t'], ['max-sm:h-auto']);
226+
}
227+
});
228+
229+
it('the pending-drafts row\'s "Publish" is 44 px below sm, in a row tall enough to hold it', () => {
230+
render(<HomePage />);
231+
expectPhoneTarget(screen.getByTestId('pending-drafts-publish'), ['h-7'], ['max-sm:h-11']);
232+
expectPhoneTarget(screen.getByTestId('home-pending-drafts'), ['h-10'], ['max-sm:h-14']);
233+
});
234+
});
235+
236+
describe('"Recently accessed" and the activity feed (objectstack#29147)', () => {
237+
it('a recent row is 44 px below sm', () => {
238+
render(<HomePage />);
239+
const [row] = within(screen.getByTestId('home-recent')).getAllByTestId('home-recent-row');
240+
expectPhoneTarget(row, ['h-10'], ['max-sm:h-11']);
241+
});
242+
243+
it('"View all activity" is 44 px tall below sm', () => {
244+
render(<HomePage />);
245+
expectPhoneTarget(screen.getByTestId('home-activity-view-all'), ['inline-flex', 'items-center'], ['max-sm:min-h-11']);
246+
});
247+
});

0 commit comments

Comments
 (0)