Skip to content
Merged
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
54 changes: 54 additions & 0 deletions browser_tests/assets/openOnCloud/01-runnable-on-cloud.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"last_node_id": 2,
"last_link_id": 1,
"nodes": [
{
"id": 1,
"type": "EmptyImage",
"pos": [150, 140],
"size": [270, 130],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [1],
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "EmptyImage"
},
"widgets_values": [256, 256, 1, 42920]
},
{
"id": 2,
"type": "SaveImage",
"pos": [480, 140],
"size": [300, 285],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 1
}
],
"outputs": [],
"properties": {
"Node name for S&R": "SaveImage"
},
"widgets_values": ["open-on-cloud-validation"]
}
],
"links": [[1, 1, 0, 2, 0, "IMAGE"]],
"groups": [],
"config": {},
"extra": {},
"version": 0.4
}
64 changes: 64 additions & 0 deletions browser_tests/fixtures/liveOpenOnCloudFixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { expect } from '@playwright/test'
import { z } from 'zod'

import { ComfyPage } from '@e2e/fixtures/ComfyPage'
import { networkIsolationFixture as base } from '@e2e/fixtures/networkIsolationFixture'

const cloudOriginSchema = z
.url()
.refine((value) => {
const url = new URL(value)
return (
url.protocol === 'https:' &&
url.href === `${url.origin}/` &&
/^(testcloud\.comfy\.org|stagingcloud\.comfy\.org|(?:fe-)?pr-\d+\.testenvs\.comfy\.org)$/.test(
url.hostname
)
)
}, 'OPEN_ON_CLOUD_URL must be a test, staging, or PR preview origin')
.transform((value) => new URL(value).origin)

export const liveOpenOnCloudFixture = base.extend<{
cloudOrigin: string
comfyPage: ComfyPage
}>({
baseURL: process.env.PLAYWRIGHT_TEST_URL,
cloudOrigin: [
process.env.OPEN_ON_CLOUD_URL?.replace(/\/$/, '') ?? '',
{ option: true }
],
liveNetworkOrigins: async ({ cloudOrigin }, use) => {
await use([
cloudOriginSchema.parse(cloudOrigin),
'https://api.comfy.org',
'https://stagingapi.comfy.org',
'https://cloud.comfy.org',
'https://testcloud.comfy.org',
'https://media.comfy.org',
'https://identitytoolkit.googleapis.com',
'https://securetoken.googleapis.com',
'https://dreamboothy-dev.firebaseapp.com',
'https://apis.google.com',
'https://www.gstatic.com',
'https://fonts.googleapis.com',
'https://fonts.gstatic.com',
'https://huggingface.co'
])
},
comfyPage: async ({ page, request }, use) => {
const comfyPage = new ComfyPage(page, request)
await comfyPage.goto()
await comfyPage.waitForAppReady()
const templates = page.getByRole('dialog', {
name: 'Get Started with a Template',
exact: true
})
if (await templates.isVisible()) {
await templates
.getByRole('button', { name: 'Close dialog', exact: true })
.press('Escape')
}
await expect(comfyPage.canvas).toBeVisible()
await use(comfyPage)
}
})
28 changes: 24 additions & 4 deletions browser_tests/fixtures/networkIsolationFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,19 @@ function guardApiRequests(

export const networkIsolationFixture = base.extend<{
liveCloudBillingConfig: LiveCloudBillingConfig | undefined
liveNetworkOrigins: string[]
networkPolicy: NetworkPolicy
toast: ToastHelper
}>({
serviceWorkers: 'block',
liveCloudBillingConfig: [undefined, { option: true }],
liveNetworkOrigins: [[], { option: true }],
networkPolicy: [
async ({ baseURL, liveCloudBillingConfig }, use, testInfo) => {
async (
{ baseURL, liveCloudBillingConfig, liveNetworkOrigins },
use,
testInfo
) => {
const frontend =
process.env.PLAYWRIGHT_TEST_URL || 'http://localhost:8188'
const origins = liveCloudBillingConfig
Expand All @@ -82,7 +88,8 @@ export const networkIsolationFixture = base.extend<{
frontend,
baseURL,
process.env.PLAYWRIGHT_SETUP_API_URL,
process.env.DEV_SERVER_COMFYUI_URL
process.env.DEV_SERVER_COMFYUI_URL,
...liveNetworkOrigins
].flatMap((url) => (url ? [new URL(url).origin] : []))
)
const unexpected = new Set<string>()
Expand All @@ -98,7 +105,9 @@ export const networkIsolationFixture = base.extend<{
liveCloudBillingConfig ? blocked.filter(isReportedViolation) : blocked,
liveCloudBillingConfig
? 'Forbidden live Cloud requests'
: 'Unexpected external requests. Add a local mock.'
: liveNetworkOrigins.length > 0
? 'Unexpected external requests during a live test'
: 'Unexpected external requests. Add a local mock.'
).toEqual([])
},
{ auto: true }
Expand All @@ -123,7 +132,13 @@ export const networkIsolationFixture = base.extend<{
restore()
},
context: async (
{ context, baseURL, networkPolicy, liveCloudBillingConfig },
{
context,
baseURL,
networkPolicy,
liveCloudBillingConfig,
liveNetworkOrigins
},
use
) => {
const { origins, unexpected } = networkPolicy
Expand Down Expand Up @@ -151,6 +166,11 @@ export const networkIsolationFixture = base.extend<{
await socket.close()
}
)
if (liveNetworkOrigins.length > 0) {
await use(context)
restore()
return
}
await context.route('https://huggingface.co/**/resolve/**', (route) =>
route.request().method() === 'HEAD'
? route.fulfill({ status: 200, body: '' })
Expand Down
12 changes: 10 additions & 2 deletions browser_tests/playwrightSelection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Live billing opt-in', () => {
{
name: 'disabled',
enabled: '0',
args: ['tests/liveCloud'],
args: [],
status: 1,
count: 0,
hooks: true
Expand All @@ -35,7 +35,15 @@ describe('Live billing opt-in', () => {
({ enabled, args, status, count, hooks }) => {
const result = spawnSync(
'pnpm',
['exec', 'playwright', 'test', ...args, '--list', '--reporter=json'],
[
'exec',
'playwright',
'test',
'tests/liveCloud/billingSmoke.spec.ts',
...args,
'--list',
'--reporter=json'
],
{
cwd: process.cwd(),
env: {
Expand Down
61 changes: 61 additions & 0 deletions browser_tests/tests/liveCloud/openOnCloud.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { expect } from '@playwright/test'

import { zCloudCompatibility } from '@comfyorg/ingest-types/zod'
import { liveOpenOnCloudFixture as test } from '@e2e/fixtures/liveOpenOnCloudFixture'

test.describe(
'Open on Cloud live compatibility',
{ tag: ['@cloud-live', '@smoke', '@ui'] },
() => {
test('offers to open a workflow that Cloud can run', async ({
comfyPage,
cloudOrigin
}) => {
await test.step('Load the runnable workflow', async () => {
await comfyPage.workflow.loadWorkflow(
'openOnCloud/01-runnable-on-cloud'
)
})

await test.step('Check compatibility against the real Cloud server', async () => {
const responsePromise = comfyPage.page.waitForResponse(
(response) =>
new URL(response.url()).pathname === '/api/cloud/compatibility' &&
response.request().method() === 'POST'
)
await comfyPage.page.getByTestId('cloud-button').click()
const response = await responsePromise

expect(new URL(response.url()).origin).toBe(cloudOrigin)
expect(response.status()).toBe(200)
expect(await response.serverAddr()).not.toBeNull()
const compatibility = zCloudCompatibility.parse(await response.json())
expect(compatibility.cloud.missing_node_types).toEqual([])
expect(compatibility.cloud.missing_models).toEqual([])
})

await test.step('Offer Cloud execution with the signed-out explanation', async () => {
await expect(
comfyPage.page.getByRole('heading', {
name: 'Run on Comfy Cloud',
exact: true
})
).toBeVisible()
await expect(
comfyPage.page.getByRole('button', {
name: 'Open on Comfy Cloud',
exact: true
})
).toBeVisible()
await expect(
comfyPage.page.getByText('Comfy Cloud will ask you to sign in.', {
exact: true
})
).toBeVisible()
await comfyPage.attachScreenshot('runnable-on-cloud.png', {
runInCI: true
})
})
})
}
)
45 changes: 45 additions & 0 deletions browser_tests/tests/openOnCloudGate.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { Request } from '@playwright/test'
import { expect } from '@playwright/test'

import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'

function isOpenOnCloudTraffic(request: Request): boolean {
const url = new URL(request.url())
return (
url.pathname.endsWith('/api/cloud/compatibility') ||
decodeURIComponent(url.pathname).includes('/userdata/open-on-cloud/')
)
}

test.describe('Open on Cloud gate', { tag: ['@ui'] }, () => {
test('boots, loads and hovers the top menu without any Open on Cloud surface or traffic while the gate is off', async ({
comfyPage
}) => {
await comfyPage.featureFlags.seedServerFlags({
open_on_cloud_enabled: false
})
const traffic: string[] = []
comfyPage.page.on('request', (request) => {
if (isOpenOnCloudTraffic(request)) traffic.push(request.url())
})

await comfyPage.workflow.reloadAndWaitForApp()
await comfyPage.workflow.loadWorkflow('openOnCloud/01-runnable-on-cloud')
await comfyPage.page.getByTestId('top-menu-actionbars').hover()

await expect(comfyPage.page.getByTestId('cloud-button')).toHaveCount(0)
expect(traffic).toEqual([])
})

test('shows the Cloud button while the gate is on, proving the gate-off check looks at the right control', async ({
comfyPage
}) => {
await comfyPage.featureFlags.seedServerFlags({
open_on_cloud_enabled: true
})

await comfyPage.workflow.reloadAndWaitForApp()

await expect(comfyPage.page.getByTestId('cloud-button')).toBeVisible()
})
})
Loading
Loading