* update customer service prep * expand on the update customer groups test case * add the test case for customer group update * docs for `groups` prop on update customer endpoint * refactor, update comments * expend on integration tests, add customer mock with a group * refactor to use `customerGroupService.list` method * update units * remove `updateCustomerGroups` * fix rebase conflict * fix customer seed data, add JoinTable on groups * group retrieval using the expand param * fix: use `buildQuery_` * fix: validation for `groups`, enable `expand`param on update customer endpoint * fix: remove fileds form the `FilterableCustomerGroupProps` * fix: spearate body/query validation Co-authored-by: fPolic <frane@medusajs.com>
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
const { Customer, Address, CustomerGroup } = require("@medusajs/medusa")
|
|
|
|
module.exports = async (connection, data = {}) => {
|
|
const manager = connection.manager
|
|
|
|
const testAddr = await manager.create(Address, {
|
|
id: "test-address",
|
|
first_name: "Lebron",
|
|
last_name: "James",
|
|
})
|
|
|
|
await manager.save(testAddr)
|
|
|
|
const customer = await manager.create(Customer, {
|
|
id: "test-customer-1",
|
|
email: "test1@email.com",
|
|
})
|
|
|
|
customer.billing_address = testAddr
|
|
customer.shipping_addresses = [testAddr]
|
|
await manager.save(customer)
|
|
|
|
await manager.insert(Customer, {
|
|
id: "test-customer-2",
|
|
email: "test2@email.com",
|
|
})
|
|
|
|
await manager.insert(Customer, {
|
|
id: "test-customer-3",
|
|
email: "test3@email.com",
|
|
})
|
|
|
|
await manager.insert(Customer, {
|
|
id: "test-customer-has_account",
|
|
email: "test4@email.com",
|
|
has_account: true,
|
|
})
|
|
|
|
await manager.insert(Customer, {
|
|
id: "test-customer-5",
|
|
email: "test5@email.com",
|
|
groups: [{ id: "test-group-5", name: "test-group-5" }],
|
|
})
|
|
|
|
await manager.insert(CustomerGroup, {
|
|
id: "customer-group-1",
|
|
name: "vip-customers",
|
|
})
|
|
|
|
await manager.insert(CustomerGroup, {
|
|
id: "test-group-4",
|
|
name: "test-group-4",
|
|
})
|
|
|
|
await manager.insert(CustomerGroup, {
|
|
id: "test-group-5",
|
|
name: "test-group-5",
|
|
})
|
|
}
|