feat: refine mobile dashboard experience
This commit is contained in:
1 parent
46898cd0ea
commit
c1da19c9b2
68 files changed
+1418
-1306
No files matched your search
@@ -1,6 +1,10 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { resolveMobileItemPresentation } from "./mobile-presentation";
|
||||
import {
|
||||
isMobileContextActionVisible,
|
||||
resolveMobileItemPresentation,
|
||||
shouldRenderMobileWidgetActions,
|
||||
} from "./mobile-presentation";
|
||||
|
||||
describe("resolveMobileItemPresentation", () => {
|
||||
test("renders apps as eager compact tiles", () => {
|
||||
@@ -9,19 +13,51 @@ describe("resolveMobileItemPresentation", () => {
|
||||
height: 1,
|
||||
eager: true,
|
||||
supportsDetails: false,
|
||||
unmountWhenOffscreen: false,
|
||||
});
|
||||
});
|
||||
|
||||
test("defaults widgets to full width and clamps desktop height", () => {
|
||||
test("defaults widgets to full width without inventing a detail view", () => {
|
||||
expect(resolveMobileItemPresentation({ kind: "calendar", height: 8 }, undefined)).toMatchObject({
|
||||
width: 2,
|
||||
height: 3,
|
||||
eager: false,
|
||||
supportsDetails: false,
|
||||
unmountWhenOffscreen: false,
|
||||
});
|
||||
});
|
||||
|
||||
test("enables details only when the widget explicitly supports them", () => {
|
||||
expect(
|
||||
resolveMobileItemPresentation(
|
||||
{ kind: "calendar", height: 2 },
|
||||
{
|
||||
width: 2,
|
||||
height: 1,
|
||||
supportsDetailView: true,
|
||||
},
|
||||
),
|
||||
).toMatchObject({
|
||||
supportsDetails: true,
|
||||
});
|
||||
});
|
||||
|
||||
test("prefers explicit presentation metadata", () => {
|
||||
test("keeps automatic footprint defaults when only details are configured", () => {
|
||||
expect(
|
||||
resolveMobileItemPresentation(
|
||||
{ kind: "calendar", height: 7 },
|
||||
{
|
||||
supportsDetailView: true,
|
||||
},
|
||||
),
|
||||
).toMatchObject({
|
||||
width: 2,
|
||||
height: 3,
|
||||
supportsDetails: true,
|
||||
});
|
||||
});
|
||||
|
||||
test("prefers explicit presentation metadata while eager mounting takes precedence", () => {
|
||||
expect(
|
||||
resolveMobileItemPresentation(
|
||||
{ kind: "clock", height: 3 },
|
||||
@@ -31,6 +67,7 @@ describe("resolveMobileItemPresentation", () => {
|
||||
supportsCompactSummary: true,
|
||||
supportsDetailView: false,
|
||||
eager: true,
|
||||
unmountWhenOffscreen: true,
|
||||
},
|
||||
),
|
||||
).toEqual({
|
||||
@@ -39,6 +76,37 @@ describe("resolveMobileItemPresentation", () => {
|
||||
displayMode: "mobileSummary",
|
||||
supportsDetails: false,
|
||||
eager: true,
|
||||
unmountWhenOffscreen: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldRenderMobileWidgetActions", () => {
|
||||
test("does not render an action trigger without an explicit capability", () => {
|
||||
expect(
|
||||
shouldRenderMobileWidgetActions({
|
||||
supportsDetails: false,
|
||||
supportsRefresh: false,
|
||||
visibleContextActionCount: 0,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
test.each([
|
||||
{ supportsDetails: true, supportsRefresh: false, visibleContextActionCount: 0 },
|
||||
{ supportsDetails: false, supportsRefresh: true, visibleContextActionCount: 0 },
|
||||
{ supportsDetails: false, supportsRefresh: false, visibleContextActionCount: 1 },
|
||||
])("renders an action trigger for an explicit capability", (capabilities) => {
|
||||
expect(shouldRenderMobileWidgetActions(capabilities)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isMobileContextActionVisible", () => {
|
||||
test("requires actions to opt into the read-only mobile surface", () => {
|
||||
const action = { key: "configure", label: "Configure", onClick: () => undefined };
|
||||
|
||||
expect(isMobileContextActionVisible(action)).toBe(false);
|
||||
expect(isMobileContextActionVisible({ ...action, mobileVisible: true })).toBe(true);
|
||||
expect(isMobileContextActionVisible({ ...action, mobileVisible: true, hidden: true })).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user