From 89a560239bf52b0bf4f6733f07c3951cb57432f5 Mon Sep 17 00:00:00 2001 From: Redin Daniil Date: Thu, 23 Jan 2025 20:12:11 +0400 Subject: [PATCH 1/3] ECWID-156302 - add absent enums to DiscountBase --- .github/workflows/pull-request.yml | 2 +- .../com/ecwid/apiclient/v3/util/OrderUtils.kt | 26 ++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9ab6d2c29..2bb17a70c 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -39,7 +39,7 @@ jobs: GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }} - name: Upload artifacts with checks results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: check-results diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt b/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt index a359db5db..4c6de89f4 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt @@ -73,7 +73,10 @@ fun generateTestOrder(): UpdatedOrder { generateTestOnTotalDiscountInfo(), generateTestOnMembershipDiscountInfo(), generateTestOnTotalAndMembershipDiscountInfo(), - generateTestCustomDiscountInfo() + generateTestCustomDiscountInfo(), + generateTestItemDiscountInfo(), + generateTestShippingDiscountInfo(), + generateTestSubtotalDiscountInfo() ), // TODO Pass real discount coupon code when API client will support this @@ -190,6 +193,27 @@ private fun generateTestCustomDiscountInfo() = UpdatedOrder.DiscountInfo( description = "Custom discount " + randomAlphanumeric(8) ) +private fun generateTestItemDiscountInfo() = UpdatedOrder.DiscountInfo( + value = randomPrice(), + type = randomEnumValue(), + base = DiscountBase.ITEM, + description = "On item discount " + randomAlphanumeric(8) +) + +private fun generateTestShippingDiscountInfo() = UpdatedOrder.DiscountInfo( + value = randomPrice(), + type = randomEnumValue(), + base = DiscountBase.SHIPPING, + description = "On shipping discount " + randomAlphanumeric(8) +) + +private fun generateTestSubtotalDiscountInfo() = UpdatedOrder.DiscountInfo( + value = randomPrice(), + type = randomEnumValue(), + base = DiscountBase.SUBTOTAL, + description = "On subtotal discount " + randomAlphanumeric(8) +) + private fun generateTestOrderItem() = UpdatedOrder.OrderItem( // var id: Int? = null, // TODO readonly // productId = com.ecwid.api.v3.randomId(), // TODO need to pass existing product id From 8a7a86b4414c0a3cd5a8d530ec3a279782783606 Mon Sep 17 00:00:00 2001 From: ringo Date: Mon, 27 Jan 2025 11:37:59 +0400 Subject: [PATCH 2/3] Fill in the orderTotal field in tests --- src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt b/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt index 4c6de89f4..deb07ac5c 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt @@ -197,6 +197,7 @@ private fun generateTestItemDiscountInfo() = UpdatedOrder.DiscountInfo( value = randomPrice(), type = randomEnumValue(), base = DiscountBase.ITEM, + orderTotal = randomPrice(), description = "On item discount " + randomAlphanumeric(8) ) @@ -204,6 +205,7 @@ private fun generateTestShippingDiscountInfo() = UpdatedOrder.DiscountInfo( value = randomPrice(), type = randomEnumValue(), base = DiscountBase.SHIPPING, + orderTotal = randomPrice(), description = "On shipping discount " + randomAlphanumeric(8) ) @@ -211,6 +213,7 @@ private fun generateTestSubtotalDiscountInfo() = UpdatedOrder.DiscountInfo( value = randomPrice(), type = randomEnumValue(), base = DiscountBase.SUBTOTAL, + orderTotal = randomPrice(), description = "On subtotal discount " + randomAlphanumeric(8) ) From fa40118160b368712399c9bcb929f7ad320843d7 Mon Sep 17 00:00:00 2001 From: ringo Date: Mon, 27 Jan 2025 12:43:37 +0400 Subject: [PATCH 3/3] Revert changes to pull-request.yml in case they were unnecessary for the branch --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 2bb17a70c..9ab6d2c29 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -39,7 +39,7 @@ jobs: GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }} - name: Upload artifacts with checks results - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 if: failure() with: name: check-results