Skip to content

Commit

Permalink
feat(presets): added presets to several entity drafts for use by audi… (
Browse files Browse the repository at this point in the history
#452)

* feat(presets): added presets to several entity drafts for use by audit log

* feat(presets): add shopping list package to changeset

* feat(presets): add shopping list presets to export
  • Loading branch information
Sarah4VT authored Jan 3, 2024
1 parent 647ba4a commit 3240130
Show file tree
Hide file tree
Showing 22 changed files with 161 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .changeset/tricky-shrimps-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@commercetools-test-data/inventory-entry': minor
'@commercetools-test-data/shopping-list': minor
'@commercetools-test-data/product-type': minor
'@commercetools-test-data/category': minor
'@commercetools-test-data/customer': minor
---

Add presets to several entities for use by audit log
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import withNoParent from './with-no-parent';

const presets = {
withNoParent,
};

export default presets;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { TCategoryDraft } from '../../../types';
import withNoParent from './with-no-parent';

describe('Category with no parent', () => {
it('should return a category containing no parent value', () => {
const category = withNoParent().build<TCategoryDraft>();

expect(category).toEqual(
expect.objectContaining({
parent: undefined,
})
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import CategoryDraft from '../../builder';

const withCategoryNoParent = () => CategoryDraft().parent(undefined);

export default withCategoryNoParent;
8 changes: 7 additions & 1 deletion models/category/src/category-draft/presets/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import changeHistoryData from './change-history-data';
import empty from './empty';
import sampleDataFashion from './sample-data-fashion';
import sampleDataGoodStore from './sample-data-goodstore';

const presets = { empty, sampleDataFashion, sampleDataGoodStore };
const presets = {
empty,
sampleDataFashion,
sampleDataGoodStore,
changeHistoryData,
};

export default presets;
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import usBasedNoState from './us-based-with-no-state';
import withNoDob from './with-no-dob';

const presets = {
usBasedNoState,
withNoDob,
};

export default presets;
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('A US-based customer with no defined state', () => {
state: null,
}),
]),
authenticationMode: 'Password',
})
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ const usBasedNoState = (): TCustomerDraftBuilder =>
.addresses([AddressDraft.presets.changeHistoryData.withCountryUsNoState()])
.defaultBillingAddress(0)
.defaultShippingAddress(0)
.locale('en-US');
.locale('en-US')
.authenticationMode('Password');
export default usBasedNoState;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { TCustomerDraft } from '../../../types';
import withNoDob from './with-no-dob';

describe('A customer with no date of birth', () => {
it('should return customer with date of birth undefined and authentication mode set to `Password`', () => {
const customer = withNoDob().build<TCustomerDraft>();

expect(customer).toEqual(
expect.objectContaining({
dateOfBirth: undefined,
authenticationMode: 'Password',
})
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { TCustomerDraftBuilder } from '../../../types';
import * as CustomerDraft from '../../index';

const withNoDob = (): TCustomerDraftBuilder =>
CustomerDraft.random().dateOfBirth(undefined).authenticationMode('Password');
export default withNoDob;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import withNoSupplyChannel from './with-no-supply-channel';

const presets = {
withNoSupplyChannel,
};

export default presets;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { TInventoryEntryDraft } from '../../../types';
import withNoSupplyChannel from './with-no-supply-channel';

describe('Inventory Entry with no supply channel', () => {
it('should return an inventory entry with supply channel undefined', () => {
const inventoryEntry = withNoSupplyChannel().build<TInventoryEntryDraft>();

expect(inventoryEntry).toEqual(
expect.objectContaining({
supplyChannel: undefined,
})
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import InventoryEntryDraft from '../../builder';

const withNoSupplyChannel = () =>
InventoryEntryDraft().supplyChannel(undefined);

export default withNoSupplyChannel;
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import changeHistoryData from './change-history-data';
import empty from './empty';
import sampleDataGoodStore from './sample-data-goodstore';

const presets = {
changeHistoryData,
empty,
sampleDataGoodStore,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import withNoAttributes from './with-no-attributes';

const presets = {
withNoAttributes,
};

export default presets;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { TProductTypeDraft } from '../../../types';
import withNoAttributes from './with-no-attributes';

describe('Product type with no attributes', () => {
it('should return a product type with attributes undefined', () => {
const category = withNoAttributes().build<TProductTypeDraft>();

expect(category).toEqual(
expect.objectContaining({
attributes: undefined,
})
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import ProductTypeDraft from '../../builder';

const withNoAttributes = () => ProductTypeDraft().attributes(undefined);

export default withNoAttributes;
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import changeHistoryData from './change-history-data';
import empty from './empty';
import sampleDataFashion from './sample-data-fashion';
import sampleDataGoodStore from './sample-data-goodstore';

const presets = { empty, sampleDataFashion, sampleDataGoodStore };
const presets = {
changeHistoryData,
empty,
sampleDataFashion,
sampleDataGoodStore,
};

export default presets;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import withNoCustomer from './with-no-customer';

const presets = {
withNoCustomer,
};

export default presets;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { TShoppingListDraft } from '../../../types';
import withNoCustomer from './with-no-customer';

describe('Shopping List with no customer', () => {
it('should return a shopping list with customer undefined', () => {
const shoppingList = withNoCustomer().build<TShoppingListDraft>();

expect(shoppingList).toEqual(
expect.objectContaining({
customer: undefined,
})
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import ShoppingListDraft from '../../builder';

const withNoCustomer = () => ShoppingListDraft().customer(undefined);

export default withNoCustomer;
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const presets = {};
import changeHistoryData from './change-history-data';

const presets = {
changeHistoryData,
};

export default presets;

0 comments on commit 3240130

Please sign in to comment.