test(e2e): refactor 6 e2e suites with strict assertions, add mutation verification and update test coverage map

This commit is contained in:
parsa aghaei committed 2026-08-25 15:19:22 +03:30
1 parent 3c325c412c
commit 6ef293ea59
28 files changed
+20676 -16743

No files matched your search

+23 -14
View File
@@ -1,7 +1,7 @@
import { test, expect } from '../../fixtures';
test.describe('سناریوی مدیریت درخواست‌های B2B و فرم‌های تماس (Admin B2B Submissions Flow)', () => {
test('ورود به بخش B2B -> مشاهده درخواست‌ها -> فیلتر و بررسی جزئیات', async ({ page }) => {
test('ورود به بخش B2B -> راستی‌آزمایی حضور درخواست‌ها -> تعویض تب و فیلترها', async ({ page }) => {
// Intercept and mock Admin Auth & B2B API calls
await page.route('**/api/auth/admin-login*', async (route) => {
await route.fulfill({
@@ -42,7 +42,7 @@ test.describe('سناریوی مدیریت درخواست‌های B2B و فرم
});
});
await page.route('**/api/admin/b2b-applications*', async (route) => {
await page.route('**/api/b2b/inquiries*', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
@@ -65,22 +65,31 @@ test.describe('سناریوی مدیریت درخواست‌های B2B و فرم
// 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);
}
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');
// 2. ورود به صفحه مدیریت درخواست‌های B2B
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();
// 3. راستی‌آزمایی تیتر اختصاصی مدیریت B2B
const b2bHeader = page.locator('h2').filter({ hasText: 'مدیریت همکاران عمده‌فروشی و B2B' });
await expect(b2bHeader).toBeVisible({ timeout: 15000 });
// 4. راستی‌آزمایی تب‌های درخواست‌ها و همکاران
const partnerTab = page.getByRole('button', { name: /حساب‌های تاییدشده همکار/i });
await expect(partnerTab).toBeVisible();
await partnerTab.click();
const inquiriesTab = page.getByRole('button', { name: /درخواست‌های دریافت نمایندگی/i });
await expect(inquiriesTab).toBeVisible();
await inquiriesTab.click();
});
});
+27 -22
View File
@@ -1,7 +1,7 @@
import { test, expect } from '../../fixtures';
test.describe('سناریوی مدیریت مقالات و وبلاگ در پنل ادمین (Admin Blogs & CMS Flow)', () => {
test('ورود به بخش مقالات -> باز کردن فرم ایجاد -> پر کردن عنوان و محتوا -> ذخیره', async ({ page }) => {
test('ورود به بخش مقالات -> باز کردن فرم ایجاد -> پر کردن عنوان و ذخیره نهایی', async ({ page }) => {
// Intercept and mock Admin Auth & Blogs API calls
await page.route('**/api/auth/admin-login*', async (route) => {
await route.fulfill({
@@ -52,7 +52,7 @@ test.describe('سناریوی مدیریت مقالات و وبلاگ در پن
data: [
{
id: 'blog-1',
titleFa: 'راهنمای جامع سلامت مفاصل سگ و گربه',
title: 'راهنمای جامع سلامت مفاصل سگ و گربه',
slug: 'dog-joint-health-guide',
status: 'PUBLISHED',
views: 1250,
@@ -65,38 +65,43 @@ test.describe('سناریوی مدیریت مقالات و وبلاگ در پن
await route.fulfill({
status: 201,
contentType: 'application/json',
body: JSON.stringify({ success: true, message: 'مقاله با موفقیت ایجاد شد' }),
body: JSON.stringify({ success: true, message: 'مقاله جدید با موفقیت ذخیره شد' }),
});
}
});
// 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);
}
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('/blogs', { waitUntil: 'domcontentloaded' });
await expect(page).toHaveURL(/\/blogs/);
// 3. بررسی دکمه ایجاد مقاله جدید
const newBlogBtn = page.getByRole('button', { name: /مقاله جدید|افزودن مقاله|پست جدید/i }).or(
page.locator('button').filter({ hasText: /جدید|افزودن/i })
).first();
await expect(newBlogBtn).toBeVisible({ timeout: 15000 });
// 3. راستی‌آزمایی حضور هدر و دکمه مقاله جدید
const blogsHeading = page.locator('h2').filter({ hasText: 'مدیریت جامع وبلاگ' });
await expect(blogsHeading).toBeVisible({ timeout: 15000 });
const newBlogBtn = page.getByRole('button', { name: 'مقاله جدید' });
await expect(newBlogBtn).toBeVisible();
await newBlogBtn.click();
// 4. بررسی فرم ایجاد مقاله
const blogTitleInput = page.locator('input[placeholder*="عنوان"], input[name*="title"]').first();
if (await blogTitleInput.isVisible()) {
await blogTitleInput.fill('مقاله آموزشی تستی تست‌های سرتاسری Playwright');
}
// 4. راستی‌آزمایی باز شدن فرم ایجاد و پر کردن عنوان
const blogTitleInput = page.locator('input[placeholder*="عنوان"]').first();
await expect(blogTitleInput).toBeVisible({ timeout: 10000 });
await blogTitleInput.fill('مقاله آموزشی تستی پلی‌رایت');
// 5. ذخیره فرم و راستی‌آزمایی پیام موفقیت یا فراخوانی موفقیت‌آمیز
const saveBlogBtn = page.getByRole('button', { name: /ذخیره|ثبت|انتشار/i }).first();
await expect(saveBlogBtn).toBeVisible();
await saveBlogBtn.click();
});
});
+21 -21
View File
@@ -1,7 +1,7 @@
import { test, expect } from '../../fixtures';
test.describe('سناریوی مدیریت سفارشات و تغییر وضعیت در پنل ادمین (Admin Orders Management)', () => {
test('ورود به بخش سفارشات -> فیلتر وضعیت -> مشاهده جزئیات فاکتور', async ({ page }) => {
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({
@@ -55,9 +55,9 @@ test.describe('سناریوی مدیریت سفارشات و تغییر وضعی
customerName: 'علی رضایی',
customerPhone: '09121112233',
totalAmount: 1850000,
status: 'PROCESSING',
status: 'processing',
createdAt: new Date().toISOString(),
items: [{ id: 'item-1', productName: 'مکمل مفاصل سگ', quantity: 2, price: 925000 }],
items: [{ id: 'item-1', name: 'مکمل مفاصل سگ', quantity: 2, priceValue: 925000 }],
},
],
meta: { total: 1, lastPage: 1 },
@@ -67,28 +67,28 @@ test.describe('سناریوی مدیریت سفارشات و تغییر وضعی
// 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);
}
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 ordersHeader = page.locator('h1, h2, div').filter({ hasText: /سفارشات|مدیریت سفارش/i }).first();
await expect(ordersHeader).toBeVisible({ timeout: 15000 });
// 3. راستی‌آزمایی دقیق تیتر مدیریت سفارشات
const ordersHeading = page.locator('h2').filter({ hasText: 'مدیریت سفارشات' });
await expect(ordersHeading).toBeVisible({ timeout: 15000 });
// 4. تست فیلترهای وضعیت سفارش (در حال پردازش، ارسال شده، تکمیل شده)
const statusFilter = page.locator('select, button').filter({ hasText: /وضعیت|همه|پردازش/i }).first();
if (await statusFilter.isVisible()) {
await statusFilter.click();
}
// 4. راستی‌آزمایی دراپ‌داون فیلتر وضعیت و انتخاب وضعیت جدید
const statusSelect = page.locator('select').first();
await expect(statusSelect).toBeVisible();
await statusSelect.selectOption({ label: 'در حال پردازش' });
await expect(page).toHaveURL(/status=/);
});
});