-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(inventory-entry/b2c): added non-channel based inventory entries (#…
…727)
- Loading branch information
1 parent
c10536a
commit cccf9fe
Showing
42 changed files
with
1,405 additions
and
290 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,5 @@ | ||
--- | ||
'@commercetools-test-data/inventory-entry': patch | ||
--- | ||
|
||
B2C Lifestyle Presets: Added inventory entries without channels to support Launchpad. |
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
83 changes: 83 additions & 0 deletions
83
...entory-entry/src/inventory-entry-draft/presets/sample-data-b2c/sku-arg-56-channel.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,83 @@ | ||
import type { | ||
TInventoryEntryDraftGraphql, | ||
TInventoryEntryDraftRest, | ||
} from '../../../types'; | ||
import * as presets from './sku-arg-56-channel'; | ||
|
||
describe(`with skuArg56 preset`, () => { | ||
it(`should return a skuArg56 preset when built for rest`, () => { | ||
const skuArg56Preset = presets.restPreset().build(); | ||
expect(skuArg56Preset).toMatchInlineSnapshot(` | ||
{ | ||
"custom": null, | ||
"expectedDelivery": undefined, | ||
"key": undefined, | ||
"quantityOnStock": 100, | ||
"restockableInDays": undefined, | ||
"sku": "ARG-56", | ||
"supplyChannel": { | ||
"key": "inventory-channel", | ||
"typeId": "channel", | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
it(`should return a skuArg56 preset when built for graphql`, () => { | ||
const skuArg56Preset = presets.graphqlPreset().build(); | ||
expect(skuArg56Preset).toMatchInlineSnapshot(` | ||
{ | ||
"custom": null, | ||
"expectedDelivery": undefined, | ||
"key": undefined, | ||
"quantityOnStock": 100, | ||
"restockableInDays": undefined, | ||
"sku": "ARG-56", | ||
"supplyChannel": { | ||
"key": "inventory-channel", | ||
"typeId": "channel", | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
it(`should return a skuArg56 preset when built for legacy rest`, () => { | ||
const skuArg56Preset = presets | ||
.compatPreset() | ||
.buildRest<TInventoryEntryDraftRest>(); | ||
expect(skuArg56Preset).toMatchInlineSnapshot(` | ||
{ | ||
"custom": null, | ||
"expectedDelivery": undefined, | ||
"key": undefined, | ||
"quantityOnStock": 100, | ||
"restockableInDays": undefined, | ||
"sku": "ARG-56", | ||
"supplyChannel": { | ||
"key": "inventory-channel", | ||
"typeId": "channel", | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
it(`should return a skuArg56 preset when built for legacy graphql`, () => { | ||
const skuArg56Preset = presets | ||
.compatPreset() | ||
.buildGraphql<TInventoryEntryDraftGraphql>(); | ||
expect(skuArg56Preset).toMatchInlineSnapshot(` | ||
{ | ||
"custom": null, | ||
"expectedDelivery": undefined, | ||
"key": undefined, | ||
"quantityOnStock": 100, | ||
"restockableInDays": undefined, | ||
"sku": "ARG-56", | ||
"supplyChannel": { | ||
"key": "inventory-channel", | ||
"typeId": "channel", | ||
}, | ||
} | ||
`); | ||
}); | ||
}); |
48 changes: 48 additions & 0 deletions
48
...s/inventory-entry/src/inventory-entry-draft/presets/sample-data-b2c/sku-arg-56-channel.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,48 @@ | ||
import { | ||
ChannelDraft, | ||
type TChannelDraft, | ||
} from '@commercetools-test-data/channel'; | ||
import { KeyReferenceDraft } from '@commercetools-test-data/commons'; | ||
import type { TBuilder } from '@commercetools-test-data/core'; | ||
import { | ||
ProductVariantDraft, | ||
type TProductVariantDraft, | ||
} from '@commercetools-test-data/product'; | ||
import type { | ||
TInventoryEntryDraft, | ||
TInventoryEntryDraftGraphql, | ||
TInventoryEntryDraftRest, | ||
} from '../../../types'; | ||
import { | ||
InventoryEntryDraft, | ||
InventoryEntryDraftGraphql, | ||
InventoryEntryDraftRest, | ||
} from '../../index'; | ||
|
||
const supplyChannel = ChannelDraft.presets.sampleDataB2CLifestyle | ||
.inventoryChannel() | ||
.build<TChannelDraft>(); | ||
|
||
const variant = ProductVariantDraft.presets.sampleDataB2CLifestyle | ||
.ashenRug01() | ||
.build<TProductVariantDraft>(); | ||
|
||
const populatePreset = < | ||
TModel extends TInventoryEntryDraftRest | TInventoryEntryDraftGraphql, | ||
>( | ||
builder: TBuilder<TModel> | ||
): TBuilder<TModel> => { | ||
return builder | ||
.sku(variant.sku!) | ||
.quantityOnStock(100) | ||
.supplyChannel(KeyReferenceDraft.presets.channel().key(supplyChannel.key!)); | ||
}; | ||
|
||
export const restPreset = (): TBuilder<TInventoryEntryDraftRest> => | ||
populatePreset(InventoryEntryDraftRest.presets.empty()); | ||
|
||
export const graphqlPreset = (): TBuilder<TInventoryEntryDraftGraphql> => | ||
populatePreset(InventoryEntryDraftGraphql.presets.empty()); | ||
|
||
export const compatPreset = (): TBuilder<TInventoryEntryDraft> => | ||
populatePreset(InventoryEntryDraft.presets.empty()); |
Oops, something went wrong.