|
| 1 | +import { expect } from '@playwright/test' |
| 2 | + |
| 3 | +import { SystemStats } from '../../src/schemas/apiSchema' |
| 4 | +import { comfyPageFixture as test } from '../fixtures/ComfyPage' |
| 5 | + |
| 6 | +test.describe('Version Mismatch Warnings', () => { |
| 7 | + const ALWAYS_AHEAD_OF_INSTALLED_VERSION = '100.100.100' |
| 8 | + const ALWAYS_BEHIND_INSTALLED_VERSION = '0.0.0' |
| 9 | + |
| 10 | + const createMockSystemStatsRes = ( |
| 11 | + requiredFrontendVersion: string |
| 12 | + ): SystemStats => { |
| 13 | + return { |
| 14 | + system: { |
| 15 | + os: 'posix', |
| 16 | + ram_total: 67235385344, |
| 17 | + ram_free: 13464207360, |
| 18 | + comfyui_version: '0.3.46', |
| 19 | + required_frontend_version: requiredFrontendVersion, |
| 20 | + python_version: '3.12.3 (main, Jun 18 2025, 17:59:45) [GCC 13.3.0]', |
| 21 | + pytorch_version: '2.6.0+cu124', |
| 22 | + embedded_python: false, |
| 23 | + argv: ['main.py'] |
| 24 | + }, |
| 25 | + devices: [ |
| 26 | + { |
| 27 | + name: 'cuda:0 NVIDIA GeForce RTX 4070 : cudaMallocAsync', |
| 28 | + type: 'cuda', |
| 29 | + index: 0, |
| 30 | + vram_total: 12557156352, |
| 31 | + vram_free: 2439249920, |
| 32 | + torch_vram_total: 0, |
| 33 | + torch_vram_free: 0 |
| 34 | + } |
| 35 | + ] |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + test.beforeEach(async ({ comfyPage }) => { |
| 40 | + await comfyPage.setSetting('Comfy.UseNewMenu', 'Top') |
| 41 | + }) |
| 42 | + |
| 43 | + test('should show version mismatch warnings when installed version lower than required', async ({ |
| 44 | + comfyPage |
| 45 | + }) => { |
| 46 | + // Mock system_stats route to indicate that the installed version is always ahead of the required version |
| 47 | + await comfyPage.page.route('**/system_stats**', async (route) => { |
| 48 | + await route.fulfill({ |
| 49 | + status: 200, |
| 50 | + contentType: 'application/json', |
| 51 | + body: JSON.stringify( |
| 52 | + createMockSystemStatsRes(ALWAYS_AHEAD_OF_INSTALLED_VERSION) |
| 53 | + ) |
| 54 | + }) |
| 55 | + }) |
| 56 | + await comfyPage.setup() |
| 57 | + |
| 58 | + // Expect a warning toast to be shown |
| 59 | + await expect( |
| 60 | + comfyPage.page.getByText('Version Compatibility Warning') |
| 61 | + ).toBeVisible() |
| 62 | + }) |
| 63 | + |
| 64 | + test('should not show version mismatch warnings when installed version is ahead of required', async ({ |
| 65 | + comfyPage |
| 66 | + }) => { |
| 67 | + // Mock system_stats route to indicate that the installed version is always ahead of the required version |
| 68 | + await comfyPage.page.route('**/system_stats**', async (route) => { |
| 69 | + await route.fulfill({ |
| 70 | + status: 200, |
| 71 | + contentType: 'application/json', |
| 72 | + body: JSON.stringify( |
| 73 | + createMockSystemStatsRes(ALWAYS_BEHIND_INSTALLED_VERSION) |
| 74 | + ) |
| 75 | + }) |
| 76 | + }) |
| 77 | + await comfyPage.setup() |
| 78 | + |
| 79 | + // Expect no warning toast to be shown |
| 80 | + await expect( |
| 81 | + comfyPage.page.getByText('Version Compatibility Warning') |
| 82 | + ).not.toBeVisible() |
| 83 | + }) |
| 84 | + |
| 85 | + test('should persist dismissed state across sessions', async ({ |
| 86 | + comfyPage |
| 87 | + }) => { |
| 88 | + // Mock system_stats route to indicate that the installed version is always ahead of the required version |
| 89 | + await comfyPage.page.route('**/system_stats**', async (route) => { |
| 90 | + await route.fulfill({ |
| 91 | + status: 200, |
| 92 | + contentType: 'application/json', |
| 93 | + body: JSON.stringify( |
| 94 | + createMockSystemStatsRes(ALWAYS_AHEAD_OF_INSTALLED_VERSION) |
| 95 | + ) |
| 96 | + }) |
| 97 | + }) |
| 98 | + await comfyPage.setup() |
| 99 | + |
| 100 | + // Locate the warning toast and dismiss it |
| 101 | + const warningToast = comfyPage.page |
| 102 | + .locator('div') |
| 103 | + .filter({ hasText: 'Version Compatibility' }) |
| 104 | + .nth(3) |
| 105 | + await warningToast.waitFor({ state: 'visible' }) |
| 106 | + const dismissButton = warningToast.getByRole('button', { name: 'Close' }) |
| 107 | + await dismissButton.click() |
| 108 | + |
| 109 | + // Reload the page, keeping local storage |
| 110 | + await comfyPage.setup({ clearStorage: false }) |
| 111 | + |
| 112 | + // The same warning from same versions should not be shown to the user again |
| 113 | + await expect( |
| 114 | + comfyPage.page.getByText('Version Compatibility Warning') |
| 115 | + ).not.toBeVisible() |
| 116 | + }) |
| 117 | +}) |
0 commit comments