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
@@ -110,6 +110,7 @@ const ArchiveProductCard: React.FC<{ product: Product }> = ({ product }) => {
|
||||
className="h-full"
|
||||
>
|
||||
<Link
|
||||
data-testid="archive-product-card"
|
||||
href={productUrl}
|
||||
className="group bg-white rounded-[2.5rem] border border-medical-gray-200 overflow-hidden hover:shadow-2xl transition-all flex flex-col h-full relative"
|
||||
>
|
||||
@@ -294,8 +295,14 @@ export default function ArchivePage({
|
||||
return labels;
|
||||
}, [categories]);
|
||||
|
||||
// Sync state with prop change (e.g. from Header menu)
|
||||
// Sync state with prop change (e.g. from Header menu / Direct navigation)
|
||||
const prevInitialRef = React.useRef({ category: initialCategory, search: initialSearch });
|
||||
useEffect(() => {
|
||||
if (prevInitialRef.current.category === initialCategory && prevInitialRef.current.search === initialSearch) {
|
||||
return;
|
||||
}
|
||||
prevInitialRef.current = { category: initialCategory, search: initialSearch };
|
||||
|
||||
// Normalize Input (Trim and lowercase)
|
||||
const normSearch = (initialSearch || "").trim().toLowerCase();
|
||||
const normCat = initialCategory.trim().toLowerCase();
|
||||
@@ -303,14 +310,10 @@ export default function ArchivePage({
|
||||
const mapKey = normSearch || normCat;
|
||||
const mapping = CATEGORY_MAP[mapKey];
|
||||
|
||||
if (selectedCategory === initialCategory && searchQuery === initialSearch) {
|
||||
return;
|
||||
}
|
||||
|
||||
Promise.resolve().then(() => {
|
||||
setIsUpdating(true);
|
||||
|
||||
// Reset ALL other filters when a new category/solution is selected from menu
|
||||
// Reset other filters when initial URL route prop changes
|
||||
setSelectedPet("all");
|
||||
setActiveSymptoms([]);
|
||||
setSearchQuery("");
|
||||
@@ -349,7 +352,9 @@ export default function ArchivePage({
|
||||
|
||||
const queryString = params.toString();
|
||||
const newUrl = `/shop${queryString ? `?${queryString}` : ''}`;
|
||||
router.push(newUrl, { scroll: false });
|
||||
if (typeof window !== 'undefined' && window.location.pathname + window.location.search !== newUrl) {
|
||||
router.replace(newUrl, { scroll: false });
|
||||
}
|
||||
}, [selectedCategory, selectedPet, searchQuery, activeSymptoms, prescriptionFilter, router]);
|
||||
|
||||
const fetchProducts = useCallback(async () => {
|
||||
@@ -605,6 +610,7 @@ export default function ArchivePage({
|
||||
<div className="relative w-full sm:w-64">
|
||||
<Search className="absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-medical-gray-400" />
|
||||
<input
|
||||
data-testid="shop-search-input"
|
||||
type="text"
|
||||
placeholder="جستجوی محصول..."
|
||||
value={searchQuery}
|
||||
|
||||
@@ -440,6 +440,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
<div className="flex justify-between items-center">
|
||||
<label className="text-xs font-bold text-medical-gray-500">رمز عبور</label>
|
||||
<button
|
||||
data-testid="forgot-password-link"
|
||||
type="button"
|
||||
onClick={() => setView("forgot-password")}
|
||||
className="text-xs font-bold text-medical-gray-400 hover:text-canina-blue"
|
||||
|
||||
@@ -10,6 +10,7 @@ import SafeImage from "./SafeImage";
|
||||
import { useUserStore } from "../lib/store/userStore";
|
||||
import { useSettingsStore } from "../lib/store/settingsStore";
|
||||
import AuthModal from "./AuthModal";
|
||||
import DeleteConfirmModal from "./DeleteConfirmModal";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export default function CartDrawer({ isOpen, onClose, onCheckout, onShopNavigate }: {
|
||||
@@ -136,7 +137,7 @@ export default function CartDrawer({ isOpen, onClose, onCheckout, onShopNavigate
|
||||
>
|
||||
<Minus className="w-3 h-3" />
|
||||
</button>
|
||||
<span className="text-xs font-black min-w-[20px] text-center font-vazir">{toPersian(item.quantity)}</span>
|
||||
<span data-testid="cart-item-quantity" className="text-xs font-black min-w-[20px] text-center font-vazir">{toPersian(item.quantity)}</span>
|
||||
<button
|
||||
onClick={() => updateQuantity(item.product.id, item.quantity + 1)}
|
||||
className="p-1 hover:text-canina-blue transition-colors"
|
||||
@@ -146,6 +147,7 @@ export default function CartDrawer({ isOpen, onClose, onCheckout, onShopNavigate
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
data-testid="cart-item-delete-btn"
|
||||
onClick={() => setDeleteConfirmId(item.product.id)}
|
||||
className="text-medical-gray-300 hover:text-red-500 transition-colors"
|
||||
>
|
||||
@@ -335,7 +337,7 @@ export default function CartDrawer({ isOpen, onClose, onCheckout, onShopNavigate
|
||||
<div className="flex items-center justify-between border-t border-medical-gray-200 pt-4 px-2">
|
||||
<span className="text-lg font-black text-medical-gray-900 italic">مجموع قابل پرداخت</span>
|
||||
<div className="text-left">
|
||||
<p className="text-2xl font-black text-canina-blue tracking-tighter leading-none font-vazir">{toPersian(getTotal().toLocaleString())}</p>
|
||||
<p data-testid="cart-total-price" className="text-2xl font-black text-canina-blue tracking-tighter leading-none font-vazir">{toPersian(getTotal().toLocaleString())}</p>
|
||||
<p className="text-[10px] text-medical-gray-400 font-bold">تومان</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -351,6 +353,20 @@ export default function CartDrawer({ isOpen, onClose, onCheckout, onShopNavigate
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
|
||||
<DeleteConfirmModal
|
||||
isOpen={Boolean(deleteConfirmId)}
|
||||
onClose={() => setDeleteConfirmId(null)}
|
||||
onConfirm={() => {
|
||||
if (deleteConfirmId) {
|
||||
removeItem(deleteConfirmId);
|
||||
setDeleteConfirmId(null);
|
||||
toast.success("محصول از سبد خرید حذف شد");
|
||||
}
|
||||
}}
|
||||
title="حذف از سبد خرید"
|
||||
message="آیا از حذف این مکمل دارویی از سبد خرید خود اطمینان دارید؟"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
|
||||
@@ -342,6 +342,7 @@ export default function Header({
|
||||
</div>
|
||||
) : (
|
||||
<button
|
||||
data-testid="header-login-btn"
|
||||
onClick={() => setIsAuthModalOpen(true)}
|
||||
className="flex items-center gap-1.5 px-2.5 py-2 sm:px-3.5 sm:py-2 bg-medical-gray-900 text-white hover:bg-canina-blue rounded-xl text-[11px] sm:text-xs font-black transition-all shadow-xs whitespace-nowrap"
|
||||
>
|
||||
@@ -354,6 +355,7 @@ export default function Header({
|
||||
{/* Shopping Cart Button */}
|
||||
{!isCartDisabled && (
|
||||
<button
|
||||
data-testid="cart-header-btn"
|
||||
onClick={onCartOpen}
|
||||
className="relative px-3.5 py-2 bg-canina-blue text-white rounded-xl text-xs font-black hover:bg-medical-gray-900 transition-all flex items-center gap-2 shadow-sm"
|
||||
>
|
||||
|
||||
@@ -888,6 +888,7 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
</button>
|
||||
) : (product.packageSize || 0) <= 0 ? (
|
||||
<button
|
||||
data-testid="product-desktop-out-of-stock-btn"
|
||||
onClick={() => toast.info("درخواست اطلاعرسانی موجودی ثبت شد")}
|
||||
className="w-[60%] flex items-center justify-center gap-1.5 px-4 bg-amber-500 text-white rounded-2xl h-16 font-black text-sm hover:bg-amber-600 transition-all shadow-xl shadow-amber-500/20 font-vazir whitespace-nowrap"
|
||||
>
|
||||
@@ -896,6 +897,7 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
data-testid="product-desktop-add-to-cart-btn"
|
||||
onClick={() => {
|
||||
addItem(product, itemQuantity, { quantity: calculation.dailyDose, unit: calculation.unit });
|
||||
toast.success(`${toPersian(itemQuantity)} عدد ${product.name} به سبد خرید اضافه شد`);
|
||||
@@ -1074,6 +1076,7 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
</a>
|
||||
) : isOutOfStock ? (
|
||||
<button
|
||||
data-testid="product-out-of-stock-btn"
|
||||
onClick={() => toast.info("درخواست اطلاعرسانی موجودی ثبت شد")}
|
||||
className="flex-1 bg-amber-500 text-white py-2.5 px-3 rounded-xl font-black text-xs hover:bg-amber-600 transition-all flex items-center justify-center gap-1.5 shadow-md shadow-amber-500/20 whitespace-nowrap"
|
||||
>
|
||||
@@ -1101,6 +1104,7 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
</div>
|
||||
|
||||
<button
|
||||
data-testid="product-add-to-cart-btn"
|
||||
onClick={() => {
|
||||
addItem(product, itemQuantity, { quantity: calculation.dailyDose, unit: calculation.unit });
|
||||
toast.success(`${toPersian(itemQuantity)} عدد به سبد خرید اضافه شد`);
|
||||
|
||||
Reference in new issue
Block a user