49 lines
2.2 KiB
TypeScript
49 lines
2.2 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Scenario 05: CRM Deal Won -> Commercial Order Flow', () => {
|
|
test('advances deal to Won, confirms linked Order creation, and verifies order in Sales', async ({ page }) => {
|
|
test.setTimeout(60000);
|
|
await page.goto('/crm/deals', { waitUntil: 'domcontentloaded' });
|
|
await page.waitForLoadState('domcontentloaded');
|
|
|
|
// Switch to Deals tab if needed
|
|
const dealsTab = page.locator('button:has-text("Воронка сделок")');
|
|
if (await dealsTab.isVisible()) {
|
|
await dealsTab.click({ force: true });
|
|
}
|
|
|
|
// Locate deal cards
|
|
const dealCards = page.locator('[data-testid^="deal-card-"]');
|
|
await expect(dealCards.first()).toBeVisible({ timeout: 15000 });
|
|
|
|
// Advance a deal to Won to trigger the Order creation modal
|
|
const advanceToWonBtn = page.locator('button:has-text("Далее: Выиграна")').first();
|
|
await advanceToWonBtn.scrollIntoViewIfNeeded().catch(() => {});
|
|
if (await advanceToWonBtn.isVisible({ timeout: 5000 }).catch(() => false)) {
|
|
await advanceToWonBtn.click({ force: true });
|
|
} else {
|
|
const firstCard = dealCards.first();
|
|
const wonColumn = page.locator('[data-testid="kanban-column-won"]');
|
|
await wonColumn.scrollIntoViewIfNeeded().catch(() => {});
|
|
await firstCard.dragTo(wonColumn, { timeout: 2500 }).catch(() => {});
|
|
}
|
|
|
|
const confirmOrderBtn = page.locator('[data-testid="create-order-confirm-btn"]');
|
|
|
|
// Modal "Сделка выиграна! Создать заказ в коммерции?"
|
|
await expect(confirmOrderBtn).toBeVisible({ timeout: 10000 });
|
|
await confirmOrderBtn.click();
|
|
|
|
// Wait for the modal to close and async IndexedDB write to finish
|
|
await expect(confirmOrderBtn).not.toBeVisible({ timeout: 10000 });
|
|
await page.waitForTimeout(500);
|
|
|
|
// Navigate to Sales module
|
|
await page.goto('/sales', { waitUntil: 'domcontentloaded' });
|
|
await page.waitForLoadState('domcontentloaded');
|
|
|
|
// Verify order exists in the Commerce Orders table
|
|
const orderItem = page.locator('tbody tr').filter({ hasText: 'ORD-' }).first();
|
|
await expect(orderItem).toBeVisible({ timeout: 15000 });
|
|
});
|
|
});
|