From 6edfc9bc1be3563a0d989223cdd8e651967ffd03 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Wed, 21 Aug 2024 11:42:12 -0400 Subject: [PATCH] Use settingStore to access setting (#572) --- browser_tests/assets/missing_nodes.json | 61 +++++++++++++++++++++++ browser_tests/interaction.spec.ts | 10 ++-- browser_tests/loadWorkflowWarning.spec.ts | 14 ++++++ src/scripts/app.ts | 10 ++-- 4 files changed, 85 insertions(+), 10 deletions(-) create mode 100644 browser_tests/assets/missing_nodes.json create mode 100644 browser_tests/loadWorkflowWarning.spec.ts diff --git a/browser_tests/assets/missing_nodes.json b/browser_tests/assets/missing_nodes.json new file mode 100644 index 000000000..cc584de6a --- /dev/null +++ b/browser_tests/assets/missing_nodes.json @@ -0,0 +1,61 @@ +{ + "last_node_id": 1, + "last_link_id": 0, + "nodes": [ + { + "id": 1, + "type": "UNKNOWN NODE", + "pos": [ + 48, + 86 + ], + "size": { + "0": 358.80780029296875, + "1": 314.7989501953125 + }, + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [ + { + "name": "image", + "type": "IMAGE", + "link": null, + "slot_index": 0 + } + ], + "outputs": [ + { + "name": "STRING", + "type": "STRING", + "links": [], + "slot_index": 0, + "shape": 6 + } + ], + "properties": { + "Node name for S&R": "UNKNOWN NODE" + }, + "widgets_values": [ + "wd-v1-4-moat-tagger-v2", + 0.35, + 0.85, + false, + false, + "" + ] + } + ], + "links": [], + "groups": [], + "config": {}, + "extra": { + "ds": { + "scale": 1, + "offset": [ + 0, 0 + ] + } + }, + "version": 0.4 +} \ No newline at end of file diff --git a/browser_tests/interaction.spec.ts b/browser_tests/interaction.spec.ts index ae1f17e52..a06475e8a 100644 --- a/browser_tests/interaction.spec.ts +++ b/browser_tests/interaction.spec.ts @@ -1,5 +1,5 @@ import { expect } from '@playwright/test' -import { ComfyPage, comfyPageFixture as test } from './ComfyPage' +import { comfyPageFixture as test } from './ComfyPage' test.describe('Node Interaction', () => { test('Can enter prompt', async ({ comfyPage }) => { @@ -104,10 +104,14 @@ test.describe('Node Interaction', () => { test('Can toggle dom widget node open/closed', async ({ comfyPage }) => { await expect(comfyPage.canvas).toHaveScreenshot('default.png') await comfyPage.clickTextEncodeNodeToggler() - await expect(comfyPage.canvas).toHaveScreenshot('text-encode-toggled-off.png') + await expect(comfyPage.canvas).toHaveScreenshot( + 'text-encode-toggled-off.png' + ) await comfyPage.delay(1000) await comfyPage.clickTextEncodeNodeToggler() - await expect(comfyPage.canvas).toHaveScreenshot('text-encode-toggled-back-open.png') + await expect(comfyPage.canvas).toHaveScreenshot( + 'text-encode-toggled-back-open.png' + ) }) }) diff --git a/browser_tests/loadWorkflowWarning.spec.ts b/browser_tests/loadWorkflowWarning.spec.ts new file mode 100644 index 000000000..6c9131c6f --- /dev/null +++ b/browser_tests/loadWorkflowWarning.spec.ts @@ -0,0 +1,14 @@ +import { expect } from '@playwright/test' +import { comfyPageFixture as test } from './ComfyPage' + +test.describe('Load workflow warning', () => { + test('Should display a warning when loading a workflow with missing nodes', async ({ + comfyPage + }) => { + await comfyPage.loadWorkflow('missing_nodes') + + // Wait for the element with the .comfy-missing-nodes selector to be visible + const missingNodesWarning = comfyPage.page.locator('.comfy-missing-nodes') + await expect(missingNodesWarning).toBeVisible() + }) +}) diff --git a/src/scripts/app.ts b/src/scripts/app.ts index a6dfa1a4f..a007fb649 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -2158,13 +2158,9 @@ export class ComfyApp { showMissingNodesError(missingNodeTypes, hasAddedNodes = true) { if ( - !this.ui.settings.getSettingValue( - 'Comfy.Workflow.ShowMissingNodesWarning' - ) - ) - return - - if (this.vueAppReady) { + this.vueAppReady && + useSettingStore().get('Comfy.Workflow.ShowMissingNodesWarning') + ) { showLoadWorkflowWarning({ missingNodeTypes, hasAddedNodes,