Skip to content
314 changes: 314 additions & 0 deletions browser_tests/assets/widgets/linked_core_media.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
{
"id": "6db64321-d1c9-4bb5-b6d4-e08b60531fc6",
"revision": 0,
"last_node_id": 10,
"last_link_id": 5,
"nodes": [
{
"id": 1,
"type": "PrimitiveNode",
"pos": [20, 20],
"size": [250, 82],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "COMBO",
"type": "COMBO",
"widget": {
"name": "image"
},
"links": [1]
}
],
"title": "image",
"properties": {
"Run widget replace on values": false
},
"widgets_values": ["linked-image.webp [output]", "fixed"]
},
{
"id": 2,
"type": "PrimitiveNode",
"pos": [20, 380],
"size": [250, 82],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "COMBO",
"type": "COMBO",
"widget": {
"name": "file"
},
"links": [2]
}
],
"title": "file",
"properties": {
"Run widget replace on values": false
},
"widgets_values": ["linked-video.mp4", "fixed"]
},
{
"id": 3,
"type": "PrimitiveNode",
"pos": [20, 740],
"size": [250, 82],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "COMBO",
"type": "COMBO",
"widget": {
"name": "audio"
},
"links": [3]
}
],
"title": "audio",
"properties": {
"Run widget replace on values": false
},
"widgets_values": ["linked-audio.wav", "fixed"]
},
{
"id": 4,
"type": "LoadImage",
"pos": [360, 20],
"size": [315, 314],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "COMBO",
"widget": {
"name": "image"
},
"link": 1
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": null
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": ["linked-image.webp", "image"]
},
{
"id": 5,
"type": "LoadVideo",
"pos": [360, 380],
"size": [315, 314],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "file",
"type": "COMBO",
"widget": {
"name": "file"
},
"link": 2
}
],
"outputs": [
{
"name": "VIDEO",
"type": "VIDEO",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadVideo"
},
"widgets_values": ["linked-video.mp4", "image"]
},
{
"id": 6,
"type": "LoadAudio",
"pos": [360, 740],
"size": [315, 125],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "audio",
"type": "COMBO",
"widget": {
"name": "audio"
},
"link": 3
}
],
"outputs": [
{
"name": "AUDIO",
"type": "AUDIO",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadAudio"
},
"widgets_values": ["linked-audio.wav", null, ""]
},
{
"id": 7,
"type": "PrimitiveNode",
"pos": [720, 20],
"size": [250, 82],
"flags": {},
"order": 6,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "COMBO",
"type": "COMBO",
"widget": {
"name": "image"
},
"links": [4]
}
],
"title": "mask image",
"properties": {
"Run widget replace on values": false
},
"widgets_values": ["linked-image.webp", "fixed"]
},
{
"id": 8,
"type": "PrimitiveNode",
"pos": [720, 380],
"size": [250, 82],
"flags": {},
"order": 7,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "COMBO",
"type": "COMBO",
"widget": {
"name": "image"
},
"links": [5]
}
],
"title": "output image",
"properties": {
"Run widget replace on values": false
},
"widgets_values": ["linked-image.webp", "fixed"]
},
{
"id": 9,
"type": "LoadImageMask",
"pos": [1060, 20],
"size": [315, 314],
"flags": {},
"order": 8,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "COMBO",
"widget": {
"name": "image"
},
"link": 4
}
],
"outputs": [
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImageMask"
},
"widgets_values": ["linked-image.webp", "alpha", "image"]
},
{
"id": 10,
"type": "LoadImageOutput",
"pos": [1060, 380],
"size": [315, 314],
"flags": {},
"order": 9,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "COMBO",
"widget": {
"name": "image"
},
"link": 5
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": null
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImageOutput"
},
"widgets_values": [
"linked-image.webp [output]",
false,
"refresh",
"image"
]
}
],
"links": [
[1, 1, 0, 4, 0, "COMBO"],
[2, 2, 0, 5, 0, "COMBO"],
[3, 3, 0, 6, 0, "COMBO"],
[4, 7, 0, 9, 0, "COMBO"],
[5, 8, 0, 10, 0, "COMBO"]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.8,
"offset": [0, 0]
}
},
"version": 0.4
}
48 changes: 48 additions & 0 deletions browser_tests/fixtures/utils/viewFileMocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { Page, Route } from '@playwright/test'

type RouteFulfillOptions = NonNullable<Parameters<Route['fulfill']>[0]>

type ViewFile = Pick<RouteFulfillOptions, 'body' | 'contentType' | 'path'>

const transparentPng = Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAFgwJ/lwPIRwAAAABJRU5ErkJggg==',
'base64'
)

export async function mockViewFiles(
page: Page,
filesByName: Readonly<Record<string, ViewFile>>
) {
await page.route('**/api/view**', async (route) => {
if (route.request().method().toUpperCase() !== 'GET') {
await route.fallback()
return
}

const filename = new URL(route.request().url()).searchParams.get('filename')
if (!filename) {
await route.fulfill({
status: 400,
json: { error: 'Missing filename' } satisfies { error: string }
})
return
}

const file = filesByName[filename]
if (!file) {
await route.fulfill({
status: 404,
json: {
error: `Unknown filename: ${filename}`
} satisfies { error: string }
})
return
}

await route.fulfill({
body: file.body ?? (file.path ? undefined : transparentPng),
contentType: file.contentType ?? 'image/png',
path: file.path
})
})
}
Loading
Loading