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 emit = defineEmits(['back', 'open-travelers', 'open-orders', 'open-detail', 'buy'])
|
||||||
const groups = computed(() =>
|
const groups = computed(() =>
|
||||||
Array.isArray(props.homeData.categories) ? props.homeData.categories : []
|
Array.isArray(props.homeData.categoryProductGroups)
|
||||||
)
|
? props.homeData.categoryProductGroups
|
||||||
const products = computed(() =>
|
|
||||||
Array.isArray(props.homeData.products?.records)
|
|
||||||
? props.homeData.products.records
|
|
||||||
: []
|
: []
|
||||||
)
|
)
|
||||||
const preferredCategoryId = String(props.homeData.selectedCategoryId || '')
|
const preferredCategoryId = String(props.homeData.selectedCategoryId || '')
|
||||||
@@ -179,9 +176,7 @@ const isMp4Video = (url) => {
|
|||||||
const isActiveGroup = (groupId) =>
|
const isActiveGroup = (groupId) =>
|
||||||
String(groupId) === String(activeGroupId.value)
|
String(groupId) === String(activeGroupId.value)
|
||||||
const productsForGroup = (group) =>
|
const productsForGroup = (group) =>
|
||||||
products.value.filter(
|
Array.isArray(group.products) ? group.products : []
|
||||||
(product) => String(product.categoryId) === String(group.categoryId)
|
|
||||||
)
|
|
||||||
|
|
||||||
const selectGroup = (groupId) => {
|
const selectGroup = (groupId) => {
|
||||||
activeGroupId.value = 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.ok(source.includes(field), `${field} is not rendered`);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.match(source, /props\.homeData\.products\?\.records/);
|
assert.match(source, /props\.homeData\.categoryProductGroups/);
|
||||||
assert.match(
|
assert.match(
|
||||||
source,
|
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\('open-detail', product\.commodityId\)/);
|
||||||
assert.match(source, /emit\('buy', product\.commodityId\)/);
|
assert.match(source, /emit\('buy', product\.commodityId\)/);
|
||||||
|
|||||||
Reference in New Issue
Block a user