import { test, expect } from '../../fixtures'; test.describe('سناریوی مدیریت درخواست‌های B2B و فرم‌های تماس (Admin B2B Submissions Flow)', () => { test('ورود به بخش B2B -> مشاهده درخواست‌ها -> فیلتر و بررسی جزئیات', async ({ page }) => { // Intercept and mock Admin Auth & B2B API calls await page.route('**/api/auth/admin-login*', async (route) => { await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ success: true, data: { accessToken: 'mock_e2e_admin_jwt_token', user: { id: 'admin-1', email: 'admin@canina.ir', role: 'SUPER_ADMIN' }, }, }), }); }); await page.route('**/api/auth/refresh*', async (route) => { await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ success: true, data: { accessToken: 'mock_e2e_admin_jwt_token', user: { id: 'admin-1', email: 'admin@canina.ir', role: 'SUPER_ADMIN' }, }, }), }); }); await page.route('**/api/users/profile*', async (route) => { await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ success: true, data: { id: 'admin-1', email: 'admin@canina.ir', role: 'SUPER_ADMIN' }, }), }); }); await page.route('**/api/admin/b2b-applications*', async (route) => { await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ success: true, data: [ { id: 'b2b-1', clinicName: 'کلینیک تخصصی دامپزشکی پایتخت', managerName: 'دکتر محمدی', phone: '09123334455', status: 'PENDING', createdAt: new Date().toISOString(), }, ], meta: { total: 1, lastPage: 1 }, }), }); }); // 1. لاگین ادمین await page.goto('/login', { waitUntil: 'domcontentloaded' }); const emailInput = page.locator('input[type="email"], input[placeholder*="ایمیل"]').first(); const passwordInput = page.locator('input[type="password"], input[placeholder*="رمز"]').first(); if (await emailInput.isVisible()) { await emailInput.fill('admin@canina.ir'); await passwordInput.fill('Admin@123456'); const submitBtn = page.getByRole('button', { name: /ورود به پنل|ورود/i }).first(); await submitBtn.click(); await page.waitForTimeout(500); } // 2. ورود به صفحه مدیریت درخواست‌های B2B await page.goto('/b2b', { waitUntil: 'domcontentloaded' }); await expect(page).toHaveURL(/\/b2b/); // 3. بررسی ساختار لودینگ صفحه یا جدول اطلاعات const b2bHeader = page.locator('h1, h2, h3, div').filter({ hasText: /درخواست|B2B|همکاری|کلینیک|پت‌شاپ/i }).first(); await expect(b2bHeader).toBeVisible({ timeout: 15000 }); }); });