Files
CRM_Montzar/e2e/smoke.spec.ts
T

73 lines
3.2 KiB
TypeScript

import { test, expect, waitForIdle } from './fixtures';
/** فقط خواندنی: هیچ رکوردی ساخته، ویرایش یا حذف نمی‌شود؛ اجرا روی سرور اصلی بی‌خطر است */
const PAGES: Array<[string, string]> = [
['/', 'داشبورد'],
['/contacts', 'مشتریان'],
['/leads', 'لیدها'],
['/pipeline', 'فروش'],
['/activities', 'کارها'],
['/activities/calendar', 'تقویم کارها'],
['/routines', 'کارهای روتین'],
['/conversations', 'گفتگو'],
['/notes', 'یادداشت‌ها'],
['/tickets', 'پشتیبانی'],
['/loyalty', 'باشگاه مشتریان'],
['/reports', 'گزارش‌ها'],
['/invoices', 'فاکتورها'],
['/quotes', 'پیش‌فاکتورها'],
['/cheques', 'چک‌ها'],
['/projects', 'پروژه‌ها'],
['/profile', 'پروفایل'],
['/settings/team', 'تنظیمات تیم'],
['/settings/lead-forms', 'فرم‌های لید'],
['/settings/message-automations', 'اتوماسیون پیام'],
['/settings/tahesab', 'تنظیمات ته‌حساب'],
];
for (const [path, title] of PAGES) {
test(`صفحهٔ ${title} بدون خطا باز می‌شود (${path})`, async ({ page, problems }) => {
await page.goto(path);
await expect(page).not.toHaveURL(/\/login/);
await expect(page.locator('main.content')).toBeVisible();
await waitForIdle(page);
expect(problems.list).toEqual([]);
});
}
test('جستجوی سراسری باز می‌شود و نتیجه می‌دهد', async ({ page }) => {
await page.goto('/');
const search = page.getByPlaceholder(/جستجو در مشتریان/);
await expect(search).toBeVisible();
await search.fill('a');
await waitForIdle(page);
});
test('دارایی‌ها و اسناد ته‌حساب مشتری', async ({ page }) => {
const personId = process.env.E2E_PERSON_ID;
test.skip(!personId, 'E2E_PERSON_ID تنظیم نشده');
await page.goto(`/contacts/people/${personId}?tab=assets`);
await expect(page.getByText('مانده حساب')).toBeVisible({ timeout: 30_000 });
await page.getByRole('button', { name: 'جزئیات حساب', exact: true }).click();
await expect(page.locator('.invoice, .asnad-grid .sanad-card').first().or(page.getByText('در این بازه سندی یافت نشد'))).toBeVisible({ timeout: 60_000 });
const invoice = page.locator('.invoice').first();
if (await invoice.isVisible()) {
await expect(invoice.locator('.inv-head')).toContainText('سند شماره');
await expect(invoice.locator('.inv-table tbody tr').first()).toBeVisible();
}
});
test('فرم عمومی لید بدون لاگین باز می‌شود', async ({ browser }) => {
const token = process.env.E2E_FORM_TOKEN;
test.skip(!token, 'E2E_FORM_TOKEN تنظیم نشده');
const ctx = await browser.newContext({ storageState: undefined });
const page = await ctx.newPage();
const errors: string[] = [];
page.on('pageerror', (e) => errors.push(e.message));
await page.goto(`/f/${token}`);
await expect(page.locator('form')).toBeVisible();
await expect(page.getByRole('button', { name: /ارسال|ثبت/ })).toBeVisible();
expect(errors).toEqual([]);
await ctx.close();
});