fix(product-list): prioritize first image in non-carousel layouts and update tests
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
No hay productos disponibles en este momento.
|
No hay productos disponibles en este momento.
|
||||||
</p>
|
</p>
|
||||||
} @else {
|
} @else {
|
||||||
@for (group of catalog(); track group.id) {
|
@for (group of catalog(); track group.id; let first = $first) {
|
||||||
<app-store-section [attr.id]="group.code" [title]="group.title">
|
<app-store-section [attr.id]="group.code" [title]="group.title">
|
||||||
<app-product-list
|
<app-product-list
|
||||||
[layout]="group.layout"
|
[layout]="group.layout"
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
[items]="group.items"
|
[items]="group.items"
|
||||||
[loading]="isGroupLoading(group.id)"
|
[loading]="isGroupLoading(group.id)"
|
||||||
[loadImages]="!hasMainCarouselImages() || mainCarouselReady()"
|
[loadImages]="!hasMainCarouselImages() || mainCarouselReady()"
|
||||||
|
[prioritizeFirstImage]="first && !hasMainCarouselImages()"
|
||||||
[unavailableVariantIds]="unavailableVariantIds()"
|
[unavailableVariantIds]="unavailableVariantIds()"
|
||||||
[savingProductIds]="savingProductIds()"
|
[savingProductIds]="savingProductIds()"
|
||||||
(buy)="onBuyProduct($event)"
|
(buy)="onBuyProduct($event)"
|
||||||
|
|||||||
@@ -51,7 +51,9 @@
|
|||||||
[title]="item.nombre"
|
[title]="item.nombre"
|
||||||
[originalPrice]="price(item)"
|
[originalPrice]="price(item)"
|
||||||
[unavailableMessage]="item.unavailable_message ?? null"
|
[unavailableMessage]="item.unavailable_message ?? null"
|
||||||
[imagePriority]="loadImages() && index < 4"
|
[imagePriority]="
|
||||||
|
loadImages() && prioritizeFirstImage() && groupLayout() !== 'carousel' && index === 0
|
||||||
|
"
|
||||||
(buy)="emitProductDetailBuy(item)"
|
(buy)="emitProductDetailBuy(item)"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,14 @@ describe('ProductListComponent', () => {
|
|||||||
|
|
||||||
expect(element.querySelector('.product-list--column')).not.toBeNull();
|
expect(element.querySelector('.product-list--column')).not.toBeNull();
|
||||||
expect(element.querySelectorAll('app-product-column-with-image')).toHaveLength(2);
|
expect(element.querySelectorAll('app-product-column-with-image')).toHaveLength(2);
|
||||||
|
expect(element.querySelectorAll('img[fetchpriority="high"]')).toHaveLength(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not prioritize images rendered in a circular carousel', async () => {
|
||||||
|
const fixture = await render('column_with_image', items, 'carousel');
|
||||||
|
const element = fixture.nativeElement as HTMLElement;
|
||||||
|
|
||||||
|
expect(element.querySelectorAll('img[fetchpriority="high"]')).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders cart products next to each other in the column grid', async () => {
|
it('renders cart products next to each other in the column grid', async () => {
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ export class ProductListComponent {
|
|||||||
readonly items = input.required<CatalogFeaturedItems>();
|
readonly items = input.required<CatalogFeaturedItems>();
|
||||||
readonly loading = input(false);
|
readonly loading = input(false);
|
||||||
readonly loadImages = input(true);
|
readonly loadImages = input(true);
|
||||||
|
readonly prioritizeFirstImage = input(true);
|
||||||
readonly unavailableVariantIds = input<ReadonlySet<number>>(new Set<number>());
|
readonly unavailableVariantIds = input<ReadonlySet<number>>(new Set<number>());
|
||||||
readonly savingProductIds = input<ReadonlySet<number>>(new Set<number>());
|
readonly savingProductIds = input<ReadonlySet<number>>(new Set<number>());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user