95 lines
3.6 KiB
TypeScript
95 lines
3.6 KiB
TypeScript
import { test, expect } from '../../fixtures';
|
|
|
|
test.describe('سناریوی مدیریت سفارشات و فیلترها در پنل ادمین (Admin Orders Management)', () => {
|
|
test('ورود به بخش سفارشات -> راستیآزمایی رندر جدول فاکتورها -> فیلتر وضعیت و مشاهده جزییات', async ({ page }) => {
|
|
// Intercept and mock Admin Auth & Orders 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/orders*', async (route) => {
|
|
await route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({
|
|
success: true,
|
|
data: [
|
|
{
|
|
id: 'ord-101',
|
|
orderNumber: 'CN-10001',
|
|
customerName: 'علی رضایی',
|
|
customerPhone: '09121112233',
|
|
totalAmount: 1850000,
|
|
status: 'processing',
|
|
createdAt: new Date().toISOString(),
|
|
items: [{ id: 'item-1', name: 'مکمل مفاصل سگ', quantity: 2, priceValue: 925000 }],
|
|
},
|
|
],
|
|
meta: { total: 1, lastPage: 1 },
|
|
}),
|
|
});
|
|
});
|
|
|
|
// 1. لاگین ادمین
|
|
await page.goto('/login', { waitUntil: 'domcontentloaded' });
|
|
const emailInput = page.locator('input[type="email"]');
|
|
const passwordInput = page.locator('input[type="password"]');
|
|
await expect(emailInput).toBeVisible({ timeout: 10000 });
|
|
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. ورود به صفحه مدیریت سفارشات
|
|
await page.goto('/orders', { waitUntil: 'domcontentloaded' });
|
|
await expect(page).toHaveURL(/\/orders/);
|
|
|
|
// 3. راستیآزمایی دقیق تیتر مدیریت سفارشات
|
|
const ordersHeading = page.locator('h2').filter({ hasText: 'مدیریت سفارشات' });
|
|
await expect(ordersHeading).toBeVisible({ timeout: 15000 });
|
|
|
|
// 4. راستیآزمایی دراپداون فیلتر وضعیت و انتخاب وضعیت جدید
|
|
const statusSelect = page.locator('select').first();
|
|
await expect(statusSelect).toBeVisible();
|
|
await statusSelect.selectOption({ label: 'در حال پردازش' });
|
|
await expect(page).toHaveURL(/status=/);
|
|
});
|
|
});
|