Feat: admin collections filtering (#977)

* collections filtering

* filtering collection tests

* oas for list collections
This commit is contained in:
Philip Korsholm
2022-02-01 17:24:47 +01:00
committed by GitHub
parent fdc493df7f
commit f4f9653efc
3 changed files with 147 additions and 5 deletions

View File

@@ -14,6 +14,77 @@ Object {
}
`;
exports[`/admin/collections /admin/collections filters collections by title 1`] = `
Object {
"collections": Array [
Object {
"handle": "test-collection",
"id": "test-collection",
"products": Array [
Object {
"collection_id": "test-collection",
"created_at": Any<String>,
"deleted_at": null,
"description": "test-product-description",
"discountable": true,
"external_id": null,
"handle": "test-product",
"height": null,
"hs_code": null,
"id": "test-product",
"is_giftcard": false,
"length": null,
"material": null,
"metadata": null,
"mid_code": null,
"origin_country": null,
"profile_id": StringMatching /\\^sp_\\*/,
"status": "draft",
"subtitle": null,
"thumbnail": null,
"title": "Test product",
"type_id": "test-type",
"updated_at": Any<String>,
"weight": null,
"width": null,
},
Object {
"collection_id": "test-collection",
"created_at": Any<String>,
"deleted_at": null,
"description": "test-product-description1",
"discountable": true,
"external_id": null,
"handle": "test-product1",
"height": null,
"hs_code": null,
"id": "test-product1",
"is_giftcard": false,
"length": null,
"material": null,
"metadata": null,
"mid_code": null,
"origin_country": null,
"profile_id": StringMatching /\\^sp_\\*/,
"status": "draft",
"subtitle": null,
"thumbnail": null,
"title": "Test product1",
"type_id": "test-type",
"updated_at": Any<String>,
"weight": null,
"width": null,
},
],
"title": "Test collection",
},
],
"count": 1,
"limit": 10,
"offset": 0,
}
`;
exports[`/admin/collections /admin/collections lists collections 1`] = `
Object {
"collections": Array [

View File

@@ -216,5 +216,42 @@ describe("/admin/collections", () => {
count: 3,
})
})
it("filters collections by title", async () => {
const api = useApi()
const response = await api
.get("/admin/collections?title=Test%20collection", {
headers: { Authorization: "Bearer test_token" },
})
.catch((err) => console.log(err))
expect(response.data).toMatchSnapshot({
collections: [
{
id: "test-collection",
handle: "test-collection",
title: "Test collection",
products: [
{
collection_id: "test-collection",
created_at: expect.any(String),
updated_at: expect.any(String),
profile_id: expect.stringMatching(/^sp_*/),
},
{
collection_id: "test-collection",
created_at: expect.any(String),
updated_at: expect.any(String),
profile_id: expect.stringMatching(/^sp_*/),
},
],
},
],
count: 1,
limit: 10,
offset: 0,
})
})
})
})