Skip to content
Closed
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
49 changes: 49 additions & 0 deletions browser_tests/assets/onboarding/first_run_tour_contract.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"last_node_id": 27,
"last_link_id": 0,
"nodes": [
{
"id": 27,
"type": "CLIPTextEncode",
"pos": [80, 120],
"size": [425, 180],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [{ "name": "clip", "type": "CLIP", "link": null }],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"links": null,
"slot_index": 0
}
],
"properties": { "Node name for S&R": "CLIPTextEncode" },
"widgets_values": ["A bright landscape"]
},
{
"id": 9,
"type": "SaveImage",
"pos": [700, 120],
"size": [315, 100],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [{ "name": "images", "type": "IMAGE", "link": null }],
"outputs": [],
"properties": { "Node name for S&R": "SaveImage" },
"widgets_values": ["ComfyUI"]
}
],
"links": [],
"groups": [],
"config": {},
"extra": {
"ds": {
"offset": [0, 0],
"scale": 1
}
},
"version": 0.4
}
24 changes: 24 additions & 0 deletions browser_tests/fixtures/components/FirstRunNudge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { Locator, Page } from '@playwright/test'

import { FIRST_RUN_SUGGESTIONS } from '@/renderer/extensions/firstRunTour/nudge/firstRunNudgeSuggestions'
import type { FirstRunSuggestionId } from '@/renderer/extensions/firstRunTour/nudge/firstRunNudgeSuggestions'

const ACTION_TEST_IDS = new RegExp(
`^first-run-nudge-(${FIRST_RUN_SUGGESTIONS.map(({ id }) => id).join('|')})$`
)

/** Post-first-run discovery card (FirstRunTourNudge.vue). */
export class FirstRunNudge {
public readonly root: Locator
/** The continuation actions only — the browse-all button is not one. */
public readonly actions: Locator

constructor(page: Page) {
this.root = page.getByTestId('first-run-nudge')
this.actions = this.root.getByTestId(ACTION_TEST_IDS)
}

action(id: FirstRunSuggestionId): Locator {
return this.root.getByTestId(`first-run-nudge-${id}`)
}
}
33 changes: 31 additions & 2 deletions browser_tests/fixtures/components/Tour.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from '@playwright/test'
import type { Locator, Page } from '@playwright/test'

import { TOUR_SEEN_SETTING } from '@/platform/onboarding/onboardingTours'
Expand All @@ -14,7 +15,7 @@ export class OnboardingCoachmarks {
public readonly landing: Locator
public readonly landingStartButton: Locator
public readonly landingSkipButton: Locator
/** The current spotlight step card (the dialog carrying a "Step N of M" label). */
/** The current spotlight card, including non-step result states. */
public readonly spotlight: Locator
public readonly card: Locator
public readonly cardNextButton: Locator
Expand All @@ -30,7 +31,7 @@ export class OnboardingCoachmarks {
exact: true
})
this.spotlight = page.getByTestId('coach-spotlight')
this.card = page.getByRole('dialog').filter({ hasText: /Step \d+ of \d+/ })
this.card = page.getByTestId('coach-card')
this.cardNextButton = this.card.getByRole('button', { name: 'Next' })
this.cardDoneButton = this.card.getByRole('button', { name: 'Done' })
}
Expand All @@ -45,6 +46,34 @@ export class OnboardingCoachmarks {
return this.card.filter({ hasText: new RegExp(`Step ${step} of `) })
}

/** How many steps the card says the tour has, once it says anything. */
async stepCount(): Promise<number> {
await expect(this.card).toContainText(/Step \d+ of \d+/)
const label = await this.card.textContent()
return Number(/Step \d+ of (\d+)/.exec(label ?? '')?.[1])
}

/**
* Steps forward until the card parks on the step carrying `title`, whatever
* the sequence is, and reports how many steps the tour said it had.
*/
async walkToStep(title: string): Promise<number> {
const target = this.card.getByText(title)
const totalSteps = await this.stepCount()

for (let step = 1; step < totalSteps; step++) {
await expect(this.card).toContainText(`Step ${step} of ${totalSteps}`)
if (await target.isVisible()) break
await this.cardNextButton.click()
}

await expect(
target,
`the tour ran out of steps before reaching "${title}"`
).toBeVisible()
return totalSteps
}

/**
* Clears the pre-seeded seen-flag (so dismissal assertions observe it being
* set again) and clicks the tour's replay button, which must be mounted.
Expand Down
13 changes: 12 additions & 1 deletion browser_tests/fixtures/data/assetFixtures.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { Asset } from '@comfyorg/ingest-types'

import type { AssetItem } from '@/platform/assets/schemas/assetSchema'
import type {
AssetItem,
AssetResponse
} from '@/platform/assets/schemas/assetSchema'

/**
* Core-native asset shape: the ingest Asset plus the `loader_path` contract
Expand Down Expand Up @@ -59,6 +62,14 @@ function createOutputAsset(
...overrides
}
}

/** A backend serving nothing, for specs that only need the call not to escape. */
export const EMPTY_ASSET_RESPONSE: AssetResponse = {
assets: [],
total: 0,
has_more: false
}

export const STABLE_CHECKPOINT: Asset = createModelAsset({
id: 'test-checkpoint-001',
name: 'sd_xl_base_1.0.safetensors',
Expand Down
18 changes: 18 additions & 0 deletions browser_tests/fixtures/data/cloudWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ export const LEGACY_PERSONAL_BILLING_STATUS = {
team_credit_stop: null
} satisfies IngestBillingStatusResponse

/** A funded, subscribed personal workspace, so `canRunWorkflows` holds. */
export const ACTIVE_PERSONAL_BILLING_STATUS = {
is_active: true,
max_seats: 1,
occupied_seats: 1,
team_credit_stop: null,
subscription_tier: 'PRO',
subscription_duration: 'MONTHLY',
renewal_date: '2099-01-01',
has_funds: true
} satisfies IngestBillingStatusResponse

/** Remote config for a subscription-gated install with the first-run tour on. */
export const ONBOARDING_TOUR_REMOTE_CONFIG = {
onboarding_tour_enabled: true,
subscription_required: true
} satisfies RemoteConfig

export const EMPTY_BILLING_BALANCE = {
amount_micros: 0,
currency: 'usd',
Expand Down
66 changes: 66 additions & 0 deletions browser_tests/fixtures/data/firstRunTour.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import type { PromptResponse } from '@comfyorg/ingest-types'

import { FIRST_RUN_SUGGESTIONS } from '@/renderer/extensions/firstRunTour/nudge/firstRunNudgeSuggestions'
import type { SupportedTemplateId } from '@/renderer/extensions/firstRunTour/roles/tourRolePins'

import type { TemplateMediaInfo } from '@/platform/workflow/templates/types/template'
import type { ResultItem } from '@/schemas/apiSchema'

import { makeTemplate } from '@e2e/fixtures/data/templateFixtures'

/**
* The template both first-run suites tour. Typed against the pin table so
* dropping it from `TOUR_ROLE_PINS` fails to compile rather than leaving the
* suites waiting on a tour that can no longer resolve any roles.
*/
export const FIRST_RUN_START_TEMPLATE_ID: SupportedTemplateId =
'image_z_image_turbo'

export const FIRST_RUN_JOB_ID = 'post-first-run-continuation'

/** A prompt the queue accepts, so a walk does not depend on the backend's models. */
export function queuedPrompt(jobId: string) {
return {
prompt_id: jobId,
number: 1,
node_errors: {}
} satisfies PromptResponse
}

/**
* The image input each continuation declares, pointing at the node the
* `widgets/load_image_widget` asset carries so the seeded value is readable
* off the loaded graph.
*/
export const CONTINUATION_INPUT = {
nodeId: 10,
nodeType: 'LoadImage',
file: 'example.png',
mediaType: 'image'
} satisfies TemplateMediaInfo

/**
* Every continuation carries the `io` metadata the card's dead-end filter
* demands, so an action missing from the card means the handoff broke rather
* than the fixture being thin.
*/
export const FIRST_RUN_TEMPLATES = [
makeTemplate({
name: FIRST_RUN_START_TEMPLATE_ID,
title: 'Z-Image Turbo'
}),
...FIRST_RUN_SUGGESTIONS.map(({ templateId }) =>
makeTemplate({
name: templateId,
io: { inputs: [CONTINUATION_INPUT] }
})
)
]

export const FIRST_RUN_OUTPUT = {
filename: 'first-run-output.webp',
subfolder: '',
type: 'output'
} satisfies ResultItem

export const FIRST_RUN_OUTPUT_WIDGET_VALUE = 'first-run-output.webp [output]'
93 changes: 93 additions & 0 deletions browser_tests/fixtures/helpers/PostFirstRunHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { expect } from '@playwright/test'

import enMessages from '@/locales/en/main.json' with { type: 'json' }

import { TOUR_ROLE_PINS } from '@/renderer/extensions/firstRunTour/roles/tourRolePins'

import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
import type { OnboardingCoachmarks } from '@e2e/fixtures/components/Tour'
import {
CONTINUATION_INPUT,
FIRST_RUN_JOB_ID,
FIRST_RUN_OUTPUT,
FIRST_RUN_START_TEMPLATE_ID,
queuedPrompt
} from '@e2e/fixtures/data/firstRunTour'
import type { ExecutionHelper } from '@e2e/fixtures/helpers/ExecutionHelper'
import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute'

const { firstRun } = enMessages.onboardingCoachmarks

/**
* The roles the tour reads off the synthetic graph. The graph asset carries
* these ids by hand, so the run addresses the sink through the pin rather than
* a literal — a renumbered pin then moves both together.
*/
const START_PINS = TOUR_ROLE_PINS[FIRST_RUN_START_TEMPLATE_ID]

/** Drives the complete first-success path that precedes a continuation. */
export class PostFirstRunHelper {
constructor(
private readonly comfyPage: ComfyPage,
private readonly onboarding: OnboardingCoachmarks,
private readonly execution: ExecutionHelper
) {}

async completeTourWithImage(): Promise<void> {
const { page } = this.comfyPage
const gettingStarted = page.getByRole('dialog', {
name: enMessages.gettingStarted.title
})

await page.route(
'**/api/prompt',
(route) => route.fulfill(jsonRoute(queuedPrompt(FIRST_RUN_JOB_ID))),
{ times: 1 }
)

await expect(gettingStarted).toBeVisible()
await page
.getByTestId(`getting-started-card-${FIRST_RUN_START_TEMPLATE_ID}`)
.click()

await expect(gettingStarted).toBeHidden()
await expect(
this.onboarding.spotlight,
`the tour has to start, which needs the synthetic graph to carry ${FIRST_RUN_START_TEMPLATE_ID}'s pinned roles: ${JSON.stringify(START_PINS)}`
).toBeVisible()

await this.onboarding.walkToStep(firstRun.run.title)

await this.comfyPage.runButton.click()
await expect(
this.onboarding.card.getByText(firstRun.result.generating.title),
'the run outlives its step, so the click moves the tour on and Result reports it'
).toBeVisible({ timeout: 15_000 })

this.execution.executionStart(FIRST_RUN_JOB_ID)
this.execution.executed(FIRST_RUN_JOB_ID, String(START_PINS.sink.id), {
images: [FIRST_RUN_OUTPUT]
})
this.execution.executionSuccess(FIRST_RUN_JOB_ID)

await expect(
this.onboarding.card.getByText(firstRun.result.image.title),
'the run produced an image, so Result has to stop saying it is still coming'
).toBeVisible({ timeout: 15_000 })
await this.onboarding.cardDoneButton.click()
await expect(this.onboarding.card).toBeHidden()
}

/**
* The value the continuation's declared image input is carrying, or null
* while the graph swap has yet to settle on exactly one such node.
*/
async loadedContinuationInput(): Promise<string | null> {
const inputs = await this.comfyPage.nodeOps.getNodeRefsByType(
CONTINUATION_INPUT.nodeType
)
if (inputs.length !== 1) return null
const value = await (await inputs[0].getWidgetByName('image')).getValue()
return typeof value === 'string' ? value : null
}
}
29 changes: 29 additions & 0 deletions browser_tests/fixtures/postFirstRunFixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { mergeTests } from '@playwright/test'

import { comfyPageFixture } from '@e2e/fixtures/ComfyPage'
import { FirstRunNudge } from '@e2e/fixtures/components/FirstRunNudge'
import { ExecutionHelper } from '@e2e/fixtures/helpers/ExecutionHelper'
import { PostFirstRunHelper } from '@e2e/fixtures/helpers/PostFirstRunHelper'
import { templateApiFixture } from '@e2e/fixtures/templateApiFixture'
import { onboardingFixture } from '@e2e/fixtures/tourFixture'
import { webSocketFixture } from '@e2e/fixtures/ws'

const base = mergeTests(
comfyPageFixture,
onboardingFixture,
templateApiFixture,
webSocketFixture
)

export const postFirstRunFixture = base.extend<{
firstRunNudge: FirstRunNudge
postFirstRun: PostFirstRunHelper
}>({
firstRunNudge: async ({ page }, use) => {
await use(new FirstRunNudge(page))
},
postFirstRun: async ({ comfyPage, getWebSocket, onboarding }, use) => {
const execution = new ExecutionHelper(comfyPage, await getWebSocket())
await use(new PostFirstRunHelper(comfyPage, onboarding, execution))
}
})
Loading
Loading