Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ components with the app's production styles, translations, and a fresh Pinia
store per story. No Electron app, bootstrap Python, account, or ComfyUI
installation is needed to run them.

Choose **Screens → Create a New Instance** to explore the setup screen with
sample Electron API responses: Public Builds, sample Managed Builds after a
simulated sign-in, target switching, a retried failed request, and empty and
error states. File and install actions are simulated.

The **Storybook** CI job builds a static Storybook from the commit it checks out
and links it as a downloadable `storybook-<commit>` artifact in the job summary.
On a pull request that commit is GitHub's test merge of the PR, which includes
Expand Down
3 changes: 2 additions & 1 deletion TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ and a per-spec inventory, see [`e2e/README.md`](e2e/README.md).
Where they live:

- Unit: `src/**/*.test.ts` (excluding `*.integration.test.ts`)
- Storybook: `stories/**/*.stories.ts` (each story's play function is a test)
- Storybook: `stories/**/*.stories.ts` (each story's play function is a test;
the setup screen's sample preload responses live in `stories/desktopApi.ts`)
- Integration: `src/**/*.integration.test.ts`
- E2E + Lifecycle: `e2e/*.test.ts`, selected by tag in the test title
(`@windows @macos @linux` vs `@lifecycle`), mapped to Playwright projects in
Expand Down
146 changes: 146 additions & 0 deletions stories/InstallWizard.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { expect, screen, userEvent, waitFor } from 'storybook/test'
import InstallWizardPreview from './InstallWizardPreview.vue'
import {
createDesktopApi,
desktopApiParameters,
withDesktopApi,
type InstallScenario
} from './desktopApi'

const meta = {
title: 'Screens/Create a New Instance',
component: InstallWizardPreview,
tags: ['autodocs'],
parameters: {
...desktopApiParameters,
desktopScenario: 'publicBuilds' satisfies InstallScenario,
docs: {
description: {
component:
'Explore the actual Desktop setup screen without launching Electron, signing in, or downloading ComfyUI. Public Builds are the standard ComfyUI environments. Managed Builds are setups published to a platform workspace. Sample Windows/NVIDIA responses stand in for the preload API; they do not test real hardware compatibility. File, browser and install actions are simulated.'
}
}
},
decorators: [withDesktopApi(({ parameters }) => createDesktopApi(parameters.desktopScenario))]
} satisfies Meta<typeof InstallWizardPreview>

export default meta
type Story = StoryObj<typeof meta>

// The real takeover and its alerts teleport outside canvasElement, so plays query `screen`.

export const PublicBuilds: Story = {
play: async () => {
await waitFor(() =>
expect(screen.getByRole('heading', { name: 'Create a New Instance' })).toBeVisible()
)
await waitFor(() => expect(screen.getByRole('button', { name: 'Continue' })).toBeEnabled())
await expect(screen.getByRole('radio', { name: 'Public Builds' })).toHaveAttribute(
'aria-checked',
'true'
)
}
}

export const ManagedBuilds: Story = {
parameters: { desktopScenario: 'managedBuilds' satisfies InstallScenario },
play: async () => {
await waitFor(() =>
expect(screen.getByTestId('workspace-build-field')).toHaveTextContent('Studio Image Build')
)
await expect(screen.getByRole('radio', { name: 'Managed Builds' })).toHaveAttribute(
'aria-checked',
'true'
)
await expect(screen.queryByText('Build for another platform')).not.toBeInTheDocument()
await expect(screen.getByText('Windows - NVIDIA (CUDA 13.0)')).toBeInTheDocument()
}
}

export const ManagedInstallRequested: Story = {
parameters: { desktopScenario: 'managedBuilds' satisfies InstallScenario },
play: async () => {
await waitFor(() =>
expect(screen.getByTestId('workspace-build-field')).toHaveTextContent('Studio Image Build')
)
const install = screen.getByRole('button', { name: 'Continue' })
await waitFor(() => expect(install).toBeEnabled())
await userEvent.click(install)
await expect(
await screen.findByText(/Simulated installation requested for preview-install/)
).toBeVisible()
await expect(window.api.comfybuilder.installBuild).toHaveBeenCalledOnce()
await expect(window.api.comfybuilder.installBuild).toHaveBeenCalledWith({
buildId: 'studio-image',
artifactId: 'windows-nvidia',
releaseVersion: 3,
installRoot: 'C:\\ComfyUI-Installs'
})
}
}

export const SignInToManagedBuilds: Story = {
play: async () => {
await waitFor(() => expect(screen.getByRole('button', { name: 'Continue' })).toBeEnabled())
await userEvent.click(await screen.findByRole('radio', { name: 'Managed Builds' }))
await waitFor(() =>
expect(screen.getByTestId('workspace-build-field')).toHaveTextContent('Studio Image Build')
)
await expect(window.api.comfybuilder.signIn).toHaveBeenCalledOnce()
}
}

export const NoCompatibleBuilds: Story = {
parameters: { desktopScenario: 'noCompatibleBuilds' satisfies InstallScenario },
play: async () => {
// The real screen defaults to Public Builds when the workspace has no
// compatible release. Select Managed Builds to inspect its empty state.
await waitFor(() => expect(screen.getByRole('button', { name: 'Continue' })).toBeEnabled())
await userEvent.click(screen.getByRole('radio', { name: 'Managed Builds' }))
await waitFor(() =>
expect(screen.getByText('No compatible Builds are available to install.')).toBeVisible()
)
await expect(screen.getByRole('button', { name: 'Continue' })).toBeDisabled()
}
}

export const BuildLoadError: Story = {
parameters: { desktopScenario: 'buildLoadError' satisfies InstallScenario },
play: async () => {
await waitFor(() =>
expect(screen.getByRole('button', { name: "Couldn't load builds. Retry" })).toBeVisible()
)
}
}

export const InstallError: Story = {
parameters: { desktopScenario: 'installError' satisfies InstallScenario },
play: async () => {
const install = await screen.findByRole('button', { name: 'Continue' })
await waitFor(() => expect(install).toBeEnabled())
await userEvent.click(install)
await waitFor(() =>
expect(screen.getByText('This build is not compatible with this machine.')).toBeVisible()
)
await expect(window.api.comfybuilder.installBuild).toHaveBeenCalledOnce()
await expect(screen.queryByText(/Simulated installation requested/)).not.toBeInTheDocument()
}
}

export const LowDiskSpace: Story = {
parameters: { desktopScenario: 'lowDiskSpace' satisfies InstallScenario },
play: async () => {
const next = await screen.findByRole('button', { name: 'Continue' })
await waitFor(() => expect(next).toBeEnabled())
await userEvent.click(next)
await userEvent.click(await screen.findByRole('radio', { name: /Starter Image Workflow/ }))
// Continue restarts the wizard's 300 ms disk check; the alert shows once it has settled.
await expect(await screen.findByRole('alert', {}, { timeout: 10_000 })).toHaveTextContent(
/only 11 GB free/
)
const install = screen.getByRole('button', { name: 'Install' })
await expect(install).toHaveAttribute('aria-disabled', 'true')
await expect(install).toHaveAttribute('aria-describedby', 'tps-alerts')
}
}
42 changes: 42 additions & 0 deletions stories/InstallWizardPreview.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import InstallWizardModal from '../src/renderer/src/views/InstallWizardModal.vue'
import ModalDialog from '../src/renderer/src/components/ModalDialog.vue'
import type { ShowProgressOpts } from '../src/types/ipc'

const wizard = ref<InstanceType<typeof InstallWizardModal>>()
const visible = ref(true)
const message = ref('')

onMounted(() => {
void wizard.value?.open()
})

// The production host swaps the wizard for its progress takeover here.
function showProgress(opts: ShowProgressOpts): void {
message.value = `Simulated installation requested for ${opts.installationId}. No files were written.`
visible.value = false
}
</script>

<template>
<InstallWizardModal
v-if="visible"
ref="wizard"
@close="visible = false"
@navigate-list="visible = false"
@show-progress="showProgress"
/>
<ModalDialog />
<div v-if="!visible" class="preview-result">
<p role="status">
{{ message || 'Setup closed. Use the Storybook toolbar to remount this example.' }}
</p>
</div>
</template>

<style scoped>
.preview-result {
padding: 32px;
}
</style>
46 changes: 46 additions & 0 deletions stories/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,33 @@ page explains it and embeds isolated examples.
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Components → BaseSelect | Open the select, move with the arrow keys (disabled options are skipped), pick with Enter, or close with Escape or a click outside. |

### Create a New Instance

Under **Screens → Create a New Instance**, choose an example. Remounting resets
its sample data.

| Example | What to try |
| ------------------------- | ----------------------------------------------------------------------------------------- |
| Public Builds | Change release/hardware, continue to the starter workflow picker. |
| Managed Builds | Inspect a sample workspace build and switch its installation target. |
| Managed Install Requested | See the simulated handoff after Continue requests a Managed Build install. |
| Sign In To Managed Builds | See the result of simulated sign-in; remount Public Builds to perform the click yourself. |
| No Compatible Builds | Inspect the empty picker and disabled installation button. |
| Build Load Error | Click Retry to recover the sample failed request. |
| Install Error | Inspect the alert after the sample installation request is rejected. |
| Low Disk Space | Inspect the blocked starter workflow, then pick a smaller one or None to proceed. |

**Public Builds** are the standard ComfyUI environments. **Managed Builds** are
packaged setups published to a Comfy platform workspace. The **wizard** is this
Create a New Instance screen.

The examples use a sample Windows/NVIDIA machine. Compatibility states are
predefined API responses, not the output of the real main-process compatibility
check. These stories cannot establish whether Python, PyTorch, or a GPU works on
a machine. Browser, folder, and install actions stay inside the preview; no files
are written and no external authentication is started. Public/remote submission
shows a preview-only alert. Managed submission displays a simulated handoff.

## Add a story

- Put `*.stories.ts` files under `stories/` and import the actual renderer
Expand All @@ -27,6 +54,25 @@ page explains it and embeds isolated examples.
- Stories run without Electron, so `window.api` does not exist. A component that
calls the preload API needs a sample implementation, checked against the
production IPC types, installed for each mount and released when it unmounts.
- The setup screen's sample responses live in `desktopApi.ts`. Implement every
preload method the screen calls. A missing method is `undefined`, and product
code that feature-detects optional methods or catches preload errors silently
takes its fallback path.
- Use its `withDesktopApi` decorator and spread `desktopApiParameters` into the
meta's parameters instead of writing your own. The decorator component installs
a fresh fixture and resets shared modal state in its setup. On unmount it
resets the modal and retires the fixture, including nested namespaces such as
`comfybuilder`. The fixture's methods then never settle, including through
references a store kept (the auth store keeps `comfybuilder`), so the
unmounted screen's late async work stops instead of throwing or continuing
against a fixture no example shows. Calls it makes through `window.api` only
after the next example has mounted reach that example's fixture. Retiring
also clears the fixture's spies, which Storybook keeps for the page's
lifetime, so their recorded calls do not keep the old fixture alive.
Storybook re-runs `beforeEach` on toolbar and args changes without
remounting, which would swap the fixture under the mounted screen.
`desktopApiParameters` sets `test.restoreMocks: false` so those rerenders do not clear the fresh spies'
call history.
- Query `screen` (the document body) for popovers, takeover screens and alerts,
which teleport outside the story canvas. Use condition-based assertions
instead of sleeps.
Expand Down
Loading
Loading