73 lines
3 KiB
TypeScript
73 lines
3 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Scenario 04: CRM Lead Creation & Full Conversion Flow', () => {
|
|
test('creates a new lead, converts it into contact and deal, and verifies both', async ({ page }) => {
|
|
await page.goto('/crm/leads');
|
|
await page.waitForLoadState('domcontentloaded');
|
|
|
|
// Ensure Leads tab is active
|
|
const leadsTab = page.locator('button:has-text("Лиды")');
|
|
if (await leadsTab.isVisible()) {
|
|
await leadsTab.click({ force: true });
|
|
}
|
|
|
|
// 1. Open New Lead Modal
|
|
const newLeadBtn = page.locator('[data-testid="new-lead-btn"]');
|
|
await expect(newLeadBtn).toBeVisible({ timeout: 15000 });
|
|
await newLeadBtn.click();
|
|
|
|
// 2. Fill Lead Form inside Modal
|
|
const modal = page.getByRole('dialog', { name: 'Создание нового лида' });
|
|
await expect(modal).toBeVisible({ timeout: 10000 });
|
|
|
|
const leadTitle = `Сеть Кофеен Арабика ${Date.now().toString().slice(-4)}`;
|
|
const contactName = 'Дмитрий Морозов';
|
|
|
|
const modalInputs = modal.locator('input');
|
|
await expect(modalInputs.first()).toBeVisible({ timeout: 10000 });
|
|
|
|
// Fill fields inside the modal: title, contactName, phone, email
|
|
await modalInputs.nth(0).fill(leadTitle);
|
|
const inputCount = await modalInputs.count();
|
|
if (inputCount > 1) {
|
|
await modalInputs.nth(1).fill(contactName);
|
|
}
|
|
if (inputCount > 2) {
|
|
await modalInputs.nth(2).fill('+7 913 555-44-33');
|
|
}
|
|
if (inputCount > 3) {
|
|
await modalInputs.nth(3).fill('morozov@arabica.ru');
|
|
}
|
|
|
|
// Submit form
|
|
const submitBtn = modal.locator('[data-testid="dynamic-form-submit"], button:has-text("Создать запись")');
|
|
await submitBtn.click();
|
|
|
|
// 3. Verify lead appeared in table
|
|
await expect(modal).not.toBeVisible({ timeout: 10000 });
|
|
await expect(page.locator(`text=${leadTitle}`).first()).toBeVisible({ timeout: 10000 });
|
|
|
|
// 4. Convert Lead to Deal & Contact
|
|
const leadRow = page.locator('tr').filter({ hasText: leadTitle });
|
|
const convertBtn = leadRow.locator('[data-testid="convert-lead-btn"]');
|
|
await expect(convertBtn).toBeVisible({ timeout: 10000 });
|
|
await convertBtn.click();
|
|
|
|
// Confirm conversion modal
|
|
const confirmConvertBtn = page.locator('[data-testid="confirm-convert-lead-btn"]');
|
|
await expect(confirmConvertBtn).toBeVisible({ timeout: 10000 });
|
|
await confirmConvertBtn.click();
|
|
|
|
// 5. Verify Contact in Contacts Tab
|
|
const contactsTab = page.locator('button:has-text("Контакты")');
|
|
await contactsTab.click();
|
|
await page.waitForLoadState('domcontentloaded');
|
|
await expect(page.locator(`text=${contactName}`).or(page.locator(`text=${leadTitle}`)).first()).toBeVisible({ timeout: 10000 });
|
|
|
|
// 6. Verify Deal in Deals Tab
|
|
const dealsTab = page.locator('button:has-text("Воронка сделок")');
|
|
await dealsTab.click();
|
|
await page.waitForLoadState('domcontentloaded');
|
|
await expect(page.locator(`text=${leadTitle}`).first()).toBeVisible({ timeout: 10000 });
|
|
});
|
|
});
|