fix: read ticket category product groups
This commit is contained in:
@@ -148,11 +148,8 @@ const props = defineProps({
|
||||
|
||||
const emit = defineEmits(['back', 'open-travelers', 'open-orders', 'open-detail', 'buy'])
|
||||
const groups = computed(() =>
|
||||
Array.isArray(props.homeData.categories) ? props.homeData.categories : []
|
||||
)
|
||||
const products = computed(() =>
|
||||
Array.isArray(props.homeData.products?.records)
|
||||
? props.homeData.products.records
|
||||
Array.isArray(props.homeData.categoryProductGroups)
|
||||
? props.homeData.categoryProductGroups
|
||||
: []
|
||||
)
|
||||
const preferredCategoryId = String(props.homeData.selectedCategoryId || '')
|
||||
@@ -179,9 +176,7 @@ const isMp4Video = (url) => {
|
||||
const isActiveGroup = (groupId) =>
|
||||
String(groupId) === String(activeGroupId.value)
|
||||
const productsForGroup = (group) =>
|
||||
products.value.filter(
|
||||
(product) => String(product.categoryId) === String(group.categoryId)
|
||||
)
|
||||
Array.isArray(group.products) ? group.products : []
|
||||
|
||||
const selectGroup = (groupId) => {
|
||||
activeGroupId.value = groupId
|
||||
|
||||
@@ -104,10 +104,14 @@ test("TicketHome consumes scenic home response fields directly", async () => {
|
||||
assert.ok(source.includes(field), `${field} is not rendered`);
|
||||
}
|
||||
|
||||
assert.match(source, /props\.homeData\.products\?\.records/);
|
||||
assert.match(source, /props\.homeData\.categoryProductGroups/);
|
||||
assert.match(
|
||||
source,
|
||||
/product\.categoryId\) === String\(group\.categoryId/
|
||||
/Array\.isArray\(group\.products\) \? group\.products : \[\]/
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
source,
|
||||
/homeData\.categories|homeData\.products|products\.value\.filter/
|
||||
);
|
||||
assert.match(source, /emit\('open-detail', product\.commodityId\)/);
|
||||
assert.match(source, /emit\('buy', product\.commodityId\)/);
|
||||
|
||||
Reference in New Issue
Block a user