diff --git a/browser_tests/assets/missing_models.json b/browser_tests/assets/missing_models.json new file mode 100644 index 00000000..aece2f53 --- /dev/null +++ b/browser_tests/assets/missing_models.json @@ -0,0 +1,25 @@ +{ + "last_node_id": 0, + "last_link_id": 0, + "nodes": [], + "links": [], + "groups": [], + "config": {}, + "extra": { + "ds": { + "scale": 1, + "offset": [ + 0, + 0 + ] + } + }, + "models": [ + { + "name": "fake_model.safetensors", + "url": "http://localhost:8188/api/devtools/fake_model.safetensors", + "directory": "clip" + } + ], + "version": 0.4 +} \ No newline at end of file diff --git a/browser_tests/dialog.spec.ts b/browser_tests/dialog.spec.ts index 2d5ebf49..4ab1d755 100644 --- a/browser_tests/dialog.spec.ts +++ b/browser_tests/dialog.spec.ts @@ -25,3 +25,35 @@ test.describe('Execution error', () => { await expect(executionError).toBeVisible() }) }) + +test.describe('Missing models warning', () => { + test.beforeEach(async ({ comfyPage }) => { + await comfyPage.setSetting('Comfy.Workflow.ModelDownload.AllowedSources', [ + 'http://localhost:8188' + ]) + await comfyPage.setSetting('Comfy.Workflow.ModelDownload.AllowedSuffixes', [ + '.safetensors' + ]) + }) + + test('Should display a warning when missing models are found', async ({ + comfyPage + }) => { + // The fake_model.safetensors is served by + // https://github.com/Comfy-Org/ComfyUI_devtools/blob/main/__init__.py + await comfyPage.loadWorkflow('missing_models') + + // Wait for the element with the .comfy-missing-models selector to be visible + const missingModelsWarning = comfyPage.page.locator('.comfy-missing-models') + await expect(missingModelsWarning).toBeVisible() + + // Click the download button + const downloadButton = comfyPage.page.getByLabel('Download') + await expect(downloadButton).toBeVisible() + await downloadButton.click() + + // Wait for the element with the .download-complete selector to be visible + const downloadComplete = comfyPage.page.locator('.download-complete') + await expect(downloadComplete).toBeVisible() + }) +}) diff --git a/src/components/dialog/content/MissingModelsWarning.vue b/src/components/dialog/content/MissingModelsWarning.vue index c3f32a24..78541a86 100644 --- a/src/components/dialog/content/MissingModelsWarning.vue +++ b/src/components/dialog/content/MissingModelsWarning.vue @@ -14,28 +14,42 @@ }" >