-
-
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 chore/clean-up-models
- Loading branch information
Showing
39 changed files
with
781 additions
and
82 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,6 @@ | ||
--- | ||
"@medusajs/client-types": patch | ||
"@medusajs/medusa": patch | ||
--- | ||
|
||
fix(medusa): Adds support for ordering GET /admin/orders |
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
63 changes: 63 additions & 0 deletions
63
integration-tests/plugins/__tests__/customer/admin/list-customer-groups.spec.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,63 @@ | ||
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("GET /admin/customer-groups", () => { | ||
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 get all customer groups and its count", async () => { | ||
await customerModuleService.createCustomerGroup({ | ||
name: "Test", | ||
}) | ||
|
||
const api = useApi() as any | ||
const response = await api.get(`/admin/customer-groups`, adminHeaders) | ||
|
||
expect(response.status).toEqual(200) | ||
expect(response.data.count).toEqual(1) | ||
expect(response.data.groups).toEqual([ | ||
expect.objectContaining({ | ||
id: expect.any(String), | ||
name: "Test", | ||
}), | ||
]) | ||
}) | ||
}) |
119 changes: 119 additions & 0 deletions
119
integration-tests/plugins/__tests__/customer/admin/list-customers.spec.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,119 @@ | ||
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("GET /admin/customers", () => { | ||
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 get all customers and its count", async () => { | ||
await customerModuleService.create([ | ||
{ | ||
first_name: "Test", | ||
last_name: "Test", | ||
email: "test@me.com", | ||
}, | ||
]) | ||
|
||
const api = useApi() as any | ||
const response = await api.get(`/admin/customers`, adminHeaders) | ||
|
||
expect(response.status).toEqual(200) | ||
expect(response.data.count).toEqual(1) | ||
expect(response.data.customers).toEqual([ | ||
expect.objectContaining({ | ||
id: expect.any(String), | ||
first_name: "Test", | ||
last_name: "Test", | ||
email: "test@me.com", | ||
}), | ||
]) | ||
}) | ||
|
||
it("should filter customers by last name", async () => { | ||
await customerModuleService.create([ | ||
{ | ||
first_name: "Jane", | ||
last_name: "Doe", | ||
email: "jane@me.com", | ||
}, | ||
{ | ||
first_name: "John", | ||
last_name: "Doe", | ||
email: "john@me.com", | ||
}, | ||
{ | ||
first_name: "LeBron", | ||
last_name: "James", | ||
email: "lebron@me.com", | ||
}, | ||
{ | ||
first_name: "John", | ||
last_name: "Silver", | ||
email: "johns@me.com", | ||
}, | ||
]) | ||
|
||
const api = useApi() as any | ||
const response = await api.get( | ||
`/admin/customers?last_name=Doe`, | ||
adminHeaders | ||
) | ||
|
||
expect(response.status).toEqual(200) | ||
expect(response.data.count).toEqual(2) | ||
expect(response.data.customers).toContainEqual( | ||
expect.objectContaining({ | ||
id: expect.any(String), | ||
first_name: "Jane", | ||
last_name: "Doe", | ||
email: "jane@me.com", | ||
}) | ||
) | ||
expect(response.data.customers).toContainEqual( | ||
expect.objectContaining({ | ||
id: expect.any(String), | ||
first_name: "John", | ||
last_name: "Doe", | ||
email: "john@me.com", | ||
}) | ||
) | ||
}) | ||
}) |
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
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
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./definition" | ||
export * from "./definitions" | ||
export * as Handlers from "./handlers" | ||
export * from "./promotion" |
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,2 @@ | ||
export * from "./steps" | ||
export * from "./workflows" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../definition/promotion/create-campaigns.ts → ...c/promotion/workflows/create-campaigns.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
2 changes: 1 addition & 1 deletion
2
...definition/promotion/create-promotions.ts → .../promotion/workflows/create-promotions.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
2 changes: 1 addition & 1 deletion
2
.../definition/promotion/delete-campaigns.ts → ...c/promotion/workflows/delete-campaigns.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
2 changes: 1 addition & 1 deletion
2
...definition/promotion/delete-promotions.ts → .../promotion/workflows/delete-promotions.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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../definition/promotion/update-campaigns.ts → ...c/promotion/workflows/update-campaigns.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
2 changes: 1 addition & 1 deletion
2
...definition/promotion/update-promotions.ts → .../promotion/workflows/update-promotions.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
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
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
Oops, something went wrong.