|
| 1 | +import { expect, test } from './workflow_fixture.js'; |
| 2 | +import { selectSlimSelect, waitModalClosed, waitPageLoading } from '../utils.js'; |
| 3 | +import { createDataset } from './dataset_utils.js'; |
| 4 | +import { waitTaskFailure, waitTasksSuccess } from './workflow_task_utils.js'; |
| 5 | + |
| 6 | +test('Workflow subsets', async ({ page, workflow }) => { |
| 7 | + await page.waitForURL(workflow.url); |
| 8 | + await waitPageLoading(page); |
| 9 | + |
| 10 | + test.slow(); |
| 11 | + const modal = page.locator('.modal.show'); |
| 12 | + |
| 13 | + /** @type {string} */ |
| 14 | + let zarrDir; |
| 15 | + await test.step('Create test dataset', async () => { |
| 16 | + const dataset = await createDataset(page, workflow.projectId); |
| 17 | + zarrDir = dataset.zarrDir; |
| 18 | + }); |
| 19 | + |
| 20 | + await test.step('Open workflow page and configure tasks', async () => { |
| 21 | + await page.goto(workflow.url); |
| 22 | + await waitPageLoading(page); |
| 23 | + await workflow.addTask('create_ome_zarr_compound'); |
| 24 | + await workflow.selectTask('create_ome_zarr_compound'); |
| 25 | + await page.getByRole('textbox', { name: 'Image Dir' }).fill(zarrDir); |
| 26 | + await page.getByRole('spinbutton', { name: 'Num Images' }).fill('15'); |
| 27 | + await workflow.addTask('illumination_correction'); |
| 28 | + await workflow.addTask('cellpose_segmentation'); |
| 29 | + await page.getByRole('button', { name: 'Save changes' }).click(); |
| 30 | + await expect(page.getByRole('button', { name: 'Save changes' })).toBeDisabled(); |
| 31 | + }); |
| 32 | + |
| 33 | + await test.step('Add meta properties', async () => { |
| 34 | + await workflow.selectTask('cellpose_segmentation'); |
| 35 | + await page.getByRole('button', { name: 'Meta', exact: true }).click(); |
| 36 | + await page.getByRole('button', { name: 'Add property' }).click(); |
| 37 | + await page.getByPlaceholder('Argument name').fill('k1'); |
| 38 | + await page.getByPlaceholder('Argument value').fill('v1'); |
| 39 | + await page.getByRole('button', { name: 'Save changes' }).click(); |
| 40 | + await expect(page.getByRole('button', { name: 'Save changes' })).toBeDisabled(); |
| 41 | + }); |
| 42 | + |
| 43 | + await test.step('Run workflow', async () => { |
| 44 | + await page.getByRole('button', { name: 'Run workflow' }).click(); |
| 45 | + await modal.waitFor(); |
| 46 | + await modal.getByRole('button', { name: 'Run' }).click(); |
| 47 | + await modal.getByRole('button', { name: 'Confirm' }).click(); |
| 48 | + await waitModalClosed(page); |
| 49 | + await waitTasksSuccess(page); |
| 50 | + }); |
| 51 | + |
| 52 | + await test.step('Open logs modal', async () => { |
| 53 | + await page.locator('[aria-label="Done images"]').last().click(); |
| 54 | + await modal.waitFor(); |
| 55 | + await expect(modal.getByText("Images with status='done'")).toBeVisible(); |
| 56 | + await expect(modal.getByText('Total results: 15')).toBeVisible(); |
| 57 | + await modal.getByRole('button', { name: '2' }).click(); |
| 58 | + await expect(modal.getByRole('row')).toHaveCount(5); |
| 59 | + await modal.getByRole('button', { name: 'Logs' }).last().click(); |
| 60 | + await expect(modal.getByText('START cellpose_segmentation task')).toBeVisible(); |
| 61 | + await modal.getByRole('button', { name: 'Back' }).click(); |
| 62 | + await expect(modal.getByRole('row')).toHaveCount(5); |
| 63 | + await modal.getByRole('button', { name: 'Close' }).click(); |
| 64 | + await waitModalClosed(page); |
| 65 | + }); |
| 66 | + |
| 67 | + await test.step('Update meta properties', async () => { |
| 68 | + await page.getByRole('button', { name: 'Meta', exact: true }).click(); |
| 69 | + await page.getByPlaceholder('Argument name').fill('k2'); |
| 70 | + await page.getByPlaceholder('Argument value').fill('v2'); |
| 71 | + await page.getByRole('button', { name: 'Save changes' }).click(); |
| 72 | + await expect(page.getByRole('button', { name: 'Save changes' })).toBeDisabled(); |
| 73 | + }); |
| 74 | + |
| 75 | + await test.step('Continue workflow', async () => { |
| 76 | + await page.getByRole('button', { name: 'Continue workflow' }).click(); |
| 77 | + await modal.waitFor(); |
| 78 | + await modal.getByRole('combobox', { name: 'First task' }).selectOption('cellpose_segmentation'); |
| 79 | + await modal.getByRole('button', { name: 'Image list' }).click(); |
| 80 | + await selectSlimSelect(page, page.getByLabel('Selector for attribute well'), 'A02'); |
| 81 | + await modal.getByRole('button', { name: 'Apply' }).click(); |
| 82 | + await expect(modal.getByRole('button', { name: 'Apply' })).toBeDisabled(); |
| 83 | + await modal.getByRole('button', { name: 'Run' }).click(); |
| 84 | + await expect(modal.getByText('This job will process 1 image')).toBeVisible(); |
| 85 | + await modal.getByRole('button', { name: 'Confirm' }).click(); |
| 86 | + await waitModalClosed(page); |
| 87 | + await waitTasksSuccess(page); |
| 88 | + }); |
| 89 | + |
| 90 | + await test.step('Open subsets of last task and check meta', async () => { |
| 91 | + await page.getByRole('button', { name: 'Meta', exact: true }).click(); |
| 92 | + await expect(page.getByPlaceholder('Argument name')).toHaveValue('k2'); |
| 93 | + await expect(page.getByPlaceholder('Argument value')).toHaveValue('v2'); |
| 94 | + await expect(page.getByRole('button', { name: 'Add property' })).toBeEnabled(); |
| 95 | + await page.locator('[aria-label="Show subsets"]').last().click(); |
| 96 | + await page.getByRole('button', { name: 'Subset 1' }).click(); |
| 97 | + await expect(page.getByPlaceholder('Argument name')).toHaveValue('k1'); |
| 98 | + await expect(page.getByPlaceholder('Argument value')).toHaveValue('v1'); |
| 99 | + await expect(page.getByRole('button', { name: 'Add property' })).not.toBeEnabled(); |
| 100 | + await page.getByRole('button', { name: 'Subset 2' }).click(); |
| 101 | + await expect(page.getByPlaceholder('Argument name')).toHaveValue('k2'); |
| 102 | + await expect(page.getByPlaceholder('Argument value')).toHaveValue('v2'); |
| 103 | + await expect(page.getByRole('button', { name: 'Add property' })).not.toBeEnabled(); |
| 104 | + }); |
| 105 | + |
| 106 | + await test.step('Open subset logs modal', async () => { |
| 107 | + await page.locator('[aria-label="Done images"]').last().click(); |
| 108 | + await modal.waitFor(); |
| 109 | + await expect(modal.getByText('Total results: 1')).toBeVisible(); |
| 110 | + await expect(modal.getByRole('row')).toHaveCount(1); |
| 111 | + await modal.getByRole('button', { name: 'Close' }).click(); |
| 112 | + await waitModalClosed(page); |
| 113 | + }); |
| 114 | + |
| 115 | + await test.step('Open subsets of second task and check arguments', async () => { |
| 116 | + await workflow.selectTask('illumination_correction'); |
| 117 | + await expect(page.getByRole('button', { name: 'Subset 1' })).not.toBeVisible(); |
| 118 | + await page.getByRole('button', { name: 'Arguments', exact: true }).click(); |
| 119 | + await page.getByRole('switch').check(); |
| 120 | + await page.getByRole('button', { name: 'Save changes' }).click(); |
| 121 | + await expect(page.getByRole('button', { name: 'Save changes' })).toBeDisabled(); |
| 122 | + await expect(page.getByRole('switch')).toBeChecked(); |
| 123 | + await page.locator('[aria-label="Show subsets"]').nth(1).click(); |
| 124 | + await page.getByRole('button', { name: 'Subset 1' }).click(); |
| 125 | + await expect(page.getByRole('button', { name: 'Subset 2' })).not.toBeVisible(); |
| 126 | + await expect(page.getByRole('switch')).not.toBeChecked(); |
| 127 | + await expect(page.getByRole('switch')).not.toBeEditable(); |
| 128 | + }); |
| 129 | + |
| 130 | + await test.step('Continue workflow causing failure', async () => { |
| 131 | + await page.getByRole('button', { name: 'Continue workflow' }).click(); |
| 132 | + await modal.waitFor(); |
| 133 | + await modal |
| 134 | + .getByRole('combobox', { name: 'First task' }) |
| 135 | + .selectOption('create_ome_zarr_compound'); |
| 136 | + await modal.getByRole('button', { name: 'Run' }).click(); |
| 137 | + await modal.getByRole('button', { name: 'Confirm' }).click(); |
| 138 | + await waitModalClosed(page); |
| 139 | + await waitTaskFailure(page); |
| 140 | + }); |
| 141 | + |
| 142 | + await test.step('Open failed logs modal', async () => { |
| 143 | + await page.locator('[aria-label="Failed images"]').first().click(); |
| 144 | + await modal.waitFor(); |
| 145 | + await expect(modal.getByText("Images with status='failed'")).toBeVisible(); |
| 146 | + await expect(modal.getByText('Total results: 15')).toBeVisible(); |
| 147 | + await modal.getByRole('button', { name: 'Logs' }).first().click(); |
| 148 | + await modal.getByRole('button', { name: 'click here to expand' }).click(); |
| 149 | + await expect(page.getByText('Traceback')).toBeVisible(); |
| 150 | + await modal.getByRole('button', { name: 'Close' }).click(); |
| 151 | + await waitModalClosed(page); |
| 152 | + }); |
| 153 | +}); |
0 commit comments