-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into docs/fix-config-title
- Loading branch information
Showing
117 changed files
with
5,308 additions
and
419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@medusajs/types": patch | ||
--- | ||
|
||
feat(types): added computed actions for automatic promotions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 3 additions & 12 deletions
15
docs-util/packages/docblock-generator/src/commands/run-git-changes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 3 additions & 14 deletions
17
docs-util/packages/docblock-generator/src/commands/run-git-commit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
integration-tests/plugins/__tests__/cart/store/get-cart.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { ModuleRegistrationName } from "@medusajs/modules-sdk" | ||
import { ICartModuleService } from "@medusajs/types" | ||
import path from "path" | ||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app" | ||
import { useApi } from "../../../../environment-helpers/use-api" | ||
import { getContainer } from "../../../../environment-helpers/use-container" | ||
import { initDb, useDb } from "../../../../environment-helpers/use-db" | ||
import adminSeeder from "../../../../helpers/admin-seeder" | ||
|
||
jest.setTimeout(50000) | ||
|
||
const env = { MEDUSA_FF_MEDUSA_V2: true } | ||
|
||
describe("GET /store/:id", () => { | ||
let dbConnection | ||
let appContainer | ||
let shutdownServer | ||
let cartModuleService: ICartModuleService | ||
|
||
beforeAll(async () => { | ||
const cwd = path.resolve(path.join(__dirname, "..", "..", "..")) | ||
dbConnection = await initDb({ cwd, env } as any) | ||
shutdownServer = await startBootstrapApp({ cwd, env }) | ||
appContainer = getContainer() | ||
cartModuleService = appContainer.resolve(ModuleRegistrationName.CART) | ||
}) | ||
|
||
afterAll(async () => { | ||
const db = useDb() | ||
await db.shutdown() | ||
await shutdownServer() | ||
}) | ||
|
||
beforeEach(async () => { | ||
await adminSeeder(dbConnection) | ||
}) | ||
|
||
afterEach(async () => { | ||
const db = useDb() | ||
await db.teardown() | ||
}) | ||
|
||
it("should get cart", async () => { | ||
const cart = await cartModuleService.create({ | ||
currency_code: "usd", | ||
items: [ | ||
{ | ||
unit_price: 1000, | ||
quantity: 1, | ||
title: "Test item", | ||
}, | ||
], | ||
}) | ||
|
||
const api = useApi() as any | ||
const response = await api.get(`/store/carts/${cart.id}`) | ||
|
||
expect(response.status).toEqual(200) | ||
expect(response.data.cart).toEqual( | ||
expect.objectContaining({ | ||
id: cart.id, | ||
currency_code: "usd", | ||
items: expect.arrayContaining([ | ||
expect.objectContaining({ | ||
unit_price: 1000, | ||
quantity: 1, | ||
title: "Test item", | ||
}), | ||
]), | ||
}) | ||
) | ||
}) | ||
}) |
85 changes: 85 additions & 0 deletions
85
integration-tests/plugins/__tests__/customer-group/admin/batch-add-customers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { ModuleRegistrationName } from "@medusajs/modules-sdk" | ||
import { ICustomerModuleService } from "@medusajs/types" | ||
import path from "path" | ||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app" | ||
import { useApi } from "../../../../environment-helpers/use-api" | ||
import { getContainer } from "../../../../environment-helpers/use-container" | ||
import { initDb, useDb } from "../../../../environment-helpers/use-db" | ||
import adminSeeder from "../../../../helpers/admin-seeder" | ||
|
||
const env = { MEDUSA_FF_MEDUSA_V2: true } | ||
const adminHeaders = { | ||
headers: { "x-medusa-access-token": "test_token" }, | ||
} | ||
|
||
describe("POST /admin/customer-groups/:id/customers/batch", () => { | ||
let dbConnection | ||
let appContainer | ||
let shutdownServer | ||
let customerModuleService: ICustomerModuleService | ||
|
||
beforeAll(async () => { | ||
const cwd = path.resolve(path.join(__dirname, "..", "..", "..")) | ||
dbConnection = await initDb({ cwd, env } as any) | ||
shutdownServer = await startBootstrapApp({ cwd, env }) | ||
appContainer = getContainer() | ||
customerModuleService = appContainer.resolve( | ||
ModuleRegistrationName.CUSTOMER | ||
) | ||
}) | ||
|
||
afterAll(async () => { | ||
const db = useDb() | ||
await db.shutdown() | ||
await shutdownServer() | ||
}) | ||
|
||
beforeEach(async () => { | ||
await adminSeeder(dbConnection) | ||
}) | ||
|
||
afterEach(async () => { | ||
const db = useDb() | ||
await db.teardown() | ||
}) | ||
|
||
it("should batch add customers to a group", async () => { | ||
const api = useApi() as any | ||
|
||
const group = await customerModuleService.createCustomerGroup({ | ||
name: "VIP", | ||
}) | ||
const customers = await customerModuleService.create([ | ||
{ | ||
first_name: "Test", | ||
last_name: "Test", | ||
}, | ||
{ | ||
first_name: "Test2", | ||
last_name: "Test2", | ||
}, | ||
{ | ||
first_name: "Test3", | ||
last_name: "Test3", | ||
}, | ||
]) | ||
|
||
const response = await api.post( | ||
`/admin/customer-groups/${group.id}/customers/batch`, | ||
{ | ||
customer_ids: customers.map((c) => ({ id: c.id })), | ||
}, | ||
adminHeaders | ||
) | ||
|
||
expect(response.status).toEqual(200) | ||
|
||
const updatedGroup = await customerModuleService.retrieveCustomerGroup( | ||
group.id, | ||
{ | ||
relations: ["customers"], | ||
} | ||
) | ||
expect(updatedGroup.customers?.length).toEqual(3) | ||
}) | ||
}) |
89 changes: 89 additions & 0 deletions
89
integration-tests/plugins/__tests__/customer-group/admin/batch-remove-customers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { ModuleRegistrationName } from "@medusajs/modules-sdk" | ||
import { ICustomerModuleService } from "@medusajs/types" | ||
import path from "path" | ||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app" | ||
import { useApi } from "../../../../environment-helpers/use-api" | ||
import { getContainer } from "../../../../environment-helpers/use-container" | ||
import { initDb, useDb } from "../../../../environment-helpers/use-db" | ||
import adminSeeder from "../../../../helpers/admin-seeder" | ||
|
||
const env = { MEDUSA_FF_MEDUSA_V2: true } | ||
const adminHeaders = { | ||
headers: { "x-medusa-access-token": "test_token" }, | ||
} | ||
|
||
describe("DELETE /admin/customer-groups/:id/customers/remove", () => { | ||
let dbConnection | ||
let appContainer | ||
let shutdownServer | ||
let customerModuleService: ICustomerModuleService | ||
|
||
beforeAll(async () => { | ||
const cwd = path.resolve(path.join(__dirname, "..", "..", "..")) | ||
dbConnection = await initDb({ cwd, env } as any) | ||
shutdownServer = await startBootstrapApp({ cwd, env }) | ||
appContainer = getContainer() | ||
customerModuleService = appContainer.resolve( | ||
ModuleRegistrationName.CUSTOMER | ||
) | ||
}) | ||
|
||
afterAll(async () => { | ||
const db = useDb() | ||
await db.shutdown() | ||
await shutdownServer() | ||
}) | ||
|
||
beforeEach(async () => { | ||
await adminSeeder(dbConnection) | ||
}) | ||
|
||
afterEach(async () => { | ||
const db = useDb() | ||
await db.teardown() | ||
}) | ||
|
||
it("should batch delete customers from a group", async () => { | ||
const api = useApi() as any | ||
|
||
const group = await customerModuleService.createCustomerGroup({ | ||
name: "VIP", | ||
}) | ||
const customers = await customerModuleService.create([ | ||
{ | ||
first_name: "Test", | ||
last_name: "Test", | ||
}, | ||
{ | ||
first_name: "Test2", | ||
last_name: "Test2", | ||
}, | ||
{ | ||
first_name: "Test3", | ||
last_name: "Test3", | ||
}, | ||
]) | ||
|
||
await customerModuleService.addCustomerToGroup( | ||
customers.map((c) => ({ customer_id: c.id, customer_group_id: group.id })) | ||
) | ||
|
||
const response = await api.post( | ||
`/admin/customer-groups/${group.id}/customers/remove`, | ||
{ | ||
customer_ids: customers.map((c) => ({ id: c.id })), | ||
}, | ||
adminHeaders | ||
) | ||
|
||
expect(response.status).toEqual(200) | ||
|
||
const updatedGroup = await customerModuleService.retrieveCustomerGroup( | ||
group.id, | ||
{ | ||
relations: ["customers"], | ||
} | ||
) | ||
expect(updatedGroup.customers?.length).toEqual(0) | ||
}) | ||
}) |
Oops, something went wrong.