|
| 1 | +import { selectSlimSelect, waitModalClosed, waitPageLoading } from '../utils.js'; |
| 2 | +import { createImage } from './image_utils.js'; |
| 3 | +import { expect, test } from './workflow_fixture.js'; |
| 4 | + |
| 5 | +test('Image list visibility in run workflow modal', async ({ page, workflow }) => { |
| 6 | + await page.waitForURL(workflow.url); |
| 7 | + await waitPageLoading(page); |
| 8 | + |
| 9 | + await page.goto(`/v2/projects/${workflow.projectId}`); |
| 10 | + await waitPageLoading(page); |
| 11 | + |
| 12 | + const modal = page.locator('.modal.show'); |
| 13 | + const randomPath = `/tmp/${Math.random().toString(36).substring(7)}`; |
| 14 | + |
| 15 | + await test.step('Create test dataset', async () => { |
| 16 | + const createDatasetButton = page.getByRole('button', { name: 'Create new dataset' }); |
| 17 | + await createDatasetButton.click(); |
| 18 | + await modal.waitFor(); |
| 19 | + await modal.getByRole('textbox', { name: 'Dataset Name' }).fill('test-dataset'); |
| 20 | + await modal.getByRole('textbox', { name: 'Zarr dir' }).fill(randomPath); |
| 21 | + await modal.getByRole('button', { name: 'Save' }).click(); |
| 22 | + await waitModalClosed(page); |
| 23 | + }); |
| 24 | + |
| 25 | + await test.step('Open workflow page and verify that image list is not displayed', async () => { |
| 26 | + await page.goto(workflow.url); |
| 27 | + await waitPageLoading(page); |
| 28 | + await workflow.addTask('generic_task'); |
| 29 | + await page.getByRole('button', { name: 'Run workflow' }).click(); |
| 30 | + await modal.waitFor(); |
| 31 | + await expect(modal.getByText('Image list')).not.toBeVisible(); |
| 32 | + }); |
| 33 | + |
| 34 | + await test.step('Add images to the dataset', async () => { |
| 35 | + await page.goto(`/v2/projects/${workflow.projectId}`); |
| 36 | + await waitPageLoading(page); |
| 37 | + await page.getByRole('link', { name: 'test-dataset' }).click(); |
| 38 | + await waitPageLoading(page); |
| 39 | + await createImage(page, `${randomPath}/img1`, { a1: 'v1' }); |
| 40 | + await createImage(page, `${randomPath}/img2`, { a2: 'v2' }); |
| 41 | + }); |
| 42 | + |
| 43 | + await test.step('Add dataset filters that exclude all images', async () => { |
| 44 | + await page.getByText('Current selection').click(); |
| 45 | + await expect(page.getByText(/Total results: 2/)).toBeVisible(); |
| 46 | + await selectSlimSelect(page, page.getByLabel('Selector for attribute a1'), 'v1'); |
| 47 | + await page.getByRole('button', { name: 'Apply' }).click(); |
| 48 | + await selectSlimSelect(page, page.getByLabel('Selector for attribute a2'), 'v2'); |
| 49 | + await page.getByRole('button', { name: 'Apply' }).click(); |
| 50 | + await expect(page.getByText(/Total results: 0/)).toBeVisible(); |
| 51 | + await page.getByRole('button', { name: 'Save' }).click(); |
| 52 | + await modal.getByRole('button', { name: 'Confirm' }).click(); |
| 53 | + await waitModalClosed(page); |
| 54 | + await expect(page.getByRole('button', { name: 'Save' })).toBeDisabled(); |
| 55 | + }); |
| 56 | + |
| 57 | + await test.step('Open workflow page and verify that image list is displayed and table is empty', async () => { |
| 58 | + await page.goto(workflow.url); |
| 59 | + await waitPageLoading(page); |
| 60 | + await page.getByRole('button', { name: 'Run workflow' }).click(); |
| 61 | + await modal.waitFor(); |
| 62 | + await expect(modal.getByRole('button', { name: 'Image list' })).toBeVisible(); |
| 63 | + await modal.getByRole('button', { name: 'Image list' }).click(); |
| 64 | + await expect(modal.getByText(/Total results: 0/)).toBeVisible(); |
| 65 | + }); |
| 66 | + |
| 67 | + await test.step('Deselect filter and check result', async () => { |
| 68 | + await modal.locator('.ss-deselect').first().click(); |
| 69 | + await modal.getByRole('button', { name: 'Apply' }).click(); |
| 70 | + await expect(modal.getByText(/Total results: 1/)).toBeVisible(); |
| 71 | + }); |
| 72 | +}); |
0 commit comments