fix(medusa): Expose list-currencies endpoint by removing feature flag guard (#2216)

This commit is contained in:
Oliver Windall Juhl
2022-09-15 16:29:14 +02:00
committed by GitHub
parent f863d28b9a
commit 5d75e16b1f
4 changed files with 222 additions and 12 deletions
@@ -1,9 +1,10 @@
const path = require("path")
const setupServer = require("../../../helpers/setup-server")
const startServerWithEnvironment =
require("../../../helpers/start-server-with-environment").default
const { useApi } = require("../../../helpers/use-api")
const { useDb } = require("../../../helpers/use-db")
const adminSeeder = require("../../helpers/admin-seeder");
const { useDb, initDb } = require("../../../helpers/use-db")
const adminSeeder = require("../../helpers/admin-seeder")
const adminReqConfig = {
headers: {
@@ -16,12 +17,86 @@ describe("/admin/currencies", () => {
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/currencies", function () {
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
} catch (e) {
console.error(e)
}
})
afterEach(async () => {
const db = useDb()
await db.teardown()
})
it("should retrieve the currencies", async () => {
const api = useApi()
const response = await api.get(
`/admin/currencies?order=code`,
adminReqConfig
)
expect(response.data).toMatchSnapshot()
})
})
describe("POST /admin/currencies/:code", function () {
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
} catch (e) {
console.error(e)
}
})
afterEach(async () => {
const db = useDb()
await db.teardown()
})
it("should fail when attempting to update includes_tax", async () => {
const api = useApi()
try {
await api.post(
`/admin/currencies/aed`,
{
includes_tax: true,
},
adminReqConfig
)
} catch (error) {
expect(error.response.data.message).toBe(
"property includes_tax should not exist"
)
}
})
})
})
describe("[MEDUSA_FF_TAX_INCLUSIVE_PRICING] /admin/currencies", () => {
let medusaProcess
let dbConnection
beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", ".."))
const [process, connection] = await startServerWithEnvironment({
cwd,
env: { MEDUSA_FF_TAX_INCLUSIVE_PRICING: true },
verbose: false,
})
dbConnection = connection
medusaProcess = process
@@ -57,7 +132,7 @@ describe("/admin/currencies", () => {
expect(response.data).toMatchSnapshot()
})
});
})
describe("POST /admin/currencies/:code", function () {
beforeEach(async () => {
@@ -78,12 +153,12 @@ describe("/admin/currencies", () => {
const response = await api.post(
`/admin/currencies/aed`,
{
includes_tax: true
includes_tax: true,
},
adminReqConfig
)
expect(response.data).toMatchSnapshot()
})
});
})
})