Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(test-data): unstub shims in goodstore data #386

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/great-actors-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-test-data/product-discount': patch
'@commercetools-test-data/cart-discount': patch
---

refactors to goodstore presets
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('with the preset `furnitureBogo`', () => {
"target": {
"discountedQuantity": 1,
"maxOccurrence": undefined,
"predicate": "productType.key = "placeholder"",
"predicate": "productType.key = "furniture-and-decor"",
"selectionMode": "Cheapest",
"triggerQuantity": 2,
"type": "multiBuyLineItems",
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('with the preset `furnitureBogo`', () => {
"multiBuyLineItems": {
"discountedQuantity": 1,
"maxOccurrence": undefined,
"predicate": "productType.key = "placeholder"",
"predicate": "productType.key = "furniture-and-decor"",
"selectionMode": "Cheapest",
"triggerQuantity": 2,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { LocalizedString } from '@commercetools-test-data/commons';
// @unstub
// TODO: Import when available
// import {
// ProductTypeDraft,
// TProductTypeDraft,
// } from '@commercetools-test-data/product-type';
import {
ProductTypeDraft,
TProductTypeDraft,
} from '@commercetools-test-data/product-type';
import {
CartDiscountMultiBuyLineItemsTargetDraft,
CartDiscountValueRelativeDraft,
Expand All @@ -14,11 +12,9 @@ import { stackingMode } from '../../../constants';
import type { TCartDiscountDraftBuilder } from '../../../types';
import * as CartDiscountDraft from '../../index';

// @unstub
// TODO: Need product type draft to be created
// const productTypeDraft = ProductTypeDraft.presets.sampleDataGoodStore
// .furniture()
// .build<TProductTypeDraft>();
const productTypeDraft = ProductTypeDraft.presets.sampleDataGoodStore
.furnitureAndDecor()
.build<TProductTypeDraft>();

const furnitureBogo = (): TCartDiscountDraftBuilder =>
CartDiscountDraft.presets
Expand All @@ -27,10 +23,7 @@ const furnitureBogo = (): TCartDiscountDraftBuilder =>
.cartPredicate('1 = 1')
.target(
CartDiscountMultiBuyLineItemsTargetDraft.random()
// @unstub
// TODO: insert when available
// .predicate(`productType.key = "${productTypeDraft.key}"`)
.predicate(`productType.key = "placeholder"`)
.predicate(`productType.key = "${productTypeDraft.key}"`)
.triggerQuantity(2)
.discountedQuantity(1)
.selectionMode(selectionMode.Cheapest)
Expand Down
2 changes: 2 additions & 0 deletions models/product-discount/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"@commercetools-test-data/commons": "6.0.0",
"@commercetools-test-data/core": "6.0.0",
"@commercetools-test-data/utils": "6.0.0",
"@commercetools-test-data/category": "6.0.0",
"@commercetools-test-data/product-type": "6.0.0",
"@commercetools/platform-sdk": "^4.11.0",
"@faker-js/faker": "^8.0.0"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import {
CategoryDraft,
TCategoryDraft,
} from '@commercetools-test-data/category';
import { LocalizedString, Money } from '@commercetools-test-data/commons';
import { ProductDiscountValueAbsoluteDraft } from '../../../../index';
import type { TProductDiscountDraftBuilder } from '../../../types';
import * as ProductDiscountDraft from '../../index';

const categoryTypeDraft = CategoryDraft.presets.sampleDataGoodStore
.bakeware()
.build<TCategoryDraft>();

const discountBakeware = (): TProductDiscountDraftBuilder =>
ProductDiscountDraft.presets
.empty()
Expand All @@ -11,8 +19,7 @@ const discountBakeware = (): TProductDiscountDraftBuilder =>
Money.random().currencyCode('EUR').centAmount(500),
])
)
// TODO: integrate product type keys
.predicate('categories.key contains "bakeware"')
.predicate(`categories.key contains "${categoryTypeDraft.key}"`)
.name(
LocalizedString.presets
.empty()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { LocalizedString, Money } from '@commercetools-test-data/commons';
import {
ProductTypeDraft,
TProductTypeDraft,
} from '@commercetools-test-data/product-type';
import { ProductDiscountValueAbsoluteDraft } from '../../../../index';
import type { TProductDiscountDraftBuilder } from '../../../types';
import * as ProductDiscountDraft from '../../index';

const productTypeDraft = ProductTypeDraft.presets.sampleDataGoodStore
.furnitureAndDecor()
.build<TProductTypeDraft>();

const discountFurnitureAndDecor = (): TProductDiscountDraftBuilder =>
ProductDiscountDraft.presets
.empty()
Expand All @@ -11,8 +19,7 @@ const discountFurnitureAndDecor = (): TProductDiscountDraftBuilder =>
Money.random().currencyCode('USD').centAmount(1000),
])
)
// TODO: integrate product type keys
.predicate('productType.key = "furniture-and-decor"')
.predicate(`productType.key = "${productTypeDraft.key}"`)
.name(
LocalizedString.presets
.empty()
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.