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
@@ -73,6 +73,7 @@ const CATEGORY_MAP: Record<string, { category?: string; query?: string; symptoms
|
||||
|
||||
const ArchiveProductCard: React.FC<{ product: Product }> = ({ product }) => {
|
||||
const { addItem } = useCartStore();
|
||||
const cartItem = useCartStore((s) => s.items.find(i => i.product.id === product.id));
|
||||
const [isAdding, setIsAdding] = useState(false);
|
||||
const activePet = usePetStore(state => state.pets.find(p => p.id === state.activePetId) || null);
|
||||
const productUrl = `/shop/${product.slug || product.id}`;
|
||||
@@ -83,7 +84,7 @@ const ArchiveProductCard: React.FC<{ product: Product }> = ({ product }) => {
|
||||
setIsAdding(true);
|
||||
addItem(product, 1);
|
||||
toast.success(`${product.name} به سبد خرید اضافه شد`);
|
||||
setTimeout(() => setIsAdding(false), 800);
|
||||
setTimeout(() => setIsAdding(false), 400);
|
||||
};
|
||||
|
||||
const compatibility = useMemo(() => {
|
||||
@@ -180,41 +181,37 @@ const ArchiveProductCard: React.FC<{ product: Product }> = ({ product }) => {
|
||||
<span className="px-2.5 py-1.5 rounded-xl bg-rose-50 text-rose-600 border border-rose-100 text-[11px] font-bold font-vazir">
|
||||
ناموجود
|
||||
</span>
|
||||
) : !useSettingsStore.getState().getText("catalog_disable_cart", "false").includes("true") && (() => {
|
||||
const cartItem = useCartStore.getState().items.find(i => i.product.id === product.id);
|
||||
if (cartItem && cartItem.quantity > 0) {
|
||||
return (
|
||||
<div
|
||||
onClick={(e) => { e.preventDefault(); e.stopPropagation(); }}
|
||||
className="flex items-center gap-1 bg-canina-blue/10 border border-canina-blue/20 rounded-xl p-1"
|
||||
) : !useSettingsStore.getState().getText("catalog_disable_cart", "false").includes("true") && (
|
||||
cartItem && cartItem.quantity > 0 ? (
|
||||
<div
|
||||
onClick={(e) => { e.preventDefault(); e.stopPropagation(); }}
|
||||
className="flex items-center gap-1 bg-canina-blue/10 border border-canina-blue/20 rounded-xl p-1"
|
||||
>
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
useCartStore.getState().updateQuantity(product.id, cartItem.quantity + 1);
|
||||
}}
|
||||
className="w-7 h-7 rounded-lg bg-canina-blue text-white flex items-center justify-center font-bold text-xs"
|
||||
>
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
useCartStore.getState().updateQuantity(product.id, cartItem.quantity + 1);
|
||||
}}
|
||||
className="w-7 h-7 rounded-lg bg-canina-blue text-white flex items-center justify-center font-bold text-xs"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
<span className="w-5 text-center font-black text-canina-blue text-xs font-vazir">
|
||||
{toPersian(cartItem.quantity)}
|
||||
</span>
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
useCartStore.getState().updateQuantity(product.id, cartItem.quantity - 1);
|
||||
}}
|
||||
className="w-7 h-7 rounded-lg bg-white text-medical-gray-700 flex items-center justify-center font-bold text-xs shadow-sm"
|
||||
>
|
||||
-
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
+
|
||||
</button>
|
||||
<span className="w-5 text-center font-black text-canina-blue text-xs font-vazir">
|
||||
{toPersian(cartItem.quantity)}
|
||||
</span>
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
useCartStore.getState().updateQuantity(product.id, cartItem.quantity - 1);
|
||||
}}
|
||||
className="w-7 h-7 rounded-lg bg-white text-medical-gray-700 flex items-center justify-center font-bold text-xs shadow-sm"
|
||||
>
|
||||
-
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<button
|
||||
onClick={handleAddToCart}
|
||||
disabled={isAdding}
|
||||
@@ -223,8 +220,8 @@ const ArchiveProductCard: React.FC<{ product: Product }> = ({ product }) => {
|
||||
{isAdding ? <Loader2 className="w-3.5 h-3.5 animate-spin" /> : <Plus className="w-3.5 h-3.5" />}
|
||||
<span>خرید</span>
|
||||
</button>
|
||||
);
|
||||
})()}
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
Reference in new issue
Block a user