37 lines
1.7 KiB
TypeScript
37 lines
1.7 KiB
TypeScript
import { test, expect } from '../../fixtures';
|
|
|
|
test.describe('سناریوی عملیات پیشرفته سبد خرید (Cart Drawer Interactive Operations)', () => {
|
|
test('افزودن کالا به سبد -> افزایش و کاهش تعداد -> حذف کالا -> بررسی حالت خالی', async ({ page }) => {
|
|
// 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);
|
|
|
|
// 3. تست افزایش تعداد با دکمه +
|
|
const plusButton = page.locator('button').filter({ hasText: '+' }).first();
|
|
if (await plusButton.isVisible()) {
|
|
await plusButton.click();
|
|
await page.waitForTimeout(300);
|
|
}
|
|
|
|
// 4. تست کاهش تعداد با دکمه -
|
|
const minusButton = page.locator('button').filter({ hasText: '-' }).first();
|
|
if (await minusButton.isVisible()) {
|
|
await minusButton.click();
|
|
await page.waitForTimeout(300);
|
|
}
|
|
|
|
// 5. باز کردن دراور یا صفحه تسویهحساب
|
|
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 });
|
|
});
|
|
});
|