feat: Allow retrieval of soft-deleted products (#723)
This commit is contained in:
@@ -144,6 +144,9 @@ describe("/admin/products", () => {
|
||||
const notExpected = [
|
||||
expect.objectContaining({ status: "draft" }),
|
||||
expect.objectContaining({ status: "rejected" }),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_4",
|
||||
}),
|
||||
]
|
||||
|
||||
const response = await api
|
||||
@@ -175,6 +178,48 @@ describe("/admin/products", () => {
|
||||
}
|
||||
})
|
||||
|
||||
it("returns a list of deleted products with free text query", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/products?deleted_at[gt]=01-26-1990&q=test", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_4",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("returns a list of deleted products", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/products?deleted_at[gt]=01-26-1990", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_4",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("returns a list of products in collection", async () => {
|
||||
const api = useApi()
|
||||
|
||||
|
||||
@@ -271,4 +271,16 @@ module.exports = async (connection, data = {}) => {
|
||||
})
|
||||
|
||||
await manager.save(product3)
|
||||
|
||||
const product4 = manager.create(Product, {
|
||||
id: "test-product_filtering_4",
|
||||
handle: "test-product_filtering_4",
|
||||
title: "Test product filtering 4",
|
||||
profile_id: defaultProfile.id,
|
||||
description: "test-product-description",
|
||||
status: "proposed",
|
||||
deleted_at: new Date().toISOString(),
|
||||
})
|
||||
|
||||
await manager.save(product4)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user