test(e2e): refactor 6 e2e suites with strict assertions, add mutation verification and update test coverage map
This commit is contained in:
1 parent
3c325c412c
commit
6ef293ea59
28 files changed
+20676
-16743
No files matched your search
@@ -1,36 +1,35 @@
|
||||
import { test, expect } from '../../fixtures';
|
||||
|
||||
test.describe('سناریوی عملیات پیشرفته سبد خرید (Cart Drawer Interactive Operations)', () => {
|
||||
test('افزودن کالا به سبد -> افزایش و کاهش تعداد -> حذف کالا -> بررسی حالت خالی', async ({ page }) => {
|
||||
// 1. ورود به فروشگاه
|
||||
test.describe('سناریوی عملیات پیشرفته سبد خرید (Cart Operations & State Synchronization)', () => {
|
||||
test('ورود به صفحه محصول -> افزودن مستقیم به سبد خرید -> راستیآزمایی در تسویهحساب', async ({ page, isMobile }) => {
|
||||
// 1. ورود مستقیم به صفحه یک محصول مشخص
|
||||
await page.goto('/shop', { waitUntil: 'domcontentloaded' });
|
||||
await expect(page).toHaveURL(/\/shop/);
|
||||
|
||||
// 2. افزودن محصول به سبد خرید
|
||||
const buyButton = page.locator('button').filter({ hasText: /خرید|افزودن به سبد/i }).first();
|
||||
await expect(buyButton).toBeVisible({ timeout: 15000 });
|
||||
await buyButton.click();
|
||||
await page.waitForTimeout(500);
|
||||
const productCard = page.locator('a[href^="/shop/"]').first();
|
||||
await expect(productCard).toBeVisible({ timeout: 20000 });
|
||||
|
||||
// 3. تست افزایش تعداد با دکمه +
|
||||
const plusButton = page.locator('button').filter({ hasText: '+' }).first();
|
||||
if (await plusButton.isVisible()) {
|
||||
await plusButton.click();
|
||||
await page.waitForTimeout(300);
|
||||
const productHref = await productCard.getAttribute('href');
|
||||
expect(productHref).toBeTruthy();
|
||||
|
||||
await page.goto(productHref!, { waitUntil: 'domcontentloaded' });
|
||||
|
||||
// 2. کلیک روی دکمه «افزودن به سبد» متناسب با دسکتاپ یا موبایل
|
||||
if (isMobile) {
|
||||
const mobileAddBtn = page.locator('div.fixed.bottom-0 button').filter({ hasText: /افزودن به سبد/i }).first();
|
||||
await expect(mobileAddBtn).toBeVisible({ timeout: 15000 });
|
||||
await mobileAddBtn.click();
|
||||
} else {
|
||||
const desktopAddBtn = page.locator('button').filter({ hasText: /افزودن به سبد خرید/i }).first();
|
||||
await expect(desktopAddBtn).toBeVisible({ timeout: 15000 });
|
||||
await desktopAddBtn.click();
|
||||
}
|
||||
|
||||
// 4. تست کاهش تعداد با دکمه -
|
||||
const minusButton = page.locator('button').filter({ hasText: '-' }).first();
|
||||
if (await minusButton.isVisible()) {
|
||||
await minusButton.click();
|
||||
await page.waitForTimeout(300);
|
||||
}
|
||||
|
||||
// 5. باز کردن دراور یا صفحه تسویهحساب
|
||||
// 3. رفتن به صفحه تسویهحساب و راستیآزمایی حضور کالا و دکمه پرداخت
|
||||
await page.goto('/checkout', { waitUntil: 'domcontentloaded' });
|
||||
await expect(page).toHaveURL(/\/checkout/);
|
||||
|
||||
const checkoutSummary = page.locator('button, div, h2, span').filter({ hasText: /پرداخت|فاکتور|سبد خرید|مجموع/i }).first();
|
||||
await expect(checkoutSummary).toBeVisible({ timeout: 10000 });
|
||||
const submitOrderBtn = page.getByRole('button', { name: /پرداخت و تکمیل سفارش/i });
|
||||
await expect(submitOrderBtn).toBeVisible({ timeout: 15000 });
|
||||
});
|
||||
});
|
||||
@@ -1,31 +1,63 @@
|
||||
import { test, expect } from '../../fixtures';
|
||||
|
||||
test.describe('سناریوی پیگیری سفارشات (Order Tracking Flow & Edge Cases)', () => {
|
||||
test('ورود به صفحه پیگیری -> استعلام کد نامعتبر (Edge Case) -> استعلام سفارش معتبر', async ({ page }) => {
|
||||
test('استعلام کد رهگیری نامعتبر -> راستیآزمایی پیام خطا -> ثبت و استعلام سفارش معتبر', async ({ page }) => {
|
||||
// 1. ورود به صفحه /track
|
||||
await page.goto('/track', { waitUntil: 'domcontentloaded' });
|
||||
await expect(page).toHaveURL(/\/track/);
|
||||
|
||||
// 2. بررسی وجود المانهای پیگیری و فیلد ورودی
|
||||
const trackingInput = page.locator('input[placeholder*="شماره سفارش"], input[placeholder*="کد رهگیری"]').first();
|
||||
await expect(trackingInput).toBeVisible({ timeout: 15000 });
|
||||
// 2. راستیآزمایی وجود المانهای ورودی و دکمه استعلام
|
||||
const trackingInput = page.locator('input[placeholder*="شماره سفارش"]');
|
||||
await expect(trackingInput).toBeVisible({ timeout: 20000 });
|
||||
|
||||
const trackBtn = page.getByRole('button', { name: /رهگیری|پیگیری|استعلام/i }).or(
|
||||
page.locator('button').filter({ hasText: /رهگیری|پیگیری/i })
|
||||
).first();
|
||||
const trackBtn = page.getByRole('button', { name: 'رهگیری آنی' });
|
||||
await expect(trackBtn).toBeVisible();
|
||||
|
||||
// 3. تست Edge Case: ورود کد پیگیری نامعتبر
|
||||
// 3. تست منفی (Negative Test): استعلام کد رهگیری نامعتبر/ساختگی
|
||||
await trackingInput.fill('INVALID-TRACK-99999');
|
||||
await trackBtn.click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
// 4. تست ورود کد رهگیری ساختگی یا بررسی ساختار تایملاین وضعیت
|
||||
await trackingInput.fill('CN-10001');
|
||||
// راستیآزمایی پیام صریح خطای عدم یافت سفارش (نه فقط پاس شدن بدون بررسی)
|
||||
const notFoundMessage = page.locator('p').filter({ hasText: 'سفارشی یافت نشد. لطفاً شماره سفارش صحیح را وارد کنید.' });
|
||||
await expect(notFoundMessage).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// 4. تزریق یک سفارش به استیت لوکال zustand (کلید canina-cart)
|
||||
await page.evaluate(() => {
|
||||
const mockOrder = {
|
||||
id: 'CN-88888',
|
||||
trackingNumber: 'IR-POST-88888',
|
||||
date: new Date().toISOString(),
|
||||
items: [{ product: { id: 'p1', name: 'مکمل کلسیم و مفاصل سگ Canina' }, quantity: 2 }],
|
||||
total: 1500000,
|
||||
status: 'processing',
|
||||
};
|
||||
const cartState = {
|
||||
state: {
|
||||
items: [],
|
||||
orders: [mockOrder],
|
||||
isOpen: false,
|
||||
isSubscribed: false,
|
||||
charityDonation: 0,
|
||||
coupon: null,
|
||||
},
|
||||
version: 0,
|
||||
};
|
||||
localStorage.setItem('canina-cart', JSON.stringify(cartState));
|
||||
});
|
||||
|
||||
// بارگذاری مجدد صفحه برای لود سفارش تزریق شده در zustand
|
||||
await page.reload({ waitUntil: 'domcontentloaded' });
|
||||
|
||||
// 5. استعلام شماره سفارش معتبر و بررسی تایملاین و محتویات فاکتور
|
||||
await trackingInput.fill('CN-88888');
|
||||
await trackBtn.click();
|
||||
|
||||
// 5. بررسی تایملاین مراحل تحویل (ثبت سفارش، آمادهسازی، ارسال)
|
||||
const timelineStep = page.locator('div, h4, span').filter({ hasText: /ثبت سفارش|آمادهسازی|تحویل|وضعیت/i }).first();
|
||||
await expect(timelineStep).toBeVisible({ timeout: 10000 });
|
||||
// راستیآزمایی تایملاین مراحل
|
||||
await expect(page.locator('h4').filter({ hasText: 'ثبت سفارش' })).toBeVisible({ timeout: 10000 });
|
||||
await expect(page.locator('h4').filter({ hasText: 'آمادهسازی در انبار' })).toBeVisible();
|
||||
|
||||
// راستیآزمایی محتویات اقلام فاکتور و کد مرسوله
|
||||
await expect(page.locator('p').filter({ hasText: 'IR-POST-88888' })).toBeVisible();
|
||||
await expect(page.locator('span').filter({ hasText: 'مکمل کلسیم و مفاصل سگ Canina' })).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -1,48 +1,29 @@
|
||||
import { test, expect } from '../../fixtures';
|
||||
|
||||
test.describe('سناریوی جستجو، فیلترها و مرتبسازی در فروشگاه (Shop Filter, Search & Edge Cases)', () => {
|
||||
test('جستجوی محصول، فیلتر بر اساس علائم و دستهها، و مدیریت حالت بدون نتیجه', async ({ page }) => {
|
||||
// 1. ورود به صفحه فروشگاه
|
||||
test('جستجوی محصول -> فیلتر علائم و دستهها -> راستیآزمایی وضعیت خالی بدون فالبک', async ({ page }) => {
|
||||
// 1. ورود به صفحه فروشگاه و راستیآزمایی URL
|
||||
await page.goto('/shop', { waitUntil: 'domcontentloaded' });
|
||||
await expect(page).toHaveURL(/\/shop/);
|
||||
|
||||
// 2. تست باکس جستجو
|
||||
const searchInput = page.locator('input[placeholder*="جستجو"], input[type="search"]').first();
|
||||
if (await searchInput.isVisible()) {
|
||||
// جستجوی یک کلمه کلیدی موجود
|
||||
await searchInput.fill('مفاصل');
|
||||
await page.waitForTimeout(500);
|
||||
// 2. راستیآزمایی اجباری وجود کارتهای اولیه کاتالوگ
|
||||
const productCard = page.locator('a[href^="/shop/"]').first();
|
||||
await expect(productCard).toBeVisible({ timeout: 20000 });
|
||||
|
||||
// پاک کردن و جستجوی عبارت ناموجود برای تست Edge Case (بدون نتیجه)
|
||||
await searchInput.fill('عبارت_ناموجود_تستی_۱۲۳۴۵۶');
|
||||
await page.waitForTimeout(500);
|
||||
// 3. جستجوی عبارت ناموجود از طریق URL query parameter
|
||||
await page.goto('/shop?search=%D8%B9%D8%A8%D8%A7%D8%B1%D8%AA_%D9%86%D8%A7%D9%85%D9%88%D8%AC%D9%88%D8%AF_99999', { waitUntil: 'domcontentloaded' });
|
||||
|
||||
// بررسی وضعیت خالی / عدم یافت محصول یا پاک کردن فیلتر
|
||||
const clearSearchOrEmpty = page.locator('text=یافت نشد').or(
|
||||
page.locator('button').filter({ hasText: /پاک کردن|نمایش همه/i })
|
||||
).or(searchInput);
|
||||
await expect(clearSearchOrEmpty.first()).toBeVisible();
|
||||
// راستیآزمایی پیام صریح عدم یافت محصول
|
||||
const emptyStateHeading = page.locator('h3').filter({ hasText: 'محصولی یافت نشد!' });
|
||||
await expect(emptyStateHeading).toBeVisible({ timeout: 15000 });
|
||||
|
||||
// بازگردانی جستجو به حالت عادی
|
||||
await searchInput.fill('');
|
||||
}
|
||||
// 4. بازگشت به صفحه اصلی فروشگاه و راستیآزمایی بارگذاری مجدد کاتالوگ
|
||||
await page.goto('/shop', { waitUntil: 'domcontentloaded' });
|
||||
await expect(productCard).toBeVisible({ timeout: 15000 });
|
||||
|
||||
// 3. تست دکمههای فیلتر دستهبندی
|
||||
const categoryTabs = page.locator('button, a').filter({ hasText: /مفاصل|مکمل|پت|ویتامین/i }).first();
|
||||
if (await categoryTabs.isVisible()) {
|
||||
await categoryTabs.click();
|
||||
await page.waitForTimeout(500);
|
||||
}
|
||||
|
||||
// 4. تست کلیک روی تگ علائم یا اندیکاسیون (Symptom Badges)
|
||||
const symptomBadge = page.locator('a[href*="symptom="], button[data-symptom]').first();
|
||||
if (await symptomBadge.isVisible()) {
|
||||
await symptomBadge.click();
|
||||
await page.waitForTimeout(500);
|
||||
}
|
||||
|
||||
// 5. بررسی نمایش حداقل یک کارت محصول یا ساختار گرید کاتالوگ
|
||||
const productGrid = page.locator('a[href^="/shop/"], div[data-product-card]').first();
|
||||
await expect(productGrid).toBeVisible({ timeout: 15000 });
|
||||
// 5. تست فیلتر دستهبندی و راستیآزمایی تغییر URL به دستهبندی جدید
|
||||
await page.goto('/shop?category=joints', { waitUntil: 'domcontentloaded' });
|
||||
await expect(page).toHaveURL(/category=joints/);
|
||||
await expect(productCard).toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user