Skip to content
Closed
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
5 changes: 5 additions & 0 deletions .changeset/tiny-suits-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-test-data/shipping-method': patch
---

B2C Lifestyle Presets - Fix shipping method zone rates
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ describe('Shipping Method with express preset', () => {
},
"tiers": [],
},
],
"zone": {
"key": "europe",
"typeId": "zone",
},
},
{
"shippingRates": [
{
"freeAbove": undefined,
"price": {
Expand All @@ -60,16 +68,10 @@ describe('Shipping Method with express preset', () => {
"tiers": [],
},
],
"zone": [
{
"key": "europe",
"typeId": "zone",
},
{
"key": "usa",
"typeId": "zone",
},
],
"zone": {
"key": "usa",
"typeId": "zone",
},
},
],
}
Expand Down Expand Up @@ -137,6 +139,14 @@ describe('Shipping Method with express preset', () => {
},
"tiers": [],
},
],
"zone": {
"key": "europe",
"typeId": "zone",
},
},
{
"shippingRates": [
{
"freeAbove": undefined,
"price": {
Expand All @@ -146,16 +156,10 @@ describe('Shipping Method with express preset', () => {
"tiers": [],
},
],
"zone": [
{
"key": "europe",
"typeId": "zone",
},
{
"key": "usa",
"typeId": "zone",
},
],
"zone": {
"key": "usa",
"typeId": "zone",
},
},
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ const expressShippingMethod = (): TShippingMethodDraftBuilder =>
.taxCategory(
KeyReferenceDraft.presets.taxCategory().key(standardTaxCategoryDraft.key!)
)
.zoneRates([ZoneRateDraft.presets.sampleDataB2CLifestyle.express()])
.zoneRates([
ZoneRateDraft.presets.sampleDataB2CLifestyle.expressEuropeUk(),
ZoneRateDraft.presets.sampleDataB2CLifestyle.expressUsa(),
])
.isDefault(false);

export default expressShippingMethod;
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ describe('Shipping Method with standard preset', () => {
},
"tiers": undefined,
},
],
"zone": {
"key": "europe",
"typeId": "zone",
},
},
{
"shippingRates": [
{
"freeAbove": {
"centAmount": 1000000,
Expand All @@ -69,16 +77,10 @@ describe('Shipping Method with standard preset', () => {
"tiers": undefined,
},
],
"zone": [
{
"key": "europe",
"typeId": "zone",
},
{
"key": "usa",
"typeId": "zone",
},
],
"zone": {
"key": "usa",
"typeId": "zone",
},
},
],
}
Expand Down Expand Up @@ -152,6 +154,14 @@ describe('Shipping Method with standard preset', () => {
},
"tiers": undefined,
},
],
"zone": {
"key": "europe",
"typeId": "zone",
},
},
{
"shippingRates": [
{
"freeAbove": {
"centAmount": 1000000,
Expand All @@ -164,16 +174,10 @@ describe('Shipping Method with standard preset', () => {
"tiers": undefined,
},
],
"zone": [
{
"key": "europe",
"typeId": "zone",
},
{
"key": "usa",
"typeId": "zone",
},
],
"zone": {
"key": "usa",
"typeId": "zone",
},
},
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ const standardShippingMethod = (): TShippingMethodDraftBuilder =>
.taxCategory(
KeyReferenceDraft.presets.taxCategory().key(standardTaxCategoryDraft.key!)
)
.zoneRates([ZoneRateDraft.presets.sampleDataB2CLifestyle.standard()])
.zoneRates([
ZoneRateDraft.presets.sampleDataB2CLifestyle.standardEuropeUk(),
ZoneRateDraft.presets.sampleDataB2CLifestyle.standardUsa(),
])
.isDefault(true);

export default standardShippingMethod;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { TZoneRateDraft, TZoneRateDraftGraphql } from '../../../types';
import express from './express';
import expressEuropeUk from './express-europe-uk';

describe('with express preset', () => {
describe('with express europe and uk preset', () => {
it(`should return an express preset`, () => {
const expressPreset = express().build<TZoneRateDraft>();
const expressPreset = expressEuropeUk().build<TZoneRateDraft>();
expect(expressPreset).toMatchInlineSnapshot(`
{
"shippingRates": [
Expand All @@ -23,32 +23,18 @@ describe('with express preset', () => {
},
"tiers": [],
},
{
"freeAbove": undefined,
"price": {
"centAmount": 75000,
"currencyCode": "USD",
},
"tiers": [],
},
],
"zone": [
{
"key": "europe",
"typeId": "zone",
},
{
"key": "usa",
"typeId": "zone",
},
],
"zone": {
"key": "europe",
"typeId": "zone",
},
}
`);
});

it(`should return an express preset when built for Graphql`, () => {
const expressPresetGraphql =
express().buildGraphql<TZoneRateDraftGraphql>();
expressEuropeUk().buildGraphql<TZoneRateDraftGraphql>();
expect(expressPresetGraphql).toMatchInlineSnapshot(`
{
"shippingRates": [
Expand All @@ -68,25 +54,11 @@ describe('with express preset', () => {
},
"tiers": [],
},
{
"freeAbove": undefined,
"price": {
"centAmount": 75000,
"currencyCode": "USD",
},
"tiers": [],
},
],
"zone": [
{
"key": "europe",
"typeId": "zone",
},
{
"key": "usa",
"typeId": "zone",
},
],
"zone": {
"key": "europe",
"typeId": "zone",
},
}
`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@ const europeZone = ZoneDraft.presets.sampleDataB2CLifestyle
.europeAndUk()
.build<TZoneDraft>();

const usaZone = ZoneDraft.presets.sampleDataB2CLifestyle
.countryUsa()
.build<TZoneDraft>();

const express = (): TZoneRateDraftBuilder =>
const expressEuropeUk = (): TZoneRateDraftBuilder =>
ZoneRateDraft.random()
.zone([
KeyReferenceDraft.presets.zone().key(europeZone.key!),
KeyReferenceDraft.presets.zone().key(usaZone.key!),
])
.zone(KeyReferenceDraft.presets.zone().key(europeZone.key!))
.shippingRates([
ShippingRateDraft.presets.sampleDataB2CLifestyle.eur75000(),
ShippingRateDraft.presets.sampleDataB2CLifestyle.gbp75000(),
ShippingRateDraft.presets.sampleDataB2CLifestyle.usd75000(),
]);

export default express;
export default expressEuropeUk;
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { TZoneRateDraft, TZoneRateDraftGraphql } from '../../../types';
import expressUsa from './express-us';

describe('with express us preset', () => {
it(`should return an express preset`, () => {
const expressPreset = expressUsa().build<TZoneRateDraft>();
expect(expressPreset).toMatchInlineSnapshot(`
{
"shippingRates": [
{
"freeAbove": undefined,
"price": {
"centAmount": 75000,
"currencyCode": "USD",
},
"tiers": [],
},
],
"zone": {
"key": "usa",
"typeId": "zone",
},
}
`);
});

it(`should return an express preset when built for Graphql`, () => {
const expressPresetGraphql =
expressUsa().buildGraphql<TZoneRateDraftGraphql>();
expect(expressPresetGraphql).toMatchInlineSnapshot(`
{
"shippingRates": [
{
"freeAbove": undefined,
"price": {
"centAmount": 75000,
"currencyCode": "USD",
},
"tiers": [],
},
],
"zone": {
"key": "usa",
"typeId": "zone",
},
}
`);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { KeyReferenceDraft } from '@commercetools-test-data/commons';
import { ZoneDraft, type TZoneDraft } from '@commercetools-test-data/zone';
import { ShippingRateDraft } from '../../../../shipping-rate';
import type { TZoneRateDraftBuilder } from '../../../types';
import * as ZoneRateDraft from '../../index';

const usaZone = ZoneDraft.presets.sampleDataB2CLifestyle
.countryUsa()
.build<TZoneDraft>();

const expressUsa = (): TZoneRateDraftBuilder =>
ZoneRateDraft.random()
.zone(KeyReferenceDraft.presets.zone().key(usaZone.key!))
.shippingRates([
ShippingRateDraft.presets.sampleDataB2CLifestyle.usd75000(),
]);

export default expressUsa;
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import express from './express';
import standard from './standard';
import expressEuropeUk from './express-europe-uk';
import expressUsa from './express-us';
import standardEuropeUk from './standard-europe-uk';
import standardUsa from './standard-us';

const presets = {
express,
standard,
expressEuropeUk,
expressUsa,
standardEuropeUk,
standardUsa,
};

export default presets;
Loading