fix: adds options to default relations in storefront product endpoints (#712)

This commit is contained in:
Sebastian Rindom
2021-11-03 13:15:36 +01:00
committed by GitHub
parent 109d400720
commit e82737a035
3 changed files with 55 additions and 11 deletions

View File

@@ -141,6 +141,18 @@ Object {
"material": null,
"metadata": 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,
"prices": Array [
Object {
@@ -178,6 +190,18 @@ Object {
"material": null,
"metadata": 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,
"prices": Array [
Object {
@@ -215,6 +239,18 @@ Object {
"material": null,
"metadata": 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,
"prices": Array [
Object {

View File

@@ -68,6 +68,12 @@ describe("/store/products", () => {
product_id: "test-product",
created_at: expect.any(String),
updated_at: expect.any(String),
options: [
{
created_at: expect.any(String),
updated_at: expect.any(String),
},
],
prices: [
{
id: "test-money-amount",
@@ -105,6 +111,12 @@ describe("/store/products", () => {
product_id: "test-product",
created_at: expect.any(String),
updated_at: expect.any(String),
options: [
{
created_at: expect.any(String),
updated_at: expect.any(String),
},
],
prices: [
{
id: "test-money-amount",
@@ -117,7 +129,6 @@ describe("/store/products", () => {
id: "test-price2",
region_id: null,
sale_amount: null,
updated_at: expect.any(String),
variant_id: "test-variant_2",
},
],
@@ -142,6 +153,12 @@ describe("/store/products", () => {
product_id: "test-product",
created_at: expect.any(String),
updated_at: expect.any(String),
options: [
{
created_at: expect.any(String),
updated_at: expect.any(String),
},
],
prices: [
{
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 () => {
const api = useApi()

View File

@@ -16,6 +16,7 @@ export default (app) => {
export const defaultRelations = [
"variants",
"variants.prices",
"variants.options",
"options",
"options.values",
"images",