36 lines
1.8 KiB
TypeScript
36 lines
1.8 KiB
TypeScript
import { test, expect } from '../../fixtures';
|
|
|
|
test.describe('سناریوی عملیات پیشرفته سبد خرید (Cart Operations & State Synchronization)', () => {
|
|
test('ورود به صفحه محصول -> افزودن مستقیم به سبد خرید -> راستیآزمایی در تسویهحساب', async ({ page, isMobile }) => {
|
|
// 1. ورود مستقیم به صفحه یک محصول مشخص
|
|
await page.goto('/shop', { waitUntil: 'domcontentloaded' });
|
|
await expect(page).toHaveURL(/\/shop/);
|
|
|
|
const productCard = page.locator('a[href^="/shop/"]').first();
|
|
await expect(productCard).toBeVisible({ timeout: 20000 });
|
|
|
|
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();
|
|
}
|
|
|
|
// 3. رفتن به صفحه تسویهحساب و راستیآزمایی حضور کالا و دکمه پرداخت
|
|
await page.goto('/checkout', { waitUntil: 'domcontentloaded' });
|
|
await expect(page).toHaveURL(/\/checkout/);
|
|
|
|
const submitOrderBtn = page.getByRole('button', { name: /پرداخت و تکمیل سفارش/i });
|
|
await expect(submitOrderBtn).toBeVisible({ timeout: 15000 });
|
|
});
|
|
});
|