Skip to content

Commit

Permalink
Added a test for copying a workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nk2136 committed Jan 22, 2025
1 parent c2b696f commit d4c7b9d
Showing 1 changed file with 8 additions and 179 deletions.
187 changes: 8 additions & 179 deletions end2end/tests/workflowEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,44 +147,17 @@ test('Copy workflow', async ({ page }) => {
await saveButton.click();
await expect(page.locator('a').filter({ hasText: originalWorkflowTitle })).toBeVisible();

// Create a new step in the workflow
await page.locator('#btn_createStep').click();

// Wait for the "Create new Step" dialog to be visible, then create a step
const stepCreateDialog = page.locator('span.ui-dialog-title:has-text("Create new Step")');
await stepCreateDialog.waitFor({ state: 'visible' });
const stepTitle = 'step1';
await page.locator('#stepTitle').fill(stepTitle);
await saveButton.click();

// Verify that the new step is visible
const stepElement = page.getByLabel(`workflow step: ${stepTitle}`, { exact: true });
await expect(stepElement).toBeInViewport();

// Hover over the new step and drag it to a desired position
await stepElement.hover();
await page.mouse.down();
await page.mouse.move(300, 300);
await page.mouse.up();

// Connect the steps by dragging connectors
const stepConnector = page.locator('.jtk-endpoint').nth(0);
const requestorConnector = page.locator('.jtk-endpoint').nth(1);
const endConnector = page.locator('.jtk-endpoint').nth(2);
const requestorConnector = page.locator('.jtk-endpoint').nth(0);
const endConnector = page.locator('.jtk-endpoint').nth(1);

await requestorConnector.dragTo(stepConnector);
await requestorConnector.dragTo(endConnector);
await expect(page.getByText('Submit')).toBeInViewport();

await stepConnector.dragTo(endConnector);

// Wait for the "Create New Workflow Action" dialog and save the action
const actionDialog = page.locator('span.ui-dialog-title:has-text("Create New Workflow Action")');
await actionDialog.waitFor({ state: 'visible' });
await saveButton.click();
await expect(page.getByText('Approve')).toBeInViewport();

// Click the 'Duplicate Workflow' button to start the copy process
await page.locator('#btn_duplicateWorkflow').click();
// Click the 'Copy Workflow' button to start the copy process
await page.reload();
const copyWorkflowButton = page.locator('#btn_duplicateWorkflow');
await copyWorkflowButton.waitFor({state: 'visible'});
await copyWorkflowButton.click();

// Wait for the "Duplicate Workflow" dialog to appear
const duplicateWorkflowDialog = page.locator('span.ui-dialog-title:has-text("Duplicate current workflow")');
Expand All @@ -195,147 +168,3 @@ test('Copy workflow', async ({ page }) => {
await saveButton.click();
await expect(page.locator('a').filter({ hasText: copiedWorkflowTitle })).toBeVisible();
});

test('Create a new workflow and delete it', async ({ page }) => {
const uniqueWorkflowName = `New_Workflow_${Math.floor(Math.random() * 10000)}`;

await page.goto('https://host.docker.internal/Test_Request_Portal/admin/?a=workflow&workflowID=1');

// Create new workflow
await page.locator('#btn_newWorkflow').click();
const workflowCreateDialog = page.locator('span.ui-dialog-title:has-text("Create new workflow")');
await workflowCreateDialog.waitFor({ state: 'visible' });

await page.locator('#description').fill(uniqueWorkflowName);
await page.locator('#button_save').click();

const workflowsDropdown = page.locator('#workflows_chosen');
await expect(workflowsDropdown).toContainText(uniqueWorkflowName);

// Delete the workflow
await page.locator('#btn_deleteWorkflow').click();
const confirmationDialog = page.locator('span.ui-dialog-title:has-text("Confirmation required")');
await confirmationDialog.waitFor({ state: 'visible' });

// Confirm the deletion
await page.locator('#confirm_button_save').click();

// Verify the workflow was deleted
await expect(workflowsDropdown).not.toContainText(uniqueWorkflowName);
});

test('Edit a step from the choose a step edit dropdown', async ({ page }) => {
const uniqueWorkflowName = `New_Workflow_${Math.floor(Math.random() * 10000)}`;

await page.goto('https://host.docker.internal/Test_Request_Portal/admin/?a=workflow&workflowID=1');

// Create a new workflow
await page.locator('#btn_newWorkflow').click();
const workflowCreateDialog = page.locator('span.ui-dialog-title:has-text("Create new workflow")');
await workflowCreateDialog.waitFor({ state: 'visible' });

await page.locator('#description').fill(uniqueWorkflowName);
await page.locator('#button_save').click();

// Verify the newly created workflow appears in the dropdown
await expect(page.locator('#workflows_chosen')).toContainText(uniqueWorkflowName);

// Select a step from the dropdown
await page.locator('#workflow_steps_chosen').click();
const requestorOption = page.locator('li[data-option-array-index="1"]');
await requestorOption.click();

// Verify the step information section is visible
const stepInfo = page.locator('#stepInfo_-1');
await stepInfo.waitFor({ state: 'visible' });

await page.locator('#toggleManageActions').click();

// Add an action from the dropdown
const addActionDropdown = page.locator('#create_route');
await addActionDropdown.selectOption('0');

// Verify the "Submit" action is in the viewport
const submitButton = page.locator('div:has-text("Submit")').nth(1);
await expect(submitButton).toBeInViewport();
});

test('Create and remove an action between steps', async ({ page }) => {
const uniqueWorkflowName = `New_Workflow_${Math.floor(Math.random() * 10000)}`;

await page.goto('https://host.docker.internal/Test_Request_Portal/admin/?a=workflow&workflowID=1');

// Create a new workflow
await page.locator('#btn_newWorkflow').click();
const workflowCreateDialog = page.locator('span.ui-dialog-title:has-text("Create new workflow")');
await workflowCreateDialog.waitFor({ state: 'visible' });

await page.locator('#description').fill(uniqueWorkflowName);
await page.locator('#button_save').click();

// Verify the newly created workflow appears in the dropdown
const workflowDropdown = page.locator('#workflows_chosen');
await expect(workflowDropdown).toContainText(uniqueWorkflowName);

// Drag connectors to connect steps
const requestorConnector = page.locator('.jtk-endpoint').nth(0);
const endConnector = page.locator('.jtk-endpoint').nth(1);
await requestorConnector.dragTo(endConnector);

// Verify 'Submit' action appears and click it
const submitAction = page.getByText('Submit', { exact: true });
await expect(submitAction).toBeInViewport();
await submitAction.click();

// Wait for the action removal dialog and click 'Remove Action'
const removeActionDialog = page.locator('#stepInfo_-1');
await removeActionDialog.waitFor({ state: 'visible' });
await page.locator('button', { hasText: 'Remove Action' }).click();

// Confirm the action removal
const confirmationDialog = page.locator('span.ui-dialog-title:has-text("Confirm action removal")');
await confirmationDialog.waitFor({ state: 'visible' });
await page.getByRole('button', { name: 'Yes' }).click();

// Verify the action is removed and is no longer in the viewport
await expect(submitAction).not.toBeInViewport();
});

test('Add event to an action', async ({ page }) => {
const uniqueWorkflowName = `New_Workflow_${Math.floor(Math.random() * 10000)}`;

await page.goto('https://host.docker.internal/Test_Request_Portal/admin/?a=workflow&workflowID=1');

// Create a new workflow
await page.locator('#btn_newWorkflow').click();
const workflowCreateDialog = page.locator('span.ui-dialog-title:has-text("Create new workflow")');
await workflowCreateDialog.waitFor({ state: 'visible' });

await page.locator('#description').fill(uniqueWorkflowName);
const saveButton = page.locator('#button_save');
await saveButton.click();

// Verify the newly created workflow appears in the dropdown
const workflowDropdown = page.locator('#workflows_chosen');
await expect(workflowDropdown).toContainText(uniqueWorkflowName);

// Drag connectors to connect steps
const requestorConnector = page.locator('.jtk-endpoint').nth(0);
const endConnector = page.locator('.jtk-endpoint').nth(1);
await requestorConnector.dragTo(endConnector);

// Verify 'Submit' action appears and click it
const submitAction = page.getByText('Submit', { exact: true });
await expect(submitAction).toBeInViewport();
await submitAction.click();

const removeActionDialog = page.locator('#stepInfo_-1');
await removeActionDialog.waitFor({ state: 'visible' });

await page.getByRole('button', { name: 'Add Event' }).click();

const addEventDialog = page.locator('span.ui-dialog-title:has-text("Add Event")');
await addEventDialog.waitFor({ state: 'visible' });
await saveButton.click();
await expect(page.locator('#stepInfo_-1')).toContainText('Email - test edited event description');
});

0 comments on commit d4c7b9d

Please sign in to comment.