mirror of
https://github.com/Heretek-AI/opencode.git
synced 2026-11-25 02:35:10 -10:00
test(app): embed timeline settings playground
This commit is contained in:
1 parent
713a49bf75
commit
2b4e52f5df
2 files changed
+53
-9
No files matched your search
@@ -1,5 +1,23 @@
|
||||
import { expect, story } from "../../storybook/playwright/story"
|
||||
|
||||
story("updates the timeline from the production slider and advanced settings", async ({ mount }) => {
|
||||
const component = await mount("app-real-timeline--preset-explorer")
|
||||
const slider = component.getByRole("slider", { name: "Timeline detail" })
|
||||
|
||||
await expect(slider).toHaveAttribute("aria-valuetext", "Compact")
|
||||
await expect(component.getByText(/^Used 10 /)).toBeVisible()
|
||||
await slider.press("End")
|
||||
await expect(slider).toHaveAttribute("aria-valuetext", "Everything")
|
||||
await expect(component.getByText(/^Used 10 /)).toHaveCount(0)
|
||||
|
||||
await component.getByRole("button", { name: "Advanced", exact: true }).click()
|
||||
const shellGrouped = component.getByRole("switch", { name: "Shell grouped", exact: true })
|
||||
await expect(shellGrouped).not.toBeChecked()
|
||||
await shellGrouped.press("Space")
|
||||
await expect(slider).toHaveAttribute("aria-valuetext", "Custom")
|
||||
await expect(component.getByText(/^Used /)).toHaveCount(2)
|
||||
})
|
||||
|
||||
story("renders a representative session with the desktop compact preset", async ({ mount }) => {
|
||||
const component = await mount("app-real-timeline--representative-compact")
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { timelinePresets, type TimelineDetail } from "@opencode/session-ui/timeline/detail"
|
||||
import { Show } from "solid-js"
|
||||
import { createStore } from "solid-js/store"
|
||||
import { SettingsList } from "@/settings/list"
|
||||
import { TimelineDetailControl } from "@/settings/timeline-detail"
|
||||
import { SessionPreview } from "./story-model"
|
||||
import {
|
||||
realTimelineCoverageDocument,
|
||||
@@ -7,6 +11,7 @@ import {
|
||||
realTimelinePresentation,
|
||||
realTimelineVerboseDocument,
|
||||
} from "./real-timeline-fixtures"
|
||||
import "@/settings/settings.css"
|
||||
|
||||
const description = "anonymized seven-day session shape · lorem ipsum content"
|
||||
const presets = Object.fromEntries(timelinePresets.map((preset) => [preset.id, preset.value])) as Record<
|
||||
@@ -27,6 +32,35 @@ function Representative(props: { preset: string }) {
|
||||
)
|
||||
}
|
||||
|
||||
function TimelineSettingsPlayground() {
|
||||
const [state, setState] = createStore({ value: structuredClone(timelinePresets[2].value) as TimelineDetail })
|
||||
|
||||
return (
|
||||
<div class="flex h-screen min-h-[640px] w-full flex-col bg-background-base lg:flex-row">
|
||||
<aside class="max-h-[46vh] w-full shrink-0 overflow-y-auto border-b border-border-weak-base bg-background-stronger p-4 lg:max-h-none lg:w-[420px] lg:border-b-0 lg:border-r">
|
||||
<SettingsList>
|
||||
<div class="py-5">
|
||||
<TimelineDetailControl value={state.value} onChange={(value) => setState("value", value)} />
|
||||
</div>
|
||||
</SettingsList>
|
||||
</aside>
|
||||
<section class="min-h-0 min-w-0 flex-1">
|
||||
<Show when={state.value} keyed>
|
||||
{(timelineDetail) => (
|
||||
<SessionPreview
|
||||
title="Real Timeline · settings playground"
|
||||
description={description}
|
||||
document={realTimelineDocument}
|
||||
presentation={realTimelinePresentation}
|
||||
timelineDetail={timelineDetail}
|
||||
/>
|
||||
)}
|
||||
</Show>
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default {
|
||||
title: "OpenCode/Session/Real Timeline",
|
||||
id: "app-real-timeline",
|
||||
@@ -43,15 +77,7 @@ export default {
|
||||
}
|
||||
|
||||
export const PresetExplorer = {
|
||||
args: { preset: "compact" },
|
||||
argTypes: {
|
||||
preset: {
|
||||
control: "select",
|
||||
options: timelinePresets.map((preset) => preset.id),
|
||||
description: "Production desktop timeline detail preset",
|
||||
},
|
||||
},
|
||||
render: (args: { preset: string }) => <Representative preset={args.preset} />,
|
||||
render: () => <TimelineSettingsPlayground />,
|
||||
}
|
||||
|
||||
export const RepresentativeCompact = {
|
||||
|
||||
Reference in new issue
Block a user