Files
medusa-store/integration-tests/helpers/customer-seeder.js
Philip Korsholm 5d10c46bb1 feat(medusa): Separate money amount and variant (#4906)
* initial changes

* working test

* final changes to product tests

* update integration tests

* update price list integration tests

* update integration tests

* update unit tests

* update plugin integration tests

* remove catch from integration test

* undo change

* add andWhere

* update upsertCurrencyMoneyAmount method

* undo line item changes

* undo changes

* update deprecated method

* Update packages/medusa/src/migrations/1692953518123-drop_money_amount_constraints_for_pricing_module.ts

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>

* rename joinTable

* update with joinTable entity

* update load methods

* remove await create

* re-add context test

* update price list behavior for prices

* update price list snapshots

* re-add admin seeder

* pr feedback

* fix unit tests

* fix plugin integration tests

* initial review changes

* redo changes to variant creation

---------

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-09-13 13:26:20 +02:00

114 lines
2.6 KiB
JavaScript

const { Customer, Address, CustomerGroup } = require("@medusajs/medusa")
module.exports = async (dataSource, data = {}) => {
const manager = dataSource.manager
const testAddr = manager.create(Address, {
id: "test-address",
first_name: "Lebron",
last_name: "James",
})
await manager.save(testAddr)
const customer = 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 = manager.create(Customer, {
id: "test-customer-5",
email: "test5@email.com",
})
await manager.save(customer5)
const customer6 = manager.create(Customer, {
id: "test-customer-6",
email: "test6@email.com",
})
await manager.save(customer6)
const customer7 = manager.create(Customer, {
id: "test-customer-7",
email: "test7@email.com",
})
await manager.save(customer7)
const deletionCustomer = 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 = manager.create(CustomerGroup, {
id: "test-group-5",
name: "test-group-5",
})
await manager.save(c_group_5)
const c_group_6 = 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 = 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)
}