|
| 1 | +import { test, expect } from '../../../setup'; |
| 2 | +import { generateDescription, generateName } from '../../../utils/faker'; |
| 3 | + |
| 4 | +test.describe('Workflow Management', () => { |
| 5 | + const workflowName = generateName(); |
| 6 | + const updatedName = generateName(); |
| 7 | + const workflowDescription = generateDescription(); |
| 8 | + const updatedDescription = generateDescription(); |
| 9 | + |
| 10 | + test('should create a workflow', async ({ adminPage }) => { |
| 11 | + /* Navigate to workflow listing page */ |
| 12 | + await adminPage.goto('admin/settings/workflows'); |
| 13 | + |
| 14 | + /* Click the 'Create Workflow' button */ |
| 15 | + await adminPage.getByRole('link', { name: 'Create Workflow' }).click(); |
| 16 | + |
| 17 | + /* Fill basic details */ |
| 18 | + await adminPage.getByRole('textbox', { name: 'Name' }).fill(workflowName); |
| 19 | + await adminPage.getByRole('textbox', { name: 'Description' }).fill(workflowDescription); |
| 20 | + |
| 21 | + /* Select event trigger */ |
| 22 | + await adminPage.locator('select[name="event"]').selectOption('lead.update.after'); |
| 23 | + |
| 24 | + /* Select condition type */ |
| 25 | + await adminPage.locator('#condition_type').selectOption('and'); |
| 26 | + |
| 27 | + /* Add condition */ |
| 28 | + await adminPage.getByRole('button', { name: /Add Condition/ }).click(); |
| 29 | + await adminPage.locator('[id="conditions[0][attribute]"]').selectOption('title'); |
| 30 | + await adminPage.locator('input[name="conditions[0][value]"]').fill('title name'); |
| 31 | + |
| 32 | + /* Add action */ |
| 33 | + await adminPage.getByRole('button', { name: /Add Action/ }).click(); |
| 34 | + await adminPage.locator('select[name="actions[0][id]"]').selectOption('add_tag'); |
| 35 | + await adminPage.locator('input[name="actions[0][value]"]').fill('new tag'); |
| 36 | + |
| 37 | + /* Save workflow */ |
| 38 | + await adminPage.getByRole('button', { name: 'Save Workflow' }).click(); |
| 39 | + |
| 40 | + /* Validate the workflow appears in the listing */ |
| 41 | + await expect(adminPage.getByText(workflowName).first()).toBeVisible(); |
| 42 | + }); |
| 43 | + |
| 44 | + test('should update a workflow', async ({ adminPage }) => { |
| 45 | + /* Navigate to workflow listing */ |
| 46 | + await adminPage.goto('admin/settings/workflows'); |
| 47 | + |
| 48 | + /* Click edit icon on the first workflow */ |
| 49 | + await adminPage.locator('(//span[contains(@class,"icon-edit")])[1]').click(); |
| 50 | + |
| 51 | + /* Update name and description */ |
| 52 | + await adminPage.getByRole('textbox', { name: 'Name' }).fill(updatedName); |
| 53 | + await adminPage.getByRole('textbox', { name: 'Description' }).fill(updatedDescription); |
| 54 | + |
| 55 | + /* Save updated workflow */ |
| 56 | + await adminPage.getByRole('button', { name: 'Save Workflow' }).click(); |
| 57 | + |
| 58 | + /* Verify updated name appears in list */ |
| 59 | + await expect(adminPage.getByText(updatedName).first()).toBeVisible(); |
| 60 | + }); |
| 61 | + |
| 62 | + test('should delete a workflow', async ({ adminPage }) => { |
| 63 | + /* Navigate to workflow listing */ |
| 64 | + await adminPage.goto('admin/settings/workflows'); |
| 65 | + |
| 66 | + /* Click delete icon on first workflow */ |
| 67 | + await adminPage.locator('(//span[contains(@class,"icon-delete")])[1]').click(); |
| 68 | + |
| 69 | + /* Confirm delete in modal */ |
| 70 | + await adminPage.getByRole('button', { name: 'Agree', exact: true }).click(); |
| 71 | + |
| 72 | + /* Confirm deleted workflow name no longer exists */ |
| 73 | + await expect(adminPage.getByText(updatedName).first()).not.toBeVisible(); |
| 74 | + }); |
| 75 | +}); |
0 commit comments