* init * added buld id validation to repo * admin done * updated price reqs * initial price selection strategy * update customer seeder * format models * price selection strategy * price selection testing * update price selection tests * update price selection strategy * remove console.warn * update price selection strat * remove console.log * fix unit tests * update product snapshot integration tests * fix failing unit tests * update variant test snapshots * intial implementation of PriceList * integration tests for price lists * updated admin/product integration tests * update updateVariantPrices method * remove comment from error handler * add integration test for batch deleting prices associated with price list * make update to prices through variant service limited to default prices * update store/products.js snapshot * add api unit tests and update product integration tests to validate that prices from Price List are ignored * fix product test * requested changes * cascade * ensure delete variant cascades to MoneyAmount * addresses PR feedback * removed unused endpoint * update mock * fix failing store integration tests * remove medusajs ressource * re add env.template * price selection strategy methods * fix integration tests * update unit tests * update jsdoc * update price selection strategy parameter * fix unit tests * pr feedback Co-authored-by: Kasper <kasper@medusajs.com> Co-authored-by: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com>
114 lines
2.6 KiB
JavaScript
114 lines
2.6 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,
|
|
})
|
|
|
|
const customer5 = await manager.create(Customer, {
|
|
id: "test-customer-5",
|
|
email: "test5@email.com",
|
|
})
|
|
await manager.save(customer5)
|
|
|
|
const customer6 = await manager.create(Customer, {
|
|
id: "test-customer-6",
|
|
email: "test6@email.com",
|
|
})
|
|
await manager.save(customer6)
|
|
|
|
const customer7 = await manager.create(Customer, {
|
|
id: "test-customer-7",
|
|
email: "test7@email.com",
|
|
})
|
|
await manager.save(customer7)
|
|
|
|
const deletionCustomer = await manager.create(Customer, {
|
|
id: "test-customer-delete-cg",
|
|
email: "test-deletetion-cg@email.com",
|
|
})
|
|
await manager.save(deletionCustomer)
|
|
|
|
await manager.insert(CustomerGroup, {
|
|
id: "customer-group-1",
|
|
name: "vip-customers",
|
|
})
|
|
|
|
await manager.insert(CustomerGroup, {
|
|
id: "customer-group-2",
|
|
name: "test-group-2",
|
|
metadata: { data1: "value1" },
|
|
})
|
|
|
|
await manager.insert(CustomerGroup, {
|
|
id: "customer-group-3",
|
|
name: "test-group-3",
|
|
})
|
|
|
|
await manager.insert(CustomerGroup, {
|
|
id: "test-group-4",
|
|
name: "test-group-4",
|
|
})
|
|
|
|
const c_group_5 = await manager.create(CustomerGroup, {
|
|
id: "test-group-5",
|
|
name: "test-group-5",
|
|
})
|
|
await manager.save(c_group_5)
|
|
|
|
const c_group_6 = await manager.create(CustomerGroup, {
|
|
id: "test-group-6",
|
|
name: "test-group-6",
|
|
})
|
|
await manager.save(c_group_6)
|
|
|
|
customer5.groups = [c_group_5]
|
|
await manager.save(customer5)
|
|
|
|
customer6.groups = [c_group_5]
|
|
await manager.save(customer6)
|
|
|
|
customer7.groups = [c_group_5, c_group_6]
|
|
await manager.save(customer7)
|
|
|
|
const c_group_delete = await manager.create(CustomerGroup, {
|
|
id: "test-group-delete",
|
|
name: "test-group-delete",
|
|
})
|
|
await manager.save(c_group_delete)
|
|
|
|
deletionCustomer.groups = [c_group_delete]
|
|
await manager.save(deletionCustomer)
|
|
}
|