|
1 | 1 | import { expect, mergeTests } from '@playwright/test' |
2 | | -import type { Page } from '@playwright/test' |
| 2 | +import type { Page, Response } from '@playwright/test' |
3 | 3 |
|
4 | 4 | import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' |
| 5 | +import { expectNoErrorUiAfterVerification } from '@e2e/fixtures/helpers/ErrorsTabHelper' |
5 | 6 | import { |
6 | 7 | createRouteMockJob, |
| 8 | + JobsRouteMocker, |
7 | 9 | jobsRouteFixture, |
8 | 10 | routeMockJobTimestamp |
9 | 11 | } from '@e2e/fixtures/jobsRouteFixture' |
| 12 | +import { TestIds } from '@e2e/fixtures/selectors' |
| 13 | +import { PropertiesPanelHelper } from '@e2e/tests/propertiesPanel/PropertiesPanelHelper' |
10 | 14 | import type { |
11 | 15 | JobDetail, |
12 | 16 | RawJobListItem |
@@ -145,6 +149,27 @@ async function mockViewFiles(page: Page, filesByName: ViewFilesByName) { |
145 | 149 | }) |
146 | 150 | } |
147 | 151 |
|
| 152 | +function isGeneratedAssetVerificationResponse(response: Response): boolean { |
| 153 | + const url = new URL(response.url()) |
| 154 | + return ( |
| 155 | + response.request().method().toUpperCase() === 'GET' && |
| 156 | + response.status() === 200 && |
| 157 | + url.pathname.endsWith('/api/jobs') && |
| 158 | + url.searchParams.get('status')?.split(',').includes('completed') === true |
| 159 | + ) |
| 160 | +} |
| 161 | + |
| 162 | +const bulkInsertionTest = comfyPageFixture.extend({ |
| 163 | + page: async ({ page }, use) => { |
| 164 | + const jobsRoutes = new JobsRouteMocker(page) |
| 165 | + await jobsRoutes.mockJobsQueue([]) |
| 166 | + await jobsRoutes.mockJobsHistory(generatedJobs) |
| 167 | + await mockInputFiles(page, []) |
| 168 | + await mockViewFiles(page, viewFiles) |
| 169 | + await use(page) |
| 170 | + } |
| 171 | +}) |
| 172 | + |
148 | 173 | test.describe('FE-130 assets sidebar route mocks', () => { |
149 | 174 | test.beforeEach(async ({ jobsRoutes, page }) => { |
150 | 175 | await jobsRoutes.mockJobsQueue([]) |
@@ -284,6 +309,68 @@ test.describe('FE-130 assets sidebar route mocks', () => { |
284 | 309 | }) |
285 | 310 | }) |
286 | 311 |
|
| 312 | +bulkInsertionTest.describe( |
| 313 | + 'Assets sidebar - bulk insert as nodes', |
| 314 | + { tag: ['@vue-nodes', '@ui', '@node', '@widget'] }, |
| 315 | + () => { |
| 316 | + bulkInsertionTest.use({ |
| 317 | + initialSettings: { |
| 318 | + 'Comfy.RightSidePanel.ShowErrorsTab': true |
| 319 | + } |
| 320 | + }) |
| 321 | + |
| 322 | + bulkInsertionTest.beforeEach(async ({ comfyPage }) => { |
| 323 | + await comfyPage.command.executeCommand('Comfy.NewBlankWorkflow') |
| 324 | + await expect.poll(() => comfyPage.nodeOps.getGraphNodesCount()).toBe(0) |
| 325 | + await comfyPage.toast.closeToasts() |
| 326 | + const panel = new PropertiesPanelHelper(comfyPage.page) |
| 327 | + await panel.open(comfyPage.actionbar.propertiesButton) |
| 328 | + await expect( |
| 329 | + comfyPage.page.getByTestId(TestIds.dialogs.errorOverlay) |
| 330 | + ).toBeHidden() |
| 331 | + await expect(panel.errorsTab).toBeHidden() |
| 332 | + |
| 333 | + const tab = comfyPage.menu.assetsTab |
| 334 | + await tab.open() |
| 335 | + await expect(tab.assetCards).toHaveCount(2) |
| 336 | + }) |
| 337 | + |
| 338 | + bulkInsertionTest( |
| 339 | + 'does not surface errors for inserted output assets', |
| 340 | + async ({ comfyPage }) => { |
| 341 | + const tab = comfyPage.menu.assetsTab |
| 342 | + const panel = new PropertiesPanelHelper(comfyPage.page) |
| 343 | + await expect(panel.root).toBeVisible() |
| 344 | + |
| 345 | + await tab.getAssetCardByName('alpha').click() |
| 346 | + await comfyPage.page.keyboard.down('ControlOrMeta') |
| 347 | + await tab.getAssetCardByName('beta').click() |
| 348 | + await comfyPage.page.keyboard.up('ControlOrMeta') |
| 349 | + await expect(tab.selectedCards).toHaveCount(2) |
| 350 | + |
| 351 | + const generatedAssetVerificationResponse = |
| 352 | + comfyPage.page.waitForResponse(isGeneratedAssetVerificationResponse) |
| 353 | + |
| 354 | + await tab.getAssetCardByName('alpha').dispatchEvent('contextmenu', { |
| 355 | + bubbles: true, |
| 356 | + cancelable: true, |
| 357 | + button: 2 |
| 358 | + }) |
| 359 | + await expect(comfyPage.contextMenu.primeVueMenu).toBeVisible() |
| 360 | + await tab.contextMenuItem('Insert all assets as nodes').click() |
| 361 | + |
| 362 | + await expect.poll(() => comfyPage.vueNodes.getNodeCount()).toBe(2) |
| 363 | + |
| 364 | + await expectNoErrorUiAfterVerification( |
| 365 | + comfyPage, |
| 366 | + panel, |
| 367 | + generatedAssetVerificationResponse |
| 368 | + ) |
| 369 | + } |
| 370 | + ) |
| 371 | + } |
| 372 | +) |
| 373 | + |
287 | 374 | test.describe('FE-910 marquee selection and select all', () => { |
288 | 375 | test.beforeEach(async ({ jobsRoutes, page, comfyPage }) => { |
289 | 376 | await jobsRoutes.mockJobsQueue([]) |
|
0 commit comments