fix: adds options to default relations in storefront product endpoints (#712)
This commit is contained in:
@@ -141,6 +141,18 @@ Object {
|
|||||||
"material": null,
|
"material": null,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
"mid_code": null,
|
"mid_code": null,
|
||||||
|
"options": Array [
|
||||||
|
Object {
|
||||||
|
"created_at": Any<String>,
|
||||||
|
"deleted_at": null,
|
||||||
|
"id": "test-variant-option",
|
||||||
|
"metadata": null,
|
||||||
|
"option_id": "test-option",
|
||||||
|
"updated_at": Any<String>,
|
||||||
|
"value": "Default variant",
|
||||||
|
"variant_id": "test-variant",
|
||||||
|
},
|
||||||
|
],
|
||||||
"origin_country": null,
|
"origin_country": null,
|
||||||
"prices": Array [
|
"prices": Array [
|
||||||
Object {
|
Object {
|
||||||
@@ -178,6 +190,18 @@ Object {
|
|||||||
"material": null,
|
"material": null,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
"mid_code": null,
|
"mid_code": null,
|
||||||
|
"options": Array [
|
||||||
|
Object {
|
||||||
|
"created_at": Any<String>,
|
||||||
|
"deleted_at": null,
|
||||||
|
"id": "test-variant-option-2",
|
||||||
|
"metadata": null,
|
||||||
|
"option_id": "test-option",
|
||||||
|
"updated_at": Any<String>,
|
||||||
|
"value": "Default variant 2",
|
||||||
|
"variant_id": "test-variant_2",
|
||||||
|
},
|
||||||
|
],
|
||||||
"origin_country": null,
|
"origin_country": null,
|
||||||
"prices": Array [
|
"prices": Array [
|
||||||
Object {
|
Object {
|
||||||
@@ -215,6 +239,18 @@ Object {
|
|||||||
"material": null,
|
"material": null,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
"mid_code": null,
|
"mid_code": null,
|
||||||
|
"options": Array [
|
||||||
|
Object {
|
||||||
|
"created_at": Any<String>,
|
||||||
|
"deleted_at": null,
|
||||||
|
"id": "test-variant-option-1",
|
||||||
|
"metadata": null,
|
||||||
|
"option_id": "test-option",
|
||||||
|
"updated_at": Any<String>,
|
||||||
|
"value": "Default variant 1",
|
||||||
|
"variant_id": "test-variant_1",
|
||||||
|
},
|
||||||
|
],
|
||||||
"origin_country": null,
|
"origin_country": null,
|
||||||
"prices": Array [
|
"prices": Array [
|
||||||
Object {
|
Object {
|
||||||
|
|||||||
@@ -68,6 +68,12 @@ describe("/store/products", () => {
|
|||||||
product_id: "test-product",
|
product_id: "test-product",
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
created_at: expect.any(String),
|
||||||
|
updated_at: expect.any(String),
|
||||||
|
},
|
||||||
|
],
|
||||||
prices: [
|
prices: [
|
||||||
{
|
{
|
||||||
id: "test-money-amount",
|
id: "test-money-amount",
|
||||||
@@ -105,6 +111,12 @@ describe("/store/products", () => {
|
|||||||
product_id: "test-product",
|
product_id: "test-product",
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
created_at: expect.any(String),
|
||||||
|
updated_at: expect.any(String),
|
||||||
|
},
|
||||||
|
],
|
||||||
prices: [
|
prices: [
|
||||||
{
|
{
|
||||||
id: "test-money-amount",
|
id: "test-money-amount",
|
||||||
@@ -117,7 +129,6 @@ describe("/store/products", () => {
|
|||||||
id: "test-price2",
|
id: "test-price2",
|
||||||
region_id: null,
|
region_id: null,
|
||||||
sale_amount: null,
|
sale_amount: null,
|
||||||
updated_at: expect.any(String),
|
|
||||||
variant_id: "test-variant_2",
|
variant_id: "test-variant_2",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -142,6 +153,12 @@ describe("/store/products", () => {
|
|||||||
product_id: "test-product",
|
product_id: "test-product",
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
created_at: expect.any(String),
|
||||||
|
updated_at: expect.any(String),
|
||||||
|
},
|
||||||
|
],
|
||||||
prices: [
|
prices: [
|
||||||
{
|
{
|
||||||
id: "test-money-amount",
|
id: "test-money-amount",
|
||||||
@@ -254,16 +271,6 @@ describe("/store/products", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Fetching variant options without additional relation fails", async () => {
|
|
||||||
const api = useApi()
|
|
||||||
|
|
||||||
const response = await api.get("/store/products/test-product")
|
|
||||||
|
|
||||||
const product = response.data.product
|
|
||||||
|
|
||||||
expect(product.variants.some((variant) => variant.options)).toEqual(false)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("lists all published products", async () => {
|
it("lists all published products", async () => {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export default (app) => {
|
|||||||
export const defaultRelations = [
|
export const defaultRelations = [
|
||||||
"variants",
|
"variants",
|
||||||
"variants.prices",
|
"variants.prices",
|
||||||
|
"variants.options",
|
||||||
"options",
|
"options",
|
||||||
"options.values",
|
"options.values",
|
||||||
"images",
|
"images",
|
||||||
|
|||||||
Reference in New Issue
Block a user