Skip to content

Commit

Permalink
Merge branch 'develop' into docs/deployments-improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jan 24, 2024
2 parents a28ed4a + b3d0139 commit 234aae1
Show file tree
Hide file tree
Showing 228 changed files with 9,083 additions and 913 deletions.
10 changes: 10 additions & 0 deletions .changeset/fuzzy-tips-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@medusajs/modules-sdk": patch
"@medusajs/types": patch
"@medusajs/pricing": patch
"@medusajs/product": patch
"@medusajs/inventory": patch
"@medusajs/stock-location": patch
---

Medusa App loading modules reference
5 changes: 5 additions & 0 deletions .changeset/gentle-pots-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/ui": patch
---

feature(ui): Adds a `size` variant to `<Copy />` component, and prevent clicks from propigating to parent elements". Also adds additional sizes to the `<Avatar />` component.
11 changes: 11 additions & 0 deletions .changeset/pink-balloons-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@medusajs/workflow-engine-inmemory": patch
"@medusajs/workflow-engine-redis": patch
"@medusajs/orchestration": patch
"@medusajs/workflows-sdk": patch
"@medusajs/modules-sdk": patch
"@medusajs/types": patch
"@medusajs/utils": patch
---

Modules: Workflows Engine in-memory and Redis
6 changes: 6 additions & 0 deletions .changeset/young-forks-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/medusa": patch
"@medusajs/types": patch
---

feat(medusa,types): added buyget support for modules
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ packages/*
!packages/orchestration
!packages/workflows-sdk
!packages/core-flows
!packages/workflow-engine-redis
!packages/workflow-engine-inmemory



**/models/*
Expand Down
6 changes: 3 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ module.exports = {
node: true,
jest: true,
},
ignorePatterns: [
"packages/admin-next/dashboard/**/dist"
],
ignorePatterns: ["packages/admin-next/dashboard/**/dist"],
overrides: [
{
files: ["*.ts"],
Expand All @@ -101,6 +99,8 @@ module.exports = {
"./packages/orchestration/tsconfig.json",
"./packages/workflows-sdk/tsconfig.spec.json",
"./packages/core-flows/tsconfig.spec.json",
"./packages/workflow-engine-redis/tsconfig.spec.json",
"./packages/workflow-engine-inmemory/tsconfig.spec.json",
],
},
rules: {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/plugins/__tests__/product/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from "../../../../factories"
import { createDefaultRuleTypes } from "../../../helpers/create-default-rule-types"

jest.setTimeout(5000000)
jest.setTimeout(50000)

const adminHeaders = {
headers: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("POST /admin/promotions", () => {
)
})

it("should create a promotion successfully", async () => {
it("should create a standard promotion successfully", async () => {
const api = useApi() as any
const response = await api.post(
`/admin/promotions`,
Expand Down Expand Up @@ -148,4 +148,194 @@ describe("POST /admin/promotions", () => {
})
)
})

it("should throw an error if buy_rules params are not passed", async () => {
const api = useApi() as any
const { response } = await api
.post(
`/admin/promotions`,
{
code: "TEST",
type: PromotionType.BUYGET,
is_automatic: true,
application_method: {
target_type: "items",
type: "fixed",
allocation: "each",
value: "100",
max_quantity: 100,
target_rules: [
{
attribute: "test.test",
operator: "eq",
values: ["test1", "test2"],
},
],
},
rules: [
{
attribute: "test.test",
operator: "eq",
values: ["test1", "test2"],
},
],
},
adminHeaders
)
.catch((e) => e)

expect(response.status).toEqual(400)
expect(response.data.message).toEqual(
"Buy rules are required for buyget promotion type"
)
})

it("should throw an error if buy_rules params are not passed", async () => {
const api = useApi() as any
const { response } = await api
.post(
`/admin/promotions`,
{
code: "TEST",
type: PromotionType.BUYGET,
is_automatic: true,
application_method: {
target_type: "items",
type: "fixed",
allocation: "each",
value: "100",
max_quantity: 100,
buy_rules: [
{
attribute: "test.test",
operator: "eq",
values: ["test1", "test2"],
},
],
},
rules: [
{
attribute: "test.test",
operator: "eq",
values: ["test1", "test2"],
},
],
},
adminHeaders
)
.catch((e) => e)

expect(response.status).toEqual(400)
expect(response.data.message).toEqual(
"Target rules are required for buyget promotion type"
)
})

it("should create a buyget promotion successfully", async () => {
const api = useApi() as any
const response = await api.post(
`/admin/promotions`,
{
code: "TEST",
type: PromotionType.BUYGET,
is_automatic: true,
campaign: {
name: "test",
campaign_identifier: "test-1",
budget: {
type: "usage",
limit: 100,
},
},
application_method: {
target_type: "items",
type: "fixed",
allocation: "each",
value: "100",
max_quantity: 100,
apply_to_quantity: 1,
buy_rules_min_quantity: 1,
target_rules: [
{
attribute: "test.test",
operator: "eq",
values: ["test1", "test2"],
},
],
buy_rules: [
{
attribute: "test.test",
operator: "eq",
values: ["test1", "test2"],
},
],
},
rules: [
{
attribute: "test.test",
operator: "eq",
values: ["test1", "test2"],
},
],
},
adminHeaders
)

expect(response.status).toEqual(200)
expect(response.data.promotion).toEqual(
expect.objectContaining({
id: expect.any(String),
code: "TEST",
type: "buyget",
is_automatic: true,
campaign: expect.objectContaining({
name: "test",
campaign_identifier: "test-1",
budget: expect.objectContaining({
type: "usage",
limit: 100,
}),
}),
application_method: expect.objectContaining({
value: 100,
max_quantity: 100,
type: "fixed",
target_type: "items",
allocation: "each",
apply_to_quantity: 1,
buy_rules_min_quantity: 1,
target_rules: [
expect.objectContaining({
operator: "eq",
attribute: "test.test",
values: expect.arrayContaining([
expect.objectContaining({ value: "test1" }),
expect.objectContaining({ value: "test2" }),
]),
}),
],
buy_rules: [
expect.objectContaining({
operator: "eq",
attribute: "test.test",
values: expect.arrayContaining([
expect.objectContaining({ value: "test1" }),
expect.objectContaining({ value: "test2" }),
]),
}),
],
}),
rules: [
expect.objectContaining({
operator: "eq",
attribute: "test.test",
values: expect.arrayContaining([
expect.objectContaining({ value: "test1" }),
expect.objectContaining({ value: "test2" }),
]),
}),
],
})
)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,30 @@ describe("GET /admin/promotions", () => {
)

expect(response.status).toEqual(200)
expect(response.data.promotion).toEqual({
id: expect.any(String),
code: "TEST",
campaign: null,
is_automatic: false,
type: "standard",
created_at: expect.any(String),
updated_at: expect.any(String),
deleted_at: null,
application_method: {
expect(response.data.promotion).toEqual(
expect.objectContaining({
id: expect.any(String),
promotion: expect.any(Object),
value: 100,
type: "fixed",
target_type: "order",
max_quantity: 0,
allocation: null,
code: "TEST",
campaign: null,
is_automatic: false,
type: "standard",
created_at: expect.any(String),
updated_at: expect.any(String),
deleted_at: null,
},
})
application_method: expect.objectContaining({
id: expect.any(String),
promotion: expect.any(Object),
value: 100,
type: "fixed",
target_type: "order",
max_quantity: 0,
allocation: null,
created_at: expect.any(String),
updated_at: expect.any(String),
deleted_at: null,
}),
})
)
})

it("should get the requested promotion with filtered fields and relations", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,58 @@ describe("POST /admin/promotions/:id", () => {
})
)
})

it("should update a buyget promotion successfully", async () => {
const createdPromotion = await promotionModuleService.create({
code: "PROMOTION_TEST",
type: PromotionType.BUYGET,
application_method: {
type: "fixed",
target_type: "items",
allocation: "across",
value: "100",
apply_to_quantity: 1,
buy_rules_min_quantity: 1,
buy_rules: [
{
attribute: "product_collection.id",
operator: "eq",
values: ["pcol_towel"],
},
],
target_rules: [
{
attribute: "product.id",
operator: "eq",
values: "prod_mat",
},
],
},
})

const api = useApi() as any
const response = await api.post(
`/admin/promotions/${createdPromotion.id}`,
{
code: "TEST_TWO",
application_method: {
value: "200",
buy_rules_min_quantity: 6,
},
},
adminHeaders
)

expect(response.status).toEqual(200)
expect(response.data.promotion).toEqual(
expect.objectContaining({
id: expect.any(String),
code: "TEST_TWO",
application_method: expect.objectContaining({
value: 200,
buy_rules_min_quantity: 6,
}),
})
)
})
})
Loading

0 comments on commit 234aae1

Please sign in to comment.