test(e2e): complete and verify 11 E2E test suites with strict mutation testing and CI integration
This commit is contained in:
1 parent
6ef293ea59
commit
e6018f3a37
21 files changed
+771
-58
No files matched your search
@@ -51,9 +51,12 @@ test.describe('سناریوی مدیریت درخواستهای B2B و فرم
|
||||
data: [
|
||||
{
|
||||
id: 'b2b-1',
|
||||
clinicName: 'کلینیک تخصصی دامپزشکی پایتخت',
|
||||
managerName: 'دکتر محمدی',
|
||||
companyName: 'کلینیک تخصصی دامپزشکی پایتخت',
|
||||
contactName: 'دکتر محمدی',
|
||||
phone: '09123334455',
|
||||
email: 'clinic@paytakht.ir',
|
||||
businessType: 'کلینیک دامپزشکی',
|
||||
message: 'درخواست خرید عمده مکملهای مفاصل کنینا',
|
||||
status: 'PENDING',
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
@@ -63,6 +66,27 @@ test.describe('سناریوی مدیریت درخواستهای B2B و فرم
|
||||
});
|
||||
});
|
||||
|
||||
await page.route('**/api/b2b/partners*', async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: [
|
||||
{
|
||||
id: 'partner-1',
|
||||
companyName: 'پت شاپ مرکزی ارکیده',
|
||||
userId: 'usr-901',
|
||||
taxId: '1400889922',
|
||||
creditLimit: 50000000,
|
||||
discountTier: 'طلایی (۲۵٪)',
|
||||
status: 'ACTIVE',
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
// 1. لاگین ادمین
|
||||
await page.goto('/login', { waitUntil: 'domcontentloaded' });
|
||||
const emailInput = page.locator('input[type="email"]');
|
||||
@@ -79,17 +103,25 @@ test.describe('سناریوی مدیریت درخواستهای B2B و فرم
|
||||
await page.goto('/b2b', { waitUntil: 'domcontentloaded' });
|
||||
await expect(page).toHaveURL(/\/b2b/);
|
||||
|
||||
// 3. راستیآزمایی تیتر اختصاصی مدیریت B2B
|
||||
// 3. راستیآزمایی تیتر اختصاصی مدیریت B2B و درخواست متناظر
|
||||
const b2bHeader = page.locator('h2').filter({ hasText: 'مدیریت همکاران عمدهفروشی و B2B' });
|
||||
await expect(b2bHeader).toBeVisible({ timeout: 15000 });
|
||||
await expect(page.locator('span').filter({ hasText: 'کلینیک تخصصی دامپزشکی پایتخت' }).first()).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// 4. راستیآزمایی تبهای درخواستها و همکاران
|
||||
const partnerTab = page.getByRole('button', { name: /حسابهای تاییدشده همکار/i });
|
||||
// 4. سوئیچ به تب حسابهای تاییدشده همکار
|
||||
const partnerTab = page.locator('[data-testid="b2b-partners-tab"]').first();
|
||||
await expect(partnerTab).toBeVisible();
|
||||
await partnerTab.click();
|
||||
|
||||
const inquiriesTab = page.getByRole('button', { name: /درخواستهای دریافت نمایندگی/i });
|
||||
// راستیآزمایی دقیق رندر شدن جدول حسابهای همکار
|
||||
const partnerRowText = page.locator('td').filter({ hasText: 'پت شاپ مرکزی ارکیده' }).first();
|
||||
await expect(partnerRowText).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// 5. سوئیچ مجدد به تب درخواستها
|
||||
const inquiriesTab = page.locator('[data-testid="b2b-inquiries-tab"]').first();
|
||||
await expect(inquiriesTab).toBeVisible();
|
||||
await inquiriesTab.click();
|
||||
|
||||
await expect(page.locator('span').filter({ hasText: 'کلینیک تخصصی دامپزشکی پایتخت' }).first()).toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
});
|
||||
@@ -2,6 +2,8 @@ import { test, expect } from '../../fixtures';
|
||||
|
||||
test.describe('سناریوی مدیریت مقالات و وبلاگ در پنل ادمین (Admin Blogs & CMS Flow)', () => {
|
||||
test('ورود به بخش مقالات -> باز کردن فرم ایجاد -> پر کردن عنوان و ذخیره نهایی', async ({ page }) => {
|
||||
let blogCreated = false;
|
||||
|
||||
// Intercept and mock Admin Auth & Blogs API calls
|
||||
await page.route('**/api/auth/admin-login*', async (route) => {
|
||||
await route.fulfill({
|
||||
@@ -42,6 +44,22 @@ test.describe('سناریوی مدیریت مقالات و وبلاگ در پن
|
||||
});
|
||||
});
|
||||
|
||||
await page.route('**/api/admin/blogs/categories*', async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({ success: true, data: [] }),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route('**/api/admin/blogs/tags*', async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({ success: true, data: [] }),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route('**/api/admin/blogs*', async (route) => {
|
||||
if (route.request().method() === 'GET') {
|
||||
await route.fulfill({
|
||||
@@ -61,12 +79,15 @@ test.describe('سناریوی مدیریت مقالات و وبلاگ در پن
|
||||
meta: { total: 1, lastPage: 1 },
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
} else if (route.request().method() === 'POST') {
|
||||
blogCreated = true;
|
||||
await route.fulfill({
|
||||
status: 201,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({ success: true, message: 'مقاله جدید با موفقیت ذخیره شد' }),
|
||||
});
|
||||
} else {
|
||||
await route.continue();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -94,14 +115,17 @@ test.describe('سناریوی مدیریت مقالات و وبلاگ در پن
|
||||
await expect(newBlogBtn).toBeVisible();
|
||||
await newBlogBtn.click();
|
||||
|
||||
// 4. راستیآزمایی باز شدن فرم ایجاد و پر کردن عنوان
|
||||
const blogTitleInput = page.locator('input[placeholder*="عنوان"]').first();
|
||||
// 4. پر کردن عنوان در فرم مودال
|
||||
const blogTitleInput = page.locator('[data-testid="blog-title-input"]').first();
|
||||
await expect(blogTitleInput).toBeVisible({ timeout: 10000 });
|
||||
await blogTitleInput.fill('مقاله آموزشی تستی پلیرایت');
|
||||
|
||||
// 5. ذخیره فرم و راستیآزمایی پیام موفقیت یا فراخوانی موفقیتآمیز
|
||||
const saveBlogBtn = page.getByRole('button', { name: /ذخیره|ثبت|انتشار/i }).first();
|
||||
await expect(saveBlogBtn).toBeVisible();
|
||||
// 5. ذخیره فرم با دکمه ذخیره مقاله
|
||||
const saveBlogBtn = page.locator('[data-testid="blog-save-btn"]').first();
|
||||
await expect(saveBlogBtn).toBeVisible({ timeout: 10000 });
|
||||
await saveBlogBtn.click();
|
||||
|
||||
// راستیآزمایی دقیق ارسال موفقیتآمیز درخواست ساخت مقاله به سرور
|
||||
await expect.poll(() => blogCreated, { timeout: 10000 }).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import { test, expect } from '../../fixtures';
|
||||
|
||||
test.describe('سناریوی مدیریت سفارشات و فیلترها در پنل ادمین (Admin Orders Management)', () => {
|
||||
test('ورود به بخش سفارشات -> راستیآزمایی رندر جدول فاکتورها -> فیلتر وضعیت و مشاهده جزییات', async ({ page }) => {
|
||||
test.describe('سناریوی مدیریت و فیلتر سفارشات در پنل ادمین (Admin Orders Flow & Exact Value Assertion)', () => {
|
||||
test('ورود به بخش سفارشات -> راستیآزمایی رندر جدول فاکتورها -> راستیآزمایی مقدار دقیق وضعیت سفارش -> فیلتر وضعیت', async ({ page }) => {
|
||||
// Intercept and mock Admin Auth & Orders API calls
|
||||
await page.route('**/api/auth/admin-login*', async (route) => {
|
||||
await route.fulfill({
|
||||
@@ -50,13 +50,13 @@ test.describe('سناریوی مدیریت سفارشات و فیلترها در
|
||||
success: true,
|
||||
data: [
|
||||
{
|
||||
id: 'ord-101',
|
||||
orderNumber: 'CN-10001',
|
||||
customerName: 'علی رضایی',
|
||||
customerPhone: '09121112233',
|
||||
id: 'ord-12345',
|
||||
trackingNumber: 'CN-88990',
|
||||
totalAmount: 1850000,
|
||||
status: 'processing',
|
||||
status: 'shipped',
|
||||
paymentMethod: 'ONLINE',
|
||||
createdAt: new Date().toISOString(),
|
||||
user: { firstName: 'علی', lastName: 'رضایی', phone: '09121112233' },
|
||||
items: [{ id: 'item-1', name: 'مکمل مفاصل سگ', quantity: 2, priceValue: 925000 }],
|
||||
},
|
||||
],
|
||||
@@ -85,10 +85,15 @@ test.describe('سناریوی مدیریت سفارشات و فیلترها در
|
||||
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: 'در حال پردازش' });
|
||||
// 4. راستیآزمایی مقدار دقیق متنی فیلد وضعیت سفارش در سطر جدول (ارسال شده)
|
||||
const orderStatusSelect = page.locator('[data-testid="order-status-select"]').first();
|
||||
await expect(orderStatusSelect).toBeVisible({ timeout: 10000 });
|
||||
await expect(orderStatusSelect).toHaveValue('shipped');
|
||||
|
||||
// 5. راستیآزمایی دراپداون فیلتر وضعیت در بالای صفحه و انتخاب وضعیت جدید
|
||||
const topFilterSelect = page.locator('select').first();
|
||||
await expect(topFilterSelect).toBeVisible();
|
||||
await topFilterSelect.selectOption({ label: 'ارسال شده' });
|
||||
await expect(page).toHaveURL(/status=/);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,109 @@
|
||||
import { test, expect } from '../../fixtures';
|
||||
|
||||
test.describe('سناریوی سطوح دسترسی و تفکیک نقشهای کاربران و ادمین (Admin RBAC Roles)', () => {
|
||||
test('لاگین سوپر ادمین -> مدیریت کاربران -> مشاهده تفکیک دقیق نقشهای کاربری، همکار B2B و مدیر کل', async ({ page }) => {
|
||||
// Intercept and mock Admin Auth & Users API
|
||||
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_superadmin_jwt',
|
||||
user: { id: 'super-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_superadmin_jwt',
|
||||
user: { id: 'super-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({
|
||||
id: 'super-admin-1',
|
||||
email: 'admin@canina.ir',
|
||||
role: 'SUPER_ADMIN',
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route('**/api/admin/users*', async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: [
|
||||
{
|
||||
id: 'user-regular',
|
||||
firstName: 'مهرداد',
|
||||
lastName: 'صادقی',
|
||||
mobile: '09121110001',
|
||||
role: 'User_PetOwner',
|
||||
walletBalance: 150000,
|
||||
},
|
||||
{
|
||||
id: 'user-b2b',
|
||||
firstName: 'دکتر علوی',
|
||||
lastName: 'کلینیک پارس',
|
||||
mobile: '09121110002',
|
||||
role: 'User_Wholesale',
|
||||
walletBalance: 5000000,
|
||||
},
|
||||
{
|
||||
id: 'user-admin',
|
||||
firstName: 'مدیر ارشد',
|
||||
lastName: 'سیستم',
|
||||
mobile: '09121110003',
|
||||
role: 'ADMIN',
|
||||
walletBalance: 0,
|
||||
},
|
||||
],
|
||||
meta: { total: 3, 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('/users', { waitUntil: 'domcontentloaded' });
|
||||
await expect(page).toHaveURL(/\/users/);
|
||||
|
||||
// 3. راستیآزمایی تفکیک قطعی نقشهای RBAC در ردیفهای جدول
|
||||
const regularBadge = page.locator('span').filter({ hasText: 'مشتری عادی' }).first();
|
||||
await expect(regularBadge).toBeVisible({ timeout: 10000 });
|
||||
|
||||
const wholesaleBadge = page.locator('span').filter({ hasText: 'خریدار عمده' }).first();
|
||||
await expect(wholesaleBadge).toBeVisible({ timeout: 10000 });
|
||||
|
||||
const adminBadge = page.locator('span').filter({ hasText: 'مدیر سیستم' }).first();
|
||||
await expect(adminBadge).toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user