feat: Use tag ids instead of values wherever possible (#8394)
This commit is contained in:
@@ -8,7 +8,6 @@ export const getProductFixture = (
|
||||
status: "draft",
|
||||
// BREAKING: Images input changed from string[] to {url: string}[]
|
||||
images: [{ url: "test-image.png" }, { url: "test-image-2.png" }],
|
||||
tags: [{ value: "123" }, { value: "456" }],
|
||||
// BREAKING: Options input changed from {title: string}[] to {title: string, values: string[]}[]
|
||||
options: [
|
||||
{ title: "size", values: ["large", "small"] },
|
||||
|
||||
@@ -50,6 +50,9 @@ medusaIntegrationTestRunner({
|
||||
let baseType
|
||||
let baseRegion
|
||||
let baseCategory
|
||||
let baseTag1
|
||||
let baseTag2
|
||||
let newTag
|
||||
|
||||
let eventBus: IEventBusModuleService
|
||||
beforeAll(async () => {
|
||||
@@ -102,6 +105,22 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
).data.product_category
|
||||
|
||||
baseTag1 = (
|
||||
await api.post("/admin/product-tags", { value: "123" }, adminHeaders)
|
||||
).data.product_tag
|
||||
|
||||
baseTag2 = (
|
||||
await api.post("/admin/product-tags", { value: "456" }, adminHeaders)
|
||||
).data.product_tag
|
||||
|
||||
newTag = (
|
||||
await api.post(
|
||||
"/admin/product-tags",
|
||||
{ value: "new-tag" },
|
||||
adminHeaders
|
||||
)
|
||||
).data.product_tag
|
||||
|
||||
baseProduct = (
|
||||
await api.post(
|
||||
"/admin/products",
|
||||
@@ -111,6 +130,7 @@ medusaIntegrationTestRunner({
|
||||
collection_id: baseCollection.id,
|
||||
type_id: baseType.id,
|
||||
categories: [{ id: baseCategory.id }],
|
||||
tags: [{ id: baseTag1.id }, { id: baseTag2.id }],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
@@ -166,7 +186,7 @@ medusaIntegrationTestRunner({
|
||||
getProductFixture({
|
||||
title: "Proposed product",
|
||||
status: "proposed",
|
||||
tags: [{ value: "new-tag" }],
|
||||
tags: [{ id: newTag.id }],
|
||||
type_id: baseType.id,
|
||||
}),
|
||||
adminHeaders
|
||||
@@ -258,6 +278,7 @@ medusaIntegrationTestRunner({
|
||||
"/admin/products",
|
||||
getProductFixture({
|
||||
title: "Product with prices",
|
||||
tags: [{ id: baseTag1.id }, { id: baseTag2.id }],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
|
||||
@@ -33,6 +33,10 @@ medusaIntegrationTestRunner({
|
||||
let baseProduct
|
||||
let baseRegion
|
||||
let baseCategory
|
||||
let baseTag1
|
||||
let baseTag2
|
||||
let baseTag3
|
||||
let newTag
|
||||
|
||||
let eventBus: IEventBusModuleService
|
||||
beforeAll(async () => {
|
||||
@@ -57,11 +61,32 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
).data.product_type
|
||||
|
||||
baseTag1 = (
|
||||
await api.post("/admin/product-tags", { value: "123" }, adminHeaders)
|
||||
).data.product_tag
|
||||
|
||||
baseTag2 = (
|
||||
await api.post("/admin/product-tags", { value: "123_1" }, adminHeaders)
|
||||
).data.product_tag
|
||||
|
||||
baseTag3 = (
|
||||
await api.post("/admin/product-tags", { value: "456" }, adminHeaders)
|
||||
).data.product_tag
|
||||
|
||||
newTag = (
|
||||
await api.post(
|
||||
"/admin/product-tags",
|
||||
{ value: "new-tag" },
|
||||
adminHeaders
|
||||
)
|
||||
).data.product_tag
|
||||
|
||||
baseProduct = (
|
||||
await api.post(
|
||||
"/admin/products",
|
||||
getProductFixture({
|
||||
title: "Base product",
|
||||
tags: [{ id: baseTag1.id }, { id: baseTag2.id }],
|
||||
}),
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
@@ -18,6 +18,9 @@ medusaIntegrationTestRunner({
|
||||
let publishedCollection
|
||||
|
||||
let baseType
|
||||
let baseTag1
|
||||
let baseTag2
|
||||
let newTag
|
||||
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, getContainer())
|
||||
@@ -46,6 +49,22 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
).data.product_type
|
||||
|
||||
baseTag1 = (
|
||||
await api.post("/admin/product-tags", { value: "123" }, adminHeaders)
|
||||
).data.product_tag
|
||||
|
||||
baseTag2 = (
|
||||
await api.post("/admin/product-tags", { value: "456" }, adminHeaders)
|
||||
).data.product_tag
|
||||
|
||||
newTag = (
|
||||
await api.post(
|
||||
"/admin/product-tags",
|
||||
{ value: "new-tag" },
|
||||
adminHeaders
|
||||
)
|
||||
).data.product_tag
|
||||
|
||||
baseProduct = (
|
||||
await api.post(
|
||||
"/admin/products",
|
||||
@@ -54,6 +73,7 @@ medusaIntegrationTestRunner({
|
||||
collection_id: baseCollection.id,
|
||||
// BREAKING: Type input changed from {type: {value: string}} to {type_id: string}
|
||||
type_id: baseType.id,
|
||||
tags: [{ id: baseTag1.id }, { id: baseTag2.id }],
|
||||
}),
|
||||
adminHeaders
|
||||
)
|
||||
@@ -65,7 +85,7 @@ medusaIntegrationTestRunner({
|
||||
getProductFixture({
|
||||
title: "Proposed product",
|
||||
status: "proposed",
|
||||
tags: [{ value: "new-tag" }],
|
||||
tags: [{ id: newTag.id }],
|
||||
type_id: baseType.id,
|
||||
}),
|
||||
adminHeaders
|
||||
@@ -79,6 +99,7 @@ medusaIntegrationTestRunner({
|
||||
title: "Published product",
|
||||
status: "published",
|
||||
collection_id: publishedCollection.id,
|
||||
tags: [{ id: baseTag1.id }, { id: baseTag2.id }],
|
||||
}),
|
||||
adminHeaders
|
||||
)
|
||||
@@ -507,7 +528,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
it("returns a list of products with tags", async () => {
|
||||
const response = await api.get(
|
||||
`/admin/products?tags[]=${baseProduct.tags[0].id}`,
|
||||
`/admin/products?tag_id[]=${baseProduct.tags[0].id}`,
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
@@ -534,7 +555,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
it("returns a list of products with tags in a collection", async () => {
|
||||
const response = await api.get(
|
||||
`/admin/products?collection_id[]=${baseCollection.id}&tags[]=${baseProduct.tags[0].id}`,
|
||||
`/admin/products?collection_id[]=${baseCollection.id}&tag_id[]=${baseProduct.tags[0].id}`,
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
@@ -1082,6 +1103,7 @@ medusaIntegrationTestRunner({
|
||||
title: "Test create",
|
||||
collection_id: baseCollection.id,
|
||||
type_id: baseType.id,
|
||||
tags: [{ id: baseTag1.id }, { id: baseTag2.id }],
|
||||
}),
|
||||
|
||||
adminHeaders
|
||||
@@ -1276,7 +1298,7 @@ medusaIntegrationTestRunner({
|
||||
description: "test-product-description",
|
||||
images: [{ url: "test-image.png" }, { url: "test-image-2.png" }],
|
||||
collection_id: baseCollection.id,
|
||||
tags: [{ value: "123" }, { value: "456" }],
|
||||
tags: [{ id: baseTag1.id }, { id: baseTag2.id }],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
@@ -1306,7 +1328,7 @@ medusaIntegrationTestRunner({
|
||||
description: "test-product-description 1",
|
||||
images: [{ url: "test-image.png" }, { url: "test-image-2.png" }],
|
||||
collection_id: baseCollection.id,
|
||||
tags: [{ value: "123" }, { value: "456" }],
|
||||
tags: [{ id: baseTag1.id }, { id: baseTag2.id }],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant 1",
|
||||
@@ -1406,7 +1428,7 @@ medusaIntegrationTestRunner({
|
||||
],
|
||||
},
|
||||
],
|
||||
tags: [{ value: "123" }],
|
||||
tags: [{ id: baseTag1.id }],
|
||||
images: [{ url: "test-image-2.png" }],
|
||||
status: "published",
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ medusaIntegrationTestRunner({
|
||||
let store
|
||||
let appContainer
|
||||
let collection
|
||||
let tag
|
||||
let product
|
||||
let product1
|
||||
let product2
|
||||
@@ -496,6 +497,9 @@ medusaIntegrationTestRunner({
|
||||
adminHeaders
|
||||
)
|
||||
).data.collection
|
||||
tag = (
|
||||
await api.post("/admin/product-tags", { value: "tag1" }, adminHeaders)
|
||||
).data.product_tag
|
||||
;[product, [variant]] = await createProducts({
|
||||
title: "test product 1",
|
||||
collection_id: collection.id,
|
||||
@@ -504,7 +508,7 @@ medusaIntegrationTestRunner({
|
||||
{ title: "size", values: ["large", "small"] },
|
||||
{ title: "color", values: ["green"] },
|
||||
],
|
||||
tags: [{ value: "tag1" }],
|
||||
tags: [{ id: tag.id }],
|
||||
variants: [
|
||||
{
|
||||
title: "test variant 1",
|
||||
@@ -726,7 +730,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
it("returns a list of products with a given tag", async () => {
|
||||
const response = await api.get(
|
||||
`/store/products?tags[]=${product.tags[0].id}`
|
||||
`/store/products?tag_id[]=${product.tags[0].id}`
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
@@ -1899,7 +1899,6 @@ medusaIntegrationTestRunner({
|
||||
"/admin/products",
|
||||
{
|
||||
title: "Test fixture",
|
||||
tags: [{ value: "123" }, { value: "456" }],
|
||||
options: [
|
||||
{ title: "size", values: ["large", "small"] },
|
||||
{ title: "color", values: ["green"] },
|
||||
|
||||
@@ -65,7 +65,6 @@ medusaIntegrationTestRunner({
|
||||
"/admin/products",
|
||||
{
|
||||
title: "Test fixture",
|
||||
tags: [{ value: "123" }, { value: "456" }],
|
||||
options: [
|
||||
{ title: "size", values: ["large", "small"] },
|
||||
{ title: "color", values: ["green"] },
|
||||
|
||||
Reference in New Issue
Block a user