Skip to content

Commit

Permalink
fix(integration-tests): Use asymmetric matcher for arrays in tests (#…
Browse files Browse the repository at this point in the history
…1992)

feat(medusa): Convert CollectionService to TypeScript (#1976)

feat(medusa): Convert OauthService to TypeScript (#1983)

feat(medusa-js): Add Collection batch (remove, add) endpoints (#1958)

feat(medusa-react): Add Collection batch (remove, add) endpoints (#1959)

feat(medusa-payment-stripe): Add support for Przelewy24 and Blik (#1982)

feat(medusa): Convert ShippingProfileService to TypeScript (#1963)

feat(medusa): Use transactions in CartCompletionStrategy (#1968)

feat(medusa): Convert IdempotencyKeyService to TypeScript (#1995)

* feat(medusa): Migrate the idempotency key service to ts + fix

* feat(medusa): Finalise idempotency migration

* Create late-owls-pump.md

* feat(medusa): Polish

* feat(medusa): Add case to the error handler

* feat(medusa): Add case to the error handler

Co-authored-by: olivermrbl <oliver@mrbltech.com>

feat(medusa,medusa-telemetry): Add telemetry on feature flags (#2017)

chore(medusa): Feature flag loader simplify, deduplicate and increase readability (#2025)

feat(medusa:) Convert PaymentProvider + PaymentProviderInterface to TS +  (#1773)

* feat(payments): Refactor core Payment related

* fix(medusa): typings

* test(unit): fix suite

* test(unit): fix suite

* feat(medusa): Improve payment provider container typings

* fix(medusa): typings

* styles(medusa): renove comments

* feat(medusa): cleanup

* feat(medusa): Add uniq constraint on payment session and idem key on create-payment-session end point

* fix(medusa): migration

* fix(medusa): create payment session

* feat(medusa): cleanup

feat(medusa): Refactor undefined check into a single util (#2024)

chore(medusa): Remove intepestive services re instanciation in loop (#2036)

* chore(medusa): Renove intepestive services re instanciation in loop

* test(medusa): Fix missing deps

* fix(medusa): Missing await

feat(medusa): Simplify the transaction base service (#2007)

**What**
Simplify the transaction base service.

**How**

In fact, it does not need to be template and reduce the extensibility as the type is internally enforce. Now, the type is deduced by this which can be any derived class.

fix(medusa): join tracking links to all fulfillments in admin/orders (#2045)

Fixes #2042

feat(medusa): Implement the SC migration scripts (#2037)

**What**
Migrate the existing products to the default sales channel

FIXES CORE-434

fix(medusa): Complete cart with 100% discount (#2032)

**What**
Naive fix to allow carts with 100% discount to be completed.

**Why**
Discount total is wrongly calculated if `items` and `items.adjustments` is not included in relations upon retrieving the cart.

**Thought**
This is yet another example of why we need to rethink and refactor totals computation to not depend on what is provided by the user.

fix(medusa-payment-stripe): Add item adjustments relation in CartSubcriber (#2052)

added upgrade guide for v1.3.6

Revert "added upgrade guide for v1.3.6"

This reverts commit 9c3c8cb.

feat(medusa): Migrate Return service to ts (#1926)

feat(medusa): Add Mongolian currency tugrug (#2067)

tests(integration-tests): Allow null updates in discounts (#1299)

feat(medusa): Filtering Customer Orders (#975)

feat(medusa-js): Add deleteSession endpoint (#1234)
  • Loading branch information
adrien2p authored and carlos-r-l-rodrigues committed Aug 22, 2022
1 parent 1c6fcb2 commit 9d773e9
Show file tree
Hide file tree
Showing 174 changed files with 5,414 additions and 3,114 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-years-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

Join tracking links to all fulfillments in admin/orders
6 changes: 6 additions & 0 deletions .changeset/eighty-onions-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"medusa-telemetry": patch
"@medusajs/medusa": patch
---

Adds enabled features flags to tracking event in `medusa-telemetry`
5 changes: 5 additions & 0 deletions .changeset/fresh-snakes-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

Convert CollectionService to TypeScript
5 changes: 5 additions & 0 deletions .changeset/giant-jobs-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa-js": patch
---

Add deleteSession endpoint
5 changes: 5 additions & 0 deletions .changeset/gorgeous-bears-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"medusa-react": patch
---

Add Collection batch (remove, add) endpoints to medusa-react
5 changes: 5 additions & 0 deletions .changeset/honest-garlics-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

---

Use asymetric matcher for arrays
5 changes: 5 additions & 0 deletions .changeset/khaki-spiders-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

Allow filtering of customer orders
6 changes: 6 additions & 0 deletions .changeset/late-owls-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/medusa": patch
---

Convert IdempotencyKeyService to TypeScript
Add await to retrieve in lock method
5 changes: 5 additions & 0 deletions .changeset/proud-papayas-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

Convert ShippingProfileService to TypeScript
5 changes: 5 additions & 0 deletions .changeset/shaggy-pots-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

add Mongolian native currency tugrug
5 changes: 5 additions & 0 deletions .changeset/sixty-boats-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

Convert OauthService to TypeScript
6 changes: 6 additions & 0 deletions .changeset/stale-mice-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"medusa-payment-stripe": patch
"@medusajs/medusa": patch
---

Add payment providers Przelewy24 and Blik through Stripe
5 changes: 5 additions & 0 deletions .changeset/tiny-sheep-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

Add new `isDefined` utility
5 changes: 5 additions & 0 deletions .changeset/tricky-suns-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

Use transactions in CartCompletionStrategy phases
5 changes: 5 additions & 0 deletions .changeset/wild-tables-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa-js": patch
---

Add batch endpoints (remove, add) for Collections to medusa-js
8 changes: 4 additions & 4 deletions docs-util/fixture-gen/src/services/test-pay.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PaymentService } from "medusa-interfaces";
import { AbstractPaymentService } from "@medusajs/medusa";

class TestPayService extends PaymentService {
class TestPayService extends AbstractPaymentService {
static identifier = "test-pay";

constructor() {
super();
constructor(_) {
super(_);
}

async getStatus(paymentData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ These methods are used at different points in the Checkout flow as well as when
The first step to create a payment provider is to create a file in `src/services` with the following content:

```jsx
import { PaymentService } from "medusa-interfaces"
import { AbstractPaymentService } from "@medusajs/medusa"

class MyPaymentService extends PaymentService {
class MyPaymentService extends AbstractPaymentService {

}

Expand Down
132 changes: 104 additions & 28 deletions integration-tests/api/__tests__/admin/discount.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,15 @@ describe("/admin/discounts", () => {
})
expect(response.status).toEqual(200)
expect(response.data.count).toEqual(1)
expect(response.data.discounts).toEqual([
expect.objectContaining({
id: "fixed-discount",
code: "fixed100",
}),
])
expect(response.data.discounts).toHaveLength(1)
expect(response.data.discounts).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: "fixed-discount",
code: "fixed100",
}),
])
)
})

it("fails when listing invalid discount types", async () => {
Expand Down Expand Up @@ -394,12 +397,15 @@ describe("/admin/discounts", () => {
})
expect(response.status).toEqual(200)
expect(response.data.count).toEqual(1)
expect(response.data.discounts).toEqual([
expect.objectContaining({
id: "dynamic-discount",
code: "Dyn100",
}),
])
expect(response.data.discounts).toHaveLength(1)
expect(response.data.discounts).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: "dynamic-discount",
code: "Dyn100",
})
])
)
})

it("lists disabled discounts ", async () => {
Expand All @@ -416,12 +422,15 @@ describe("/admin/discounts", () => {
})
expect(response.status).toEqual(200)
expect(response.data.count).toEqual(1)
expect(response.data.discounts).toEqual([
expect.objectContaining({
id: "disabled-discount",
code: "Dis100",
}),
])
expect(response.data.discounts).toHaveLength(1)
expect(response.data.discounts).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: "disabled-discount",
code: "Dis100",
}),
])
)
})
})

Expand Down Expand Up @@ -614,16 +623,19 @@ describe("/admin/discounts", () => {
})

expect(response.status).toEqual(200)
expect(response.data.discount.rule.conditions).toEqual([
expect.objectContaining({
type: "products",
operator: "in",
}),
expect.objectContaining({
type: "product_types",
operator: "not_in",
}),
])
expect(response.data.discount.rule.conditions).toHaveLength(2)
expect(response.data.discount.rule.conditions).toEqual(
expect.arrayContaining([
expect.objectContaining({
type: "products",
operator: "in",
}),
expect.objectContaining({
type: "product_types",
operator: "not_in",
}),
])
)

const createdRule = response.data.discount.rule
const condsToUpdate = createdRule.conditions[0]
Expand Down Expand Up @@ -1473,6 +1485,70 @@ describe("/admin/discounts", () => {
})
})

describe("POST /admin/discounts/:id", () => {
beforeEach(async () => {
await adminSeeder(dbConnection)
await dbConnection.manager.insert(DiscountRule, {
id: "test-discount-rule",
description: "Test discount rule",
type: "percentage",
value: 10,
allocation: "total",
})
await dbConnection.manager.insert(Discount, {
id: "test-discount",
code: "TESTING",
rule_id: "test-discount-rule",
is_dynamic: false,
is_disabled: false,
ends_at: new Date(),
usage_limit: 10,
valid_duration: "P1D",
})
})

afterEach(async () => {
const db = useDb()
await db.teardown()
})

it("Removes ends_at, valid_duration and usage_limit when fields are updated with null", async () => {
const api = useApi()

await api
.post(
"/admin/discounts/test-discount",
{
ends_at: null,
valid_duration: null,
usage_limit: null,
},
{
headers: {
Authorization: "Bearer test_token",
},
}
)
.catch((err) => {
console.log(err)
})

const resultingDiscount = await api.get(
"/admin/discounts/test-discount",
{ headers: { Authorization: "Bearer test_token" } }
)

expect(resultingDiscount.status).toEqual(200)
expect(resultingDiscount.data.discount).toEqual(
expect.objectContaining({
ends_at: null,
valid_duration: null,
usage_limit: null,
})
)
})
})

describe("testing for soft-deletion + uniqueness on discount codes", () => {
let manager
beforeEach(async () => {
Expand Down
Loading

0 comments on commit 9d773e9

Please sign in to comment.