feat: Development server for core + plugins (#2448)
This commit is contained in:
committed by
GitHub
parent
4de4f20b46
commit
b88cef2b1f
17
integration-tests/development/database/customer.js
Normal file
17
integration-tests/development/database/customer.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const { Customer } = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (connection) => {
|
||||
const manager = connection.manager
|
||||
|
||||
const customer = await manager.create(Customer, {
|
||||
id: "customer-1",
|
||||
email: "test1@email.com",
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
password_hash:
|
||||
"c2NyeXB0AAEAAAABAAAAAVMdaddoGjwU1TafDLLlBKnOTQga7P2dbrfgf3fB+rCD/cJOMuGzAvRdKutbYkVpuJWTU39P7OpuWNkUVoEETOVLMJafbI8qs8Qx/7jMQXkN",
|
||||
// password matching "test"
|
||||
has_account: true,
|
||||
})
|
||||
await manager.save(customer)
|
||||
}
|
||||
9
integration-tests/development/database/index.js
Normal file
9
integration-tests/development/database/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const user = require("./user")
|
||||
const region = require("./region")
|
||||
const customer = require("./customer")
|
||||
|
||||
module.exports = async (db) => {
|
||||
await user(db)
|
||||
await region(db)
|
||||
await customer(db)
|
||||
}
|
||||
45
integration-tests/development/database/region.js
Normal file
45
integration-tests/development/database/region.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const { Region } = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (connection) => {
|
||||
const manager = connection.manager
|
||||
|
||||
const r = manager.create(Region, {
|
||||
id: "test-region",
|
||||
name: "Test Region",
|
||||
payment_providers: [{ id: "test-pay" }],
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
await manager.save(r)
|
||||
|
||||
const europeRegion = manager.create(Region, {
|
||||
id: "eur-region",
|
||||
name: "Europe Region",
|
||||
payment_providers: [{ id: "test-pay" }],
|
||||
currency_code: "eur",
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
await manager.save(europeRegion)
|
||||
|
||||
// Region with multiple countries
|
||||
const regionWithMultipleCoutries = manager.create(Region, {
|
||||
id: "test-region-multiple",
|
||||
name: "Test Region",
|
||||
currency_code: "eur",
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
await manager.save(regionWithMultipleCoutries)
|
||||
|
||||
await manager.query(
|
||||
`UPDATE "country" SET region_id='test-region-multiple' WHERE iso_2 = 'no'`
|
||||
)
|
||||
await manager.query(
|
||||
`UPDATE "country" SET region_id='test-region-multiple' WHERE iso_2 = 'dk'`
|
||||
)
|
||||
await manager.query(
|
||||
`UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'`
|
||||
)
|
||||
}
|
||||
17
integration-tests/development/database/user.js
Normal file
17
integration-tests/development/database/user.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const Scrypt = require("scrypt-kdf")
|
||||
const { User } = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (connection) => {
|
||||
const manager = connection.manager
|
||||
|
||||
const buf = await Scrypt.kdf("secret_password", { logN: 1, r: 1, p: 1 })
|
||||
const password_hash = buf.toString("base64")
|
||||
|
||||
await manager.insert(User, {
|
||||
id: "admin_user",
|
||||
email: "admin@medusa.js",
|
||||
api_token: "test_token",
|
||||
role: "admin",
|
||||
password_hash,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user