fix: adds order by functionality to products (#1021)

* fix: adds order by functionality to products

* feat: adds product tags list

* fix: adds client and react support for product tags

* fix: unit test

* Update packages/medusa/src/services/product-tag.ts

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* Update packages/medusa/src/services/product-tag.ts

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* Update packages/medusa/src/services/product-tag.ts

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* Update packages/medusa/src/services/product-tag.ts

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* Update packages/medusa/src/services/product-tag.ts

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* Update packages/medusa/src/services/product-tag.ts

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Sebastian Rindom
2022-02-03 19:03:15 +01:00
committed by GitHub
parent a81227fa74
commit 3bf32e5dc9
17 changed files with 498 additions and 13 deletions

View File

@@ -0,0 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`/admin/product-tags GET /admin/product-tags returns a list of product tags 1`] = `
Array [
Object {
"created_at": Any<String>,
"id": "tag1",
"updated_at": Any<String>,
"value": "123",
},
Object {
"created_at": Any<String>,
"id": "tag3",
"updated_at": Any<String>,
"value": "123",
},
Object {
"created_at": Any<String>,
"id": "tag4",
"updated_at": Any<String>,
"value": "123",
},
]
`;

View File

@@ -0,0 +1,72 @@
const path = require("path")
const setupServer = require("../../../helpers/setup-server")
const { useApi } = require("../../../helpers/use-api")
const { initDb, useDb } = require("../../../helpers/use-db")
const adminSeeder = require("../../helpers/admin-seeder")
const productSeeder = require("../../helpers/product-seeder")
jest.setTimeout(50000)
describe("/admin/product-tags", () => {
let medusaProcess
let dbConnection
beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", ".."))
dbConnection = await initDb({ cwd })
medusaProcess = await setupServer({ cwd })
})
afterAll(async () => {
const db = useDb()
await db.shutdown()
medusaProcess.kill()
})
describe("GET /admin/product-tags", () => {
beforeEach(async () => {
try {
await productSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
const db = useDb()
await db.teardown()
})
it("returns a list of product tags", async () => {
const api = useApi()
const res = await api
.get("/admin/product-tags", {
headers: {
Authorization: "Bearer test_token",
},
})
.catch((err) => {
console.log(err)
})
expect(res.status).toEqual(200)
const tagMatch = {
created_at: expect.any(String),
updated_at: expect.any(String),
}
expect(res.data.product_tags).toMatchSnapshot([
tagMatch,
tagMatch,
tagMatch,
])
})
})
})