diff --git a/browser_tests/assets/onboarding/first_run_tour_contract.json b/browser_tests/assets/onboarding/first_run_tour_contract.json new file mode 100644 index 00000000000..c6880e640a9 --- /dev/null +++ b/browser_tests/assets/onboarding/first_run_tour_contract.json @@ -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 +} diff --git a/browser_tests/fixtures/components/FirstRunNudge.ts b/browser_tests/fixtures/components/FirstRunNudge.ts new file mode 100644 index 00000000000..88cd1ea25d5 --- /dev/null +++ b/browser_tests/fixtures/components/FirstRunNudge.ts @@ -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}`) + } +} diff --git a/browser_tests/fixtures/components/Tour.ts b/browser_tests/fixtures/components/Tour.ts index 9c1569cc8e2..cc434f7d1e2 100644 --- a/browser_tests/fixtures/components/Tour.ts +++ b/browser_tests/fixtures/components/Tour.ts @@ -1,3 +1,4 @@ +import { expect } from '@playwright/test' import type { Locator, Page } from '@playwright/test' import { TOUR_SEEN_SETTING } from '@/platform/onboarding/onboardingTours' @@ -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 @@ -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' }) } @@ -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 { + 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 { + 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. diff --git a/browser_tests/fixtures/data/assetFixtures.ts b/browser_tests/fixtures/data/assetFixtures.ts index 745cb0eb57d..9761ef1117e 100644 --- a/browser_tests/fixtures/data/assetFixtures.ts +++ b/browser_tests/fixtures/data/assetFixtures.ts @@ -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 @@ -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', diff --git a/browser_tests/fixtures/data/cloudWorkspace.ts b/browser_tests/fixtures/data/cloudWorkspace.ts index 03fb46ea8f1..f2de5f675f4 100644 --- a/browser_tests/fixtures/data/cloudWorkspace.ts +++ b/browser_tests/fixtures/data/cloudWorkspace.ts @@ -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', diff --git a/browser_tests/fixtures/data/firstRunTour.ts b/browser_tests/fixtures/data/firstRunTour.ts new file mode 100644 index 00000000000..731d90668c6 --- /dev/null +++ b/browser_tests/fixtures/data/firstRunTour.ts @@ -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]' diff --git a/browser_tests/fixtures/helpers/PostFirstRunHelper.ts b/browser_tests/fixtures/helpers/PostFirstRunHelper.ts new file mode 100644 index 00000000000..f06b998d6c2 --- /dev/null +++ b/browser_tests/fixtures/helpers/PostFirstRunHelper.ts @@ -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 { + 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 { + 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 + } +} diff --git a/browser_tests/fixtures/postFirstRunFixture.ts b/browser_tests/fixtures/postFirstRunFixture.ts new file mode 100644 index 00000000000..0b2dae9e5a8 --- /dev/null +++ b/browser_tests/fixtures/postFirstRunFixture.ts @@ -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)) + } +}) diff --git a/browser_tests/fixtures/utils/firstRunTourMocks.ts b/browser_tests/fixtures/utils/firstRunTourMocks.ts new file mode 100644 index 00000000000..e265b5dba97 --- /dev/null +++ b/browser_tests/fixtures/utils/firstRunTourMocks.ts @@ -0,0 +1,25 @@ +import type { Page } from '@playwright/test' + +import { EMPTY_ASSET_RESPONSE } from '@e2e/fixtures/data/assetFixtures' +import { + ACTIVE_PERSONAL_BILLING_STATUS, + ONBOARDING_TOUR_REMOTE_CONFIG +} from '@e2e/fixtures/data/cloudWorkspace' +import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute' + +/** + * The install the first-run tour needs: the tour flag on, a workspace funded + * enough to run, and a backend serving no assets. Both onboarding suites enter + * through here, so neither can drift from the other. + */ +export async function mockFirstRunTourBackend(page: Page) { + await page.route('**/api/features', (route) => + route.fulfill(jsonRoute(ONBOARDING_TOUR_REMOTE_CONFIG)) + ) + await page.route('**/api/billing/status', (route) => + route.fulfill(jsonRoute(ACTIVE_PERSONAL_BILLING_STATUS)) + ) + await page.route('**/api/assets**', (route) => + route.fulfill(jsonRoute(EMPTY_ASSET_RESPONSE)) + ) +} diff --git a/browser_tests/tests/gettingStartedTour.spec.ts b/browser_tests/tests/onboarding/gettingStartedTour.spec.ts similarity index 81% rename from browser_tests/tests/gettingStartedTour.spec.ts rename to browser_tests/tests/onboarding/gettingStartedTour.spec.ts index 1fc67ab9f69..14dd1f06924 100644 --- a/browser_tests/tests/gettingStartedTour.spec.ts +++ b/browser_tests/tests/onboarding/gettingStartedTour.spec.ts @@ -5,17 +5,20 @@ import enMessages from '@/locales/en/main.json' with { type: 'json' } import { TOUR_ROLE_PINS } from '@/renderer/extensions/firstRunTour/roles/tourRolePins' import type { SupportedTemplateId } from '@/renderer/extensions/firstRunTour/roles/tourRolePins' -import type { PromptResponse } from '@comfyorg/ingest-types' - -import type { AssetResponse } from '@/platform/assets/schemas/assetSchema' -import type { RemoteConfig } from '@/platform/remoteConfig/types' import type { BillingStatusResponse } from '@/platform/workspace/api/workspaceApi' import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' +import { FirstRunNudge } from '@e2e/fixtures/components/FirstRunNudge' +import type { OnboardingCoachmarks } from '@e2e/fixtures/components/Tour' +import { + FIRST_RUN_START_TEMPLATE_ID, + queuedPrompt +} from '@e2e/fixtures/data/firstRunTour' import { ExecutionHelper } from '@e2e/fixtures/helpers/ExecutionHelper' import { onboardingFixture } from '@e2e/fixtures/tourFixture' import type { Position } from '@e2e/fixtures/types' import { mockBilling } from '@e2e/fixtures/utils/cloudBillingMocks' +import { mockFirstRunTourBackend } from '@e2e/fixtures/utils/firstRunTourMocks' import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute' import { VueNodeFixture } from '@e2e/fixtures/utils/vueNodeFixtures' import { webSocketFixture } from '@e2e/fixtures/ws' @@ -33,30 +36,6 @@ const CARD_TESTID_PREFIX = 'getting-started-card-' /** The prompt id the tour's run is queued under, so WS events can address it. */ const TOUR_JOB_ID = 'first-run-tour-prompt' -const LINKED_TEMPLATE_ID: SupportedTemplateId = 'image_z_image_turbo' - -/** A prompt the queue accepts, so the walk does not depend on the backend's models. */ -const QUEUED_PROMPT: PromptResponse = { - prompt_id: TOUR_JOB_ID, - number: 1, - node_errors: {} -} - -const TOUR_FEATURE_FLAGS: RemoteConfig = { - onboarding_tour_enabled: true, - subscription_required: true -} - -const ACTIVE_SUBSCRIPTION: BillingStatusResponse = { - 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 -} const INACTIVE_SUBSCRIPTION: BillingStatusResponse = { is_active: false, @@ -68,23 +47,10 @@ const INACTIVE_SUBSCRIPTION: BillingStatusResponse = { has_funds: false } -const NO_ASSETS: AssetResponse = { - assets: [], - total: 0, - has_more: false -} - function isPinned(id: string): id is SupportedTemplateId { return Object.hasOwn(TOUR_ROLE_PINS, id) } -/** How many steps the card says the tour has, once it says anything. */ -async function tourLength(card: Locator): Promise { - await expect(card).toContainText(/Step \d+ of \d+/) - const label = await card.textContent() - return Number(/Step \d+ of (\d+)/.exec(label ?? '')?.[1]) -} - async function clearWorkflowHistory(page: Page) { await page.evaluate(() => { for (const key of Object.keys(localStorage)) @@ -209,20 +175,11 @@ test.describe('First-run tour', { tag: ['@cloud', '@ui'] }, () => { 'Comfy.TutorialCompleted': false, 'Comfy.OnboardingCoachmarks.Seen': ['appMode'], 'Comfy.VueNodes.Enabled': true - }, - initialFeatureFlags: { onboarding_tour_enabled: true } + } }) test.beforeEach(async ({ page }) => { - await page.route('**/api/features', (route) => - route.fulfill(jsonRoute(TOUR_FEATURE_FLAGS)) - ) - await page.route('**/api/billing/status', (route) => - route.fulfill(jsonRoute(ACTIVE_SUBSCRIPTION)) - ) - await page.route('**/api/assets**', (route) => - route.fulfill(jsonRoute(NO_ASSETS)) - ) + await mockFirstRunTourBackend(page) }) /** @@ -231,13 +188,14 @@ test.describe('First-run tour', { tag: ['@cloud', '@ui'] }, () => { * paywalled branches part. The run is queued under a known id, so whoever * goes on to click Run can address it over the websocket. */ - async function tourToRunStep(page: Page) { + async function tourToRunStep( + page: Page, + onboarding: OnboardingCoachmarks + ): Promise { const screen = page.getByRole('dialog', { name: GETTING_STARTED_TITLE }) - const spotlight = page.getByTestId('coach-spotlight') - const card = page.getByTestId('coach-card') await page.route('**/api/prompt', (route) => - route.fulfill(jsonRoute(QUEUED_PROMPT)) + route.fulfill(jsonRoute(queuedPrompt(TOUR_JOB_ID))) ) await expect(screen).toBeVisible() @@ -247,63 +205,54 @@ test.describe('First-run tour', { tag: ['@cloud', '@ui'] }, () => { await expect(screen).toBeHidden() await expect( - spotlight, + onboarding.spotlight, 'picking a template must spotlight the graph it loaded' ).toBeVisible() - const next = card.getByRole('button', { name: 'Next' }) - const runTitle = card.getByText(RUN_STEP_TITLE) - const totalSteps = await tourLength(card) - - for (let step = 1; step < totalSteps; step++) { - await expect(card).toContainText(`Step ${step} of ${totalSteps}`) - if (await runTitle.isVisible()) break - await next.click() - } + const totalSteps = await onboarding.walkToStep(RUN_STEP_TITLE) - await expect(runTitle).toBeVisible() await expect( - next, + onboarding.cardNextButton, 'the Run step must offer no way forward except running' ).toBeHidden() - return { spotlight, card, totalSteps } + return totalSteps } /** Clicks Run and waits for the Result step to admit the run is in flight. */ async function runFromTourStep( page: Page, - card: Locator, + onboarding: OnboardingCoachmarks, totalSteps: number ) { await page.getByTestId('queue-button').click() await expect( - card.getByText(GENERATING_TITLE), + onboarding.card.getByText(GENERATING_TITLE), 'the run outlives its step, so the click moves the tour on and Result reports it' ).toBeVisible({ timeout: 15_000 }) await expect( - card, + onboarding.card, 'Run hands over to the last step, the one spotlighting where output lands' ).toContainText(`Step ${totalSteps} of ${totalSteps}`) } wstest( 'guides a first-run user from a template to a finished result', - async ({ comfyPage, getWebSocket }) => { + async ({ comfyPage, getWebSocket, onboarding }) => { // A template load, three camera flights and a queued run do not fit the default budget. test.slow() const { page } = comfyPage const execution = new ExecutionHelper(comfyPage, await getWebSocket()) - const { card, totalSteps } = await tourToRunStep(page) - await runFromTourStep(page, card, totalSteps) + const totalSteps = await tourToRunStep(page, onboarding) + await runFromTourStep(page, onboarding, totalSteps) execution.executionStart(TOUR_JOB_ID) execution.executionSuccess(TOUR_JOB_ID) await expect( - card.getByText(RESULT_IMAGE_TITLE), + onboarding.card.getByText(RESULT_IMAGE_TITLE), 'the run finished, so the Result step has to stop saying it is still coming' ).toBeVisible({ timeout: 15_000 }) } @@ -311,19 +260,19 @@ test.describe('First-run tour', { tag: ['@cloud', '@ui'] }, () => { wstest( 'tells a first-run user when the run produced nothing', - async ({ comfyPage, getWebSocket }) => { + async ({ comfyPage, getWebSocket, onboarding }) => { test.slow() const { page } = comfyPage const execution = new ExecutionHelper(comfyPage, await getWebSocket()) - const { card, totalSteps } = await tourToRunStep(page) - await runFromTourStep(page, card, totalSteps) + const totalSteps = await tourToRunStep(page, onboarding) + await runFromTourStep(page, onboarding, totalSteps) execution.executionStart(TOUR_JOB_ID) execution.executionError(TOUR_JOB_ID, '1', 'the run blew up') await expect( - card.getByText(RESULT_FAILED_TITLE), + onboarding.card.getByText(RESULT_FAILED_TITLE), 'announcing a result that does not exist is the bug D2 filed' ).toBeVisible({ timeout: 15_000 }) } @@ -338,12 +287,14 @@ test.describe('First-run tour', { tag: ['@cloud', '@ui'] }, () => { }) test('leaves the nudge until the upgrade dialog closes', async ({ - comfyPage + comfyPage, + onboarding }) => { test.slow() const { page } = comfyPage - const { spotlight } = await tourToRunStep(page) - const nudge = page.getByTestId('first-run-nudge') + await tourToRunStep(page, onboarding) + const { spotlight } = onboarding + const nudge = new FirstRunNudge(page).root const upgradeDialog = page.getByTestId('dialog-overlay') await page.getByTestId('subscribe-to-run-button').click() @@ -383,7 +334,7 @@ test.describe('First-run tour', { tag: ['@cloud', '@ui'] }, () => { await clearWorkflowHistory(comfyPage.page) await comfyPage.setup({ clearStorage: false, - url: `/?template=${LINKED_TEMPLATE_ID}` + url: `/?template=${FIRST_RUN_START_TEMPLATE_ID}` }) }) diff --git a/browser_tests/tests/onboarding/postFirstRunContinuations.spec.ts b/browser_tests/tests/onboarding/postFirstRunContinuations.spec.ts new file mode 100644 index 00000000000..1c23cf1197f --- /dev/null +++ b/browser_tests/tests/onboarding/postFirstRunContinuations.spec.ts @@ -0,0 +1,125 @@ +import { expect } from '@playwright/test' + +import { FIRST_RUN_SUGGESTIONS } from '@/renderer/extensions/firstRunTour/nudge/firstRunNudgeSuggestions' + +import { + CONTINUATION_INPUT, + FIRST_RUN_OUTPUT, + FIRST_RUN_OUTPUT_WIDGET_VALUE, + FIRST_RUN_START_TEMPLATE_ID, + FIRST_RUN_TEMPLATES +} from '@e2e/fixtures/data/firstRunTour' +import { withTemplates } from '@e2e/fixtures/helpers/TemplateHelper' +import { postFirstRunFixture as test } from '@e2e/fixtures/postFirstRunFixture' +import { mockFirstRunTourBackend } from '@e2e/fixtures/utils/firstRunTourMocks' +import { assetPath } from '@e2e/fixtures/utils/paths' +import { mockViewFiles } from '@e2e/fixtures/utils/viewFileMocks' + +/** + * Which continuation the walk clicks does not matter here: the id-to-template + * mapping is covered per action in `FirstRunTourNudge.test.ts`, and what this + * suite adds is the wiring underneath it — a fetched graph replacing the tour + * workflow with the first output seeded into its declared input. + */ +const CONTINUATION = FIRST_RUN_SUGGESTIONS[0] + +/** + * Covers the frontend handoff contract with a synthetic LoadImage workflow. + * Published template graphs and their runtime execution are separate gates. + */ +test.describe( + 'Post-first-run continuations', + { tag: ['@cloud', '@ui'] }, + () => { + // A template load, camera flights, a queued run and a graph swap do not fit the default budget. + test.describe.configure({ timeout: 120_000 }) + + test.use({ + initialSettings: { + 'Comfy.TutorialCompleted': false, + 'Comfy.OnboardingCoachmarks.Seen': ['appMode'], + 'Comfy.VueNodes.Enabled': true + } + }) + + test.beforeEach(async ({ page, templateApi }) => { + templateApi.configure(withTemplates(FIRST_RUN_TEMPLATES)) + await templateApi.mock() + + await mockFirstRunTourBackend(page) + await page.route( + `**/templates/${FIRST_RUN_START_TEMPLATE_ID}.json`, + (route) => + route.fulfill({ + contentType: 'application/json', + // Synthetic graph matching the tour's pinned prompt and output roles. + path: assetPath('onboarding/first_run_tour_contract.json') + }) + ) + for (const { templateId } of FIRST_RUN_SUGGESTIONS) { + await page.route(`**/templates/${templateId}.json`, (route) => + route.fulfill({ + contentType: 'application/json', + path: assetPath('widgets/load_image_widget.json') + }) + ) + } + await mockViewFiles(page, { + [FIRST_RUN_OUTPUT.filename]: { + contentType: 'image/webp', + path: assetPath('image64x64.webp') + }, + [FIRST_RUN_OUTPUT_WIDGET_VALUE]: { + contentType: 'image/webp', + path: assetPath('image64x64.webp') + } + }) + }) + + test('passes the first output to the continuation it loads', async ({ + comfyPage, + firstRunNudge, + page, + postFirstRun + }) => { + await postFirstRun.completeTourWithImage() + + await expect( + firstRunNudge.root, + 'every tour ending has to leave the user somewhere to go next' + ).toBeVisible({ timeout: 10_000 }) + await expect( + firstRunNudge.actions, + 'the served catalog carries every continuation, so none are filtered out' + ).toHaveCount(FIRST_RUN_SUGGESTIONS.length) + + const requestedTemplate = page.waitForRequest( + `**/templates/${CONTINUATION.templateId}.json` + ) + await firstRunNudge.action(CONTINUATION.id).click() + await requestedTemplate + + await expect( + firstRunNudge.root, + 'the card only closes once the continuation actually loaded' + ).toBeHidden() + await expect + .poll(() => comfyPage.nodeOps.getNodeCount(), { + message: 'the continuation never replaced the tour workflow' + }) + .toBe(1) + await expect + .poll(() => postFirstRun.loadedContinuationInput(), { + message: + 'the first output never reached the metadata-declared image input' + }) + .toBe(FIRST_RUN_OUTPUT_WIDGET_VALUE) + await expect( + comfyPage.vueNodes + .getNodeLocator(String(CONTINUATION_INPUT.nodeId)) + .locator('img'), + 'the seeded value has to resolve to an image the node can show' + ).toBeVisible() + }) + } +) diff --git a/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.test.ts b/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.test.ts index b546fd6c47b..818757dc3f9 100644 --- a/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.test.ts +++ b/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.test.ts @@ -7,6 +7,8 @@ import { createI18n } from 'vue-i18n' import enMessages from '@/locales/en/main.json' with { type: 'json' } import FirstRunTourNudge from './FirstRunTourNudge.vue' +import { FIRST_RUN_SUGGESTIONS } from './firstRunNudgeSuggestions' +import type { FirstRunSuggestionId } from './firstRunNudgeSuggestions' const APPEAR_DELAY_MS = 1500 const CATALOG_WAIT_MS = 3000 @@ -15,12 +17,22 @@ const FIRST_OUTPUT = { subfolder: 'tour', type: 'output' as const } -type SuggestionId = 'animate' | 'upscale' | 'restyle' -const SUGGESTION_TITLES: Record = { - animate: enMessages.onboardingCoachmarks.firstRun.nudge.animate.title, - upscale: enMessages.onboardingCoachmarks.firstRun.nudge.upscale.title, - restyle: enMessages.onboardingCoachmarks.firstRun.nudge.restyle.title +/** + * The template each action continues into, spelled out rather than read off + * `FIRST_RUN_SUGGESTIONS`, so repointing an action at another template fails + * here instead of being asserted against itself. + */ +const CONTINUATION_TEMPLATE_IDS = { + animate: 'video_minimax_h3_i2v_continuation', + upscale: 'utility_seedvr2_7b_int8_upscale_image', + restyle: 'api_google_nano_banana2_image_edit_continuation' +} as const satisfies Record + +function suggestionTitle(id: FirstRunSuggestionId): string { + const found = FIRST_RUN_SUGGESTIONS.find((entry) => entry.id === id) + if (!found) throw new Error(`No such suggestion: ${id}`) + return i18n.global.t(found.titleKey) } type Deferred = { @@ -36,11 +48,7 @@ function createDeferred(): Deferred { return { promise, resolve } } -const CATALOG_TEMPLATE_IDS = [ - 'video_minimax_h3_i2v_continuation', - 'utility_seedvr2_7b_int8_upscale_image', - 'api_google_nano_banana2_image_edit_continuation' -] +const CATALOG_TEMPLATE_IDS = Object.values(CONTINUATION_TEMPLATE_IDS) /** Stands in for what the install's template package actually serves. */ function catalogEntry(name: string, withIo: boolean) { @@ -153,9 +161,9 @@ function nudge() { return screen.queryByTestId('first-run-nudge') } -function suggestionButton(id: SuggestionId) { +function suggestionButton(id: FirstRunSuggestionId) { return screen.getByRole('button', { - name: new RegExp(SUGGESTION_TITLES[id], 'i') + name: new RegExp(suggestionTitle(id), 'i') }) } @@ -190,7 +198,7 @@ describe('FirstRunTourNudge', () => { ).toBeTruthy() expect(mocks.trackOnboardingTour).toHaveBeenCalledWith('nudge_shown', { tour: 'firstRun', - suggestion_count: 3 + suggestion_count: FIRST_RUN_SUGGESTIONS.length }) }) @@ -221,29 +229,16 @@ describe('FirstRunTourNudge', () => { expect(mocks.dismissNudge).toHaveBeenCalledTimes(2) }) - it.for([ - { - id: 'animate', - templateId: 'video_minimax_h3_i2v_continuation' - }, - { - id: 'upscale', - templateId: 'utility_seedvr2_7b_int8_upscale_image' - }, - { - id: 'restyle', - templateId: 'api_google_nano_banana2_image_edit_continuation' - } - ] as const)( + it.for(FIRST_RUN_SUGGESTIONS)( 'continues the first output through $id', - async ({ id, templateId }) => { + async ({ id }) => { const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime }) await showNudge() await user.click(suggestionButton(id)) expect(mocks.loadWorkflowTemplate).toHaveBeenCalledWith( - templateId, + CONTINUATION_TEMPLATE_IDS[id], 'default', { input: FIRST_OUTPUT } ) @@ -251,7 +246,7 @@ describe('FirstRunTourNudge', () => { 'nudge_suggestion_clicked', { tour: 'firstRun', - suggestion_count: 3, + suggestion_count: FIRST_RUN_SUGGESTIONS.length, suggestion: id, loaded: true } @@ -282,7 +277,7 @@ describe('FirstRunTourNudge', () => { expect(suggestionButton('animate')).toBeTruthy() expect(mocks.trackOnboardingTour).toHaveBeenCalledWith('nudge_shown', { tour: 'firstRun', - suggestion_count: 3 + suggestion_count: FIRST_RUN_SUGGESTIONS.length }) }) @@ -313,7 +308,7 @@ describe('FirstRunTourNudge', () => { expect( screen.queryByRole('button', { - name: new RegExp(SUGGESTION_TITLES.animate, 'i') + name: new RegExp(suggestionTitle('animate'), 'i') }), 'the catalog deadline already decided what the card showed and reported' ).toBeNull() @@ -354,13 +349,13 @@ describe('FirstRunTourNudge', () => { }) it('offers only the continuations the install actually serves', async () => { - mocks.catalog.value = ['utility_seedvr2_7b_int8_upscale_image'] + mocks.catalog.value = [CONTINUATION_TEMPLATE_IDS.upscale] await showNudge() expect(suggestionButton('upscale')).toBeTruthy() expect( screen.queryByRole('button', { - name: new RegExp(SUGGESTION_TITLES.animate, 'i') + name: new RegExp(suggestionTitle('animate'), 'i') }), 'this build knows the id, but the pinned template package does not serve it' ).toBeNull() @@ -382,7 +377,7 @@ describe('FirstRunTourNudge', () => { expect( screen.queryByRole('button', { - name: new RegExp(SUGGESTION_TITLES.animate, 'i') + name: new RegExp(suggestionTitle('animate'), 'i') }), 'every action would be a dead end found by clicking it' ).toBeNull() @@ -410,7 +405,7 @@ describe('FirstRunTourNudge', () => { ).toBeTruthy() expect( screen.queryByRole('button', { - name: new RegExp(SUGGESTION_TITLES.animate, 'i') + name: new RegExp(suggestionTitle('animate'), 'i') }), 'there is nothing to seed a continuation with' ).toBeNull() @@ -475,7 +470,7 @@ describe('FirstRunTourNudge', () => { 'nudge_suggestion_clicked', { tour: 'firstRun', - suggestion_count: 3, + suggestion_count: FIRST_RUN_SUGGESTIONS.length, suggestion: 'animate', loaded: false } @@ -495,7 +490,7 @@ describe('FirstRunTourNudge', () => { expect(mocks.showTemplates).toHaveBeenCalledWith('first_run_nudge') expect(mocks.trackOnboardingTour).toHaveBeenCalledWith( 'explore_templates_clicked', - { tour: 'firstRun', suggestion_count: 3 } + { tour: 'firstRun', suggestion_count: FIRST_RUN_SUGGESTIONS.length } ) expect(mocks.dismissNudge).toHaveBeenCalled() }) diff --git a/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.vue b/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.vue index a4f9d2e2eb5..737a061c73e 100644 --- a/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.vue +++ b/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.vue @@ -108,6 +108,11 @@ import { acceptsTemplateImageInput } from '@/platform/workflow/templates/utils/t import { useDialogStore } from '@/stores/dialogStore' import { useFirstRunTourController } from '../tour/useFirstRunTourController' +import { FIRST_RUN_SUGGESTIONS } from './firstRunNudgeSuggestions' +import type { + FirstRunSuggestion, + FirstRunSuggestionId +} from './firstRunNudgeSuggestions' const APPEAR_DELAY_MS = 1500 @@ -118,46 +123,6 @@ const APPEAR_DELAY_MS = 1500 */ const CATALOG_WAIT_MS = 3000 -type SuggestionId = 'animate' | 'upscale' | 'restyle' - -interface Suggestion { - id: SuggestionId - templateId: string - titleKey: string - detailKey: string - icon: string - /** A qualifier on the action itself, such as the upscale's multiplier. */ - badgeKey?: string - /** Marks the action a paid plan is required to run, so the card says so. */ - paid?: boolean -} - -const SUGGESTIONS: Suggestion[] = [ - { - id: 'animate', - templateId: 'video_minimax_h3_i2v_continuation', - titleKey: 'onboardingCoachmarks.firstRun.nudge.animate.title', - detailKey: 'onboardingCoachmarks.firstRun.nudge.animate.detail', - icon: 'icon-[lucide--film]' - }, - { - id: 'upscale', - templateId: 'utility_seedvr2_7b_int8_upscale_image', - titleKey: 'onboardingCoachmarks.firstRun.nudge.upscale.title', - detailKey: 'onboardingCoachmarks.firstRun.nudge.upscale.detail', - icon: 'icon-[lucide--maximize-2]', - badgeKey: 'onboardingCoachmarks.firstRun.nudge.upscale.badge' - }, - { - id: 'restyle', - templateId: 'api_google_nano_banana2_image_edit_continuation', - titleKey: 'onboardingCoachmarks.firstRun.nudge.restyle.title', - detailKey: 'onboardingCoachmarks.firstRun.nudge.restyle.detail', - icon: 'icon-[ph--swatches]', - paid: true - } -] - const { t } = useI18n() const toast = useToast() const { nudgeArmed, nudgeOutput, dismissNudge } = useFirstRunTourController() @@ -167,9 +132,9 @@ const dialogStore = useDialogStore() const telemetry = useTelemetry() const titleId = useId() const subtitleId = useId() -const loadingSuggestionId = ref(null) +const loadingSuggestionId = ref(null) const delayElapsed = ref(false) -const decidedSuggestions = ref(null) +const decidedSuggestions = ref(null) let reported = false /** @@ -181,7 +146,7 @@ let reported = false const catalogSuggestions = computed(() => nudgeOutput.value === null ? [] - : SUGGESTIONS.filter(({ templateId }) => { + : FIRST_RUN_SUGGESTIONS.filter(({ templateId }) => { const template = templatesStore.getTemplateByName(templateId) return ( template?.sourceModule === 'default' && @@ -281,7 +246,7 @@ watch(onScreen, (visible) => { }) }) -async function onSuggestion(suggestion: Suggestion) { +async function onSuggestion(suggestion: FirstRunSuggestion) { const input = nudgeOutput.value if (!input || loadingSuggestionId.value) return diff --git a/src/renderer/extensions/firstRunTour/nudge/firstRunNudgeSuggestions.ts b/src/renderer/extensions/firstRunTour/nudge/firstRunNudgeSuggestions.ts new file mode 100644 index 00000000000..9603b67205a --- /dev/null +++ b/src/renderer/extensions/firstRunTour/nudge/firstRunNudgeSuggestions.ts @@ -0,0 +1,44 @@ +export type FirstRunSuggestionId = 'animate' | 'upscale' | 'restyle' + +export interface FirstRunSuggestion { + id: FirstRunSuggestionId + templateId: string + titleKey: string + detailKey: string + icon: string + /** A qualifier on the action itself, such as the upscale's multiplier. */ + badgeKey?: string + /** Marks the action a paid plan is required to run, so the card says so. */ + paid?: boolean +} + +/** + * The continuations the discovery card offers, in the order it lists them. + * Kept beside the card rather than inside it so the suites covering the card + * read the ids it actually renders instead of retyping them. + */ +export const FIRST_RUN_SUGGESTIONS: readonly FirstRunSuggestion[] = [ + { + id: 'animate', + templateId: 'video_minimax_h3_i2v_continuation', + titleKey: 'onboardingCoachmarks.firstRun.nudge.animate.title', + detailKey: 'onboardingCoachmarks.firstRun.nudge.animate.detail', + icon: 'icon-[lucide--film]' + }, + { + id: 'upscale', + templateId: 'utility_seedvr2_7b_int8_upscale_image', + titleKey: 'onboardingCoachmarks.firstRun.nudge.upscale.title', + detailKey: 'onboardingCoachmarks.firstRun.nudge.upscale.detail', + icon: 'icon-[lucide--maximize-2]', + badgeKey: 'onboardingCoachmarks.firstRun.nudge.upscale.badge' + }, + { + id: 'restyle', + templateId: 'api_google_nano_banana2_image_edit_continuation', + titleKey: 'onboardingCoachmarks.firstRun.nudge.restyle.title', + detailKey: 'onboardingCoachmarks.firstRun.nudge.restyle.detail', + icon: 'icon-[ph--swatches]', + paid: true + } +]