Fixes as a result of 'end-to-end-backend' test
This commit is contained in:
+5
@@ -12,6 +12,8 @@ describe("POST /admin/shipping-options", () => {
|
||||
name: "Test option",
|
||||
region_id: "testregion",
|
||||
provider_id: "test_provider",
|
||||
data: { id: "test" },
|
||||
profile_id: "test",
|
||||
price: {
|
||||
type: "flat_rate",
|
||||
amount: 100,
|
||||
@@ -32,6 +34,7 @@ describe("POST /admin/shipping-options", () => {
|
||||
})
|
||||
|
||||
it("returns 200", () => {
|
||||
console.log(subject)
|
||||
expect(subject.status).toEqual(200)
|
||||
})
|
||||
|
||||
@@ -41,6 +44,8 @@ describe("POST /admin/shipping-options", () => {
|
||||
name: "Test option",
|
||||
region_id: "testregion",
|
||||
provider_id: "test_provider",
|
||||
data: { id: "test" },
|
||||
profile_id: "test",
|
||||
price: {
|
||||
type: "flat_rate",
|
||||
amount: 100,
|
||||
|
||||
@@ -5,11 +5,14 @@ export default async (req, res) => {
|
||||
name: Validator.string().required(),
|
||||
region_id: Validator.string().required(),
|
||||
provider_id: Validator.string().required(),
|
||||
data: Validator.object(),
|
||||
price: Validator.object().keys({
|
||||
type: Validator.string().required(),
|
||||
amount: Validator.number().optional(),
|
||||
}),
|
||||
profile_id: Validator.string().required(),
|
||||
data: Validator.object().required(),
|
||||
price: Validator.object()
|
||||
.keys({
|
||||
type: Validator.string().required(),
|
||||
amount: Validator.number().optional(),
|
||||
})
|
||||
.required(),
|
||||
requirements: Validator.array()
|
||||
.items(
|
||||
Validator.object({
|
||||
@@ -33,7 +36,7 @@ export default async (req, res) => {
|
||||
|
||||
// Add to default shipping profile
|
||||
const { _id } = await shippingProfileService.retrieveDefault()
|
||||
await shippingProfileService.addProduct(_id, data._id)
|
||||
await shippingProfileService.addShippingOption(_id, data._id)
|
||||
|
||||
res.status(200).json({ shipping_option: data })
|
||||
} catch (err) {
|
||||
|
||||
@@ -12,6 +12,7 @@ export default async (req, res) => {
|
||||
discounts: Validator.array().items({
|
||||
code: Validator.string(),
|
||||
}),
|
||||
customer_id: Validator.string(),
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
@@ -27,6 +28,10 @@ export default async (req, res) => {
|
||||
}
|
||||
|
||||
try {
|
||||
if (value.customer_id) {
|
||||
await cartService.updateCustomerId(id, value.customer_id)
|
||||
}
|
||||
|
||||
if (value.region_id) {
|
||||
await cartService.setRegion(id, value.region_id)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export default async (req, res) => {
|
||||
try {
|
||||
const customerService = req.scope.resolve("customerService")
|
||||
const customer = await customerService.create(value)
|
||||
const data = await customerService.decorate(customer)
|
||||
const data = await customerService.decorate(customer, ["_id", "email"])
|
||||
res.status(201).json({ customer: data })
|
||||
} catch (err) {
|
||||
throw err
|
||||
|
||||
Reference in New Issue
Block a user