@contrail/flexplm 1.7.4 → 1.7.5-alpha.16134da
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/interfaces/item-family-changes.d.ts +6 -0
- package/lib/interfaces/item-family-changes.js +8 -0
- package/lib/publish/base-process-publish-assortment.d.ts +3 -0
- package/lib/publish/base-process-publish-assortment.js +58 -2
- package/lib/publish/base-process-publish-assortment.spec.js +231 -0
- package/package.json +1 -1
|
@@ -12,6 +12,12 @@ export declare class ItemFamilyChanges {
|
|
|
12
12
|
colorDeletes: string[];
|
|
13
13
|
colorUpdates: string[];
|
|
14
14
|
colorUnchanged: string[];
|
|
15
|
+
/** Options that changed but are still pre-development. They do NOT produce
|
|
16
|
+
* LCSSKUSeasonLink events - they only signal that the family needs republishing. */
|
|
17
|
+
preDevelopmentOptionChanges: string[];
|
|
18
|
+
/** True when at least one option row was tracked at family level only, because the option is
|
|
19
|
+
* pre-development while the family itself is released. */
|
|
20
|
+
hasPreDevelopmentOnlyOptions: boolean;
|
|
15
21
|
assortmentItemFullChangeMap: Map<string, any>;
|
|
16
22
|
assortmentItemDeleteMap: Map<string, any>;
|
|
17
23
|
itemToFederatedIdMapping: Map<string, string>;
|
|
@@ -14,6 +14,12 @@ class ItemFamilyChanges {
|
|
|
14
14
|
this.colorDeletes = [];
|
|
15
15
|
this.colorUpdates = [];
|
|
16
16
|
this.colorUnchanged = [];
|
|
17
|
+
/** Options that changed but are still pre-development. They do NOT produce
|
|
18
|
+
* LCSSKUSeasonLink events - they only signal that the family needs republishing. */
|
|
19
|
+
this.preDevelopmentOptionChanges = [];
|
|
20
|
+
/** True when at least one option row was tracked at family level only, because the option is
|
|
21
|
+
* pre-development while the family itself is released. */
|
|
22
|
+
this.hasPreDevelopmentOnlyOptions = false;
|
|
17
23
|
this.assortmentItemFullChangeMap = new Map();
|
|
18
24
|
this.assortmentItemDeleteMap = new Map();
|
|
19
25
|
this.itemToFederatedIdMapping = new Map();
|
|
@@ -32,6 +38,8 @@ class ItemFamilyChanges {
|
|
|
32
38
|
s += ' colorDeletes: [' + this.colorDeletes + ']\n';
|
|
33
39
|
s += ' colorUpdates: [' + this.colorUpdates + ']\n';
|
|
34
40
|
s += ' colorUnchanged: [' + this.colorUnchanged + ']\n';
|
|
41
|
+
s += ' preDevelopmentOptionChanges: [' + this.preDevelopmentOptionChanges + ']\n';
|
|
42
|
+
s += ' hasPreDevelopmentOnlyOptions: ' + this.hasPreDevelopmentOnlyOptions + '\n';
|
|
35
43
|
s += 'assortmentItemFullChangeMap:\n';
|
|
36
44
|
s += 'size: ' + this.assortmentItemFullChangeMap.size + '\n[';
|
|
37
45
|
for (const key of this.assortmentItemFullChangeMap.keys()) {
|
|
@@ -62,6 +62,9 @@ export declare class BaseProcessPublishAssortment {
|
|
|
62
62
|
getFullChangeAssortmentMap(fullChange: any): Map<string, object>;
|
|
63
63
|
getDeleteChangesAssortmentMap(deleteChanges: any[]): Map<string, object>;
|
|
64
64
|
getReleasedForDevelopmentItemAndFamilyIds(fullChange: any, deleteChanges: any): string[];
|
|
65
|
+
/** Adds item families that pass meetsCriteria() but whose option rows are all pre-development.
|
|
66
|
+
* Only ever ADDS family ids - never option ids, and never removes anything. */
|
|
67
|
+
protected addReleasedFamiliesOfPreDevelopmentOptions(aItems: any[], releasedForDevelopmentItemIds: string[]): void;
|
|
65
68
|
meetsCriteria(aItem: any): boolean;
|
|
66
69
|
processPublish(pcd: PublishChangeData, changeDetail: any, fullChange: any, deleteChanges: any): Promise<{
|
|
67
70
|
results: {
|
|
@@ -527,9 +527,34 @@ class BaseProcessPublishAssortment {
|
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
529
|
}
|
|
530
|
+
this.addReleasedFamiliesOfPreDevelopmentOptions(assortmentItemsArray, releasedForDevelopmentItemIds);
|
|
531
|
+
this.addReleasedFamiliesOfPreDevelopmentOptions(deleteChanges, releasedForDevelopmentItemIds);
|
|
530
532
|
console.info('releasedForDevelopmentItemIds: ' + releasedForDevelopmentItemIds);
|
|
531
533
|
return releasedForDevelopmentItemIds;
|
|
532
534
|
}
|
|
535
|
+
/** Adds item families that pass meetsCriteria() but whose option rows are all pre-development.
|
|
536
|
+
* Only ever ADDS family ids - never option ids, and never removes anything. */
|
|
537
|
+
addReleasedFamiliesOfPreDevelopmentOptions(aItems, releasedForDevelopmentItemIds) {
|
|
538
|
+
for (const aItem of (aItems || [])) {
|
|
539
|
+
const item = aItem?.item;
|
|
540
|
+
const itemId = item?.id;
|
|
541
|
+
const itemFamilyId = item?.itemFamilyId;
|
|
542
|
+
if (!itemFamilyId || itemId === itemFamilyId) {
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
if (releasedForDevelopmentItemIds.includes(itemFamilyId)) {
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
if (this.meetsCriteria(aItem)) {
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
const familyItem = item?.itemFamily;
|
|
552
|
+
if (familyItem && this.meetsCriteria({ item: familyItem })) {
|
|
553
|
+
console.info('adding released family with pre-development options: ' + itemFamilyId);
|
|
554
|
+
releasedForDevelopmentItemIds.push(itemFamilyId);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
533
558
|
meetsCriteria(aItem) {
|
|
534
559
|
const item = aItem?.item;
|
|
535
560
|
const lifecycleStage = item?.lifecycleStage;
|
|
@@ -730,7 +755,11 @@ class BaseProcessPublishAssortment {
|
|
|
730
755
|
for (const [itemId, aItem] of assortmentItemFullChangeMap) {
|
|
731
756
|
const projectItem = aItem?.projectItem;
|
|
732
757
|
const itemFamilyId = aItem?.item?.itemFamilyId;
|
|
733
|
-
|
|
758
|
+
const familyInScope = pcd.releasedForDevelopmentItemIds.includes(itemFamilyId);
|
|
759
|
+
const itemInScope = pcd.releasedForDevelopmentItemIds.includes(itemId);
|
|
760
|
+
// Released family + pre-development option: track at family level only (no SKU events).
|
|
761
|
+
const familyOnly = !itemInScope && familyInScope && itemId !== itemFamilyId;
|
|
762
|
+
if (!familyInScope || (!itemInScope && !familyOnly)) {
|
|
734
763
|
continue;
|
|
735
764
|
}
|
|
736
765
|
const ifc = itemFamilyChanges.get(itemFamilyId) || new item_family_changes_1.ItemFamilyChanges(itemFamilyId, pcd.sinceDate);
|
|
@@ -738,10 +767,29 @@ class BaseProcessPublishAssortment {
|
|
|
738
767
|
ifc.itemFamilyObject = itemId === itemFamilyId ? aItem?.item : aItem?.item?.itemFamily;
|
|
739
768
|
itemFamilyChanges.set(itemFamilyId, ifc);
|
|
740
769
|
}
|
|
770
|
+
else if (itemId === itemFamilyId) {
|
|
771
|
+
// A pre-development option row may have created this bucket with the partial
|
|
772
|
+
// item.itemFamily; the family's own row carries the full item, so prefer it.
|
|
773
|
+
ifc.itemFamilyObject = aItem?.item;
|
|
774
|
+
}
|
|
741
775
|
ifc.assortmentItemFullChangeMap.set(itemId, aItem);
|
|
742
776
|
if (pcd.itemToFederatedIdMapping.has(itemId)) {
|
|
743
777
|
ifc.itemToFederatedIdMapping.set(itemId, pcd.itemToFederatedIdMapping.get(itemId));
|
|
744
778
|
}
|
|
779
|
+
if (familyOnly) {
|
|
780
|
+
ifc.hasPreDevelopmentOnlyOptions = true;
|
|
781
|
+
if (addIds.includes(itemId) || deleteIds.includes(itemId) || updateIds.includes(itemId)
|
|
782
|
+
|| (projectItem && new Date(projectItem.updatedOn) > pcd.sinceDate)) {
|
|
783
|
+
ifc.preDevelopmentOptionChanges.push(itemId);
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
ifc.colorUnchanged.push(itemId);
|
|
787
|
+
}
|
|
788
|
+
if (projectItem && !projectItem?.roles && aItem?.item?.roles) {
|
|
789
|
+
projectItem.roles = aItem?.item?.roles;
|
|
790
|
+
}
|
|
791
|
+
continue;
|
|
792
|
+
}
|
|
745
793
|
if (itemId === itemFamilyId) {
|
|
746
794
|
if (addIds.includes(itemId))
|
|
747
795
|
ifc.familyAdd = true;
|
|
@@ -780,7 +828,10 @@ class BaseProcessPublishAssortment {
|
|
|
780
828
|
for (const [itemId, delEntity] of assortmentItemDeleteMap) {
|
|
781
829
|
const itemFamilyId = delEntity?.item?.itemFamilyId;
|
|
782
830
|
const item = delEntity?.item;
|
|
783
|
-
|
|
831
|
+
const familyInScope = pcd.releasedForDevelopmentItemIds.includes(itemFamilyId);
|
|
832
|
+
const itemInScope = pcd.releasedForDevelopmentItemIds.includes(itemId);
|
|
833
|
+
const familyOnly = !itemInScope && familyInScope && itemId !== itemFamilyId;
|
|
834
|
+
if (!familyInScope || (!itemInScope && !familyOnly)) {
|
|
784
835
|
continue;
|
|
785
836
|
}
|
|
786
837
|
else {
|
|
@@ -810,6 +861,10 @@ class BaseProcessPublishAssortment {
|
|
|
810
861
|
if (itemId === itemFamilyId) {
|
|
811
862
|
ifc.familyDelete = true;
|
|
812
863
|
}
|
|
864
|
+
else if (familyOnly) {
|
|
865
|
+
ifc.hasPreDevelopmentOnlyOptions = true;
|
|
866
|
+
ifc.preDevelopmentOptionChanges.push(itemId);
|
|
867
|
+
}
|
|
813
868
|
else {
|
|
814
869
|
ifc.colorDeletes.push(itemId);
|
|
815
870
|
}
|
|
@@ -857,6 +912,7 @@ class BaseProcessPublishAssortment {
|
|
|
857
912
|
const projectItem = this.getProjectItem(itemFamilyChanges, itemFamilyChanges.itemFamilyId);
|
|
858
913
|
const familyAssortmentItem = itemFamilyChanges.familyAdd || itemFamilyChanges.familyUpdate || itemFamilyChanges.familyDelete
|
|
859
914
|
|| itemFamilyChanges.colorAdds.length > 0 || itemFamilyChanges.colorUpdates.length > 0 || itemFamilyChanges.colorDeletes.length > 0
|
|
915
|
+
|| itemFamilyChanges.preDevelopmentOptionChanges.length > 0
|
|
860
916
|
|| (projectItem && this.updatedSinceDate(projectItem, itemFamilyChanges.sinceDate));
|
|
861
917
|
//familyItemRemoved is used when adding the first option to an assortment
|
|
862
918
|
//and will have updates for the family item.
|
|
@@ -1874,3 +1874,234 @@ describe('sendToFlexPLM / handleVibeIQFile / sendPublishPayloadEvent', () => {
|
|
|
1874
1874
|
});
|
|
1875
1875
|
});
|
|
1876
1876
|
});
|
|
1877
|
+
describe('released family with pre-development options', () => {
|
|
1878
|
+
const FAMILY_ID = 'AERfdvdAt1HHEVvQ';
|
|
1879
|
+
const LIME_ID = 'limeGreenItemId__';
|
|
1880
|
+
const MAROON_ID = 'maroonItemId_____';
|
|
1881
|
+
const SINCE = new Date('2026-09-03T16:54:20.778Z');
|
|
1882
|
+
const BEFORE_SINCE = '2026-09-01T00:00:00.000Z';
|
|
1883
|
+
const AFTER_SINCE = '2026-09-03T17:00:00.000Z';
|
|
1884
|
+
/** The full family item, as it appears on the family's own assortment row. */
|
|
1885
|
+
const fullFamilyItem = {
|
|
1886
|
+
id: FAMILY_ID, itemFamilyId: FAMILY_ID, name: 'Sweatpant', itemNumber: 11,
|
|
1887
|
+
lifecycleStage: 'released', roles: ['family'], richFamilyOnlyField: 'PRESENT'
|
|
1888
|
+
};
|
|
1889
|
+
/** The partial family item, as hydrated onto an option row. */
|
|
1890
|
+
const partialFamilyItem = {
|
|
1891
|
+
id: FAMILY_ID, itemFamilyId: FAMILY_ID, name: 'Sweatpant', itemNumber: 11,
|
|
1892
|
+
lifecycleStage: 'released', roles: ['family']
|
|
1893
|
+
};
|
|
1894
|
+
const familyRow = () => ({
|
|
1895
|
+
entityType: 'assortment-item',
|
|
1896
|
+
id: 'ai-' + FAMILY_ID,
|
|
1897
|
+
itemId: FAMILY_ID,
|
|
1898
|
+
item: { ...fullFamilyItem },
|
|
1899
|
+
projectItem: { id: 'proj:' + FAMILY_ID, itemId: FAMILY_ID, updatedOn: BEFORE_SINCE, roles: ['family'] }
|
|
1900
|
+
});
|
|
1901
|
+
const optionRow = (itemId, optionName, projectItemUpdatedOn) => ({
|
|
1902
|
+
entityType: 'assortment-item',
|
|
1903
|
+
id: 'ai-' + itemId,
|
|
1904
|
+
itemId,
|
|
1905
|
+
item: {
|
|
1906
|
+
id: itemId, itemFamilyId: FAMILY_ID, name: 'Sweatpant', optionName,
|
|
1907
|
+
optionGroup: 'color', lifecycleStage: 'concept', roles: ['color', 'option'],
|
|
1908
|
+
itemFamily: { ...partialFamilyItem }
|
|
1909
|
+
},
|
|
1910
|
+
projectItem: { id: 'proj:' + itemId, itemId, updatedOn: projectItemUpdatedOn, roles: ['color', 'option'] },
|
|
1911
|
+
familyProjectItem: { id: 'proj:' + FAMILY_ID, itemId: FAMILY_ID, updatedOn: BEFORE_SINCE, roles: ['family'] }
|
|
1912
|
+
});
|
|
1913
|
+
const emptyDetail = { adds: [], deletes: [], updates: [], familyItemsRemoved: [] };
|
|
1914
|
+
const baseConfig = { identifierAtts: { LCSProduct: ['itemNumber'] }, itemPreDevelopmentLifecycleStages: ['concept'] };
|
|
1915
|
+
const makePpa = () => {
|
|
1916
|
+
const cfg = { ...baseConfig };
|
|
1917
|
+
const mfu = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
1918
|
+
return new base_process_publish_assortment_1.BaseProcessPublishAssortment(cfg, new data_converter_1.DataConverter(cfg, mfu), mfu);
|
|
1919
|
+
};
|
|
1920
|
+
const makePcd = (releasedIds) => {
|
|
1921
|
+
const sf = { entityReference: 'assortment:11EZML5dMn3tREuT', objectClass: 'LCSSeason' };
|
|
1922
|
+
const pcd = new publish_change_data_1.PublishChangeData('11EZML5dMn3tREuT', sf, 'apc1', SINCE);
|
|
1923
|
+
pcd.itemToFederatedIdMapping = new Map();
|
|
1924
|
+
pcd.releasedForDevelopmentItemIds = releasedIds;
|
|
1925
|
+
return pcd;
|
|
1926
|
+
};
|
|
1927
|
+
const eventSeasonFed = { entityReference: 'assortment:a1', objectClass: 'LCSSeason' };
|
|
1928
|
+
const stubEventDeps = (ppa) => {
|
|
1929
|
+
jest.spyOn(ppa, 'getAssortment').mockResolvedValue({ id: 'a1', publishToFlexPLM: true });
|
|
1930
|
+
jest.spyOn(ppa, 'getSeasonalData').mockResolvedValue({});
|
|
1931
|
+
jest.spyOn(map_utils_1.MapUtil, 'applyTransformMap').mockImplementation(async (...args) => args[2]);
|
|
1932
|
+
jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getIdentifierProperties').mockResolvedValue(['itemNumber']);
|
|
1933
|
+
jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getInformationalProperties').mockResolvedValue([]);
|
|
1934
|
+
jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'isOutboundCreatableFromEntity').mockResolvedValue(true);
|
|
1935
|
+
};
|
|
1936
|
+
afterEach(() => { jest.restoreAllMocks(); });
|
|
1937
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
1938
|
+
// getReleasedForDevelopmentItemAndFamilyIds
|
|
1939
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
1940
|
+
it('released family enters scope; concept options do NOT', () => {
|
|
1941
|
+
const fullChange = { assortmentItems: [optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE),
|
|
1942
|
+
optionRow(MAROON_ID, 'Maroon', BEFORE_SINCE)] };
|
|
1943
|
+
expect(makePpa().getReleasedForDevelopmentItemAndFamilyIds(fullChange, [])).toEqual([FAMILY_ID]);
|
|
1944
|
+
});
|
|
1945
|
+
it('released family enters scope; concept options do NOT', () => {
|
|
1946
|
+
const row = optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE);
|
|
1947
|
+
row.item.itemFamily = { ...partialFamilyItem, lifecycleStage: 'concept' };
|
|
1948
|
+
expect(makePpa().getReleasedForDevelopmentItemAndFamilyIds({ assortmentItems: [row] }, [])).toEqual([]);
|
|
1949
|
+
});
|
|
1950
|
+
it('family reached only through a delete record', () => {
|
|
1951
|
+
const deleted = optionRow(MAROON_ID, 'Maroon', BEFORE_SINCE);
|
|
1952
|
+
expect(makePpa().getReleasedForDevelopmentItemAndFamilyIds({ assortmentItems: [] }, [deleted]))
|
|
1953
|
+
.toEqual([FAMILY_ID]);
|
|
1954
|
+
});
|
|
1955
|
+
it('two concept options of the same family add the family only once', () => {
|
|
1956
|
+
const fullChange = { assortmentItems: [optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE),
|
|
1957
|
+
optionRow(MAROON_ID, 'Maroon', BEFORE_SINCE)] };
|
|
1958
|
+
expect(makePpa().getReleasedForDevelopmentItemAndFamilyIds(fullChange, [])).toHaveLength(1);
|
|
1959
|
+
});
|
|
1960
|
+
it('option row with no hydrated itemFamily is skipped without throwing', () => {
|
|
1961
|
+
const bare = optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE);
|
|
1962
|
+
delete bare.item.itemFamily;
|
|
1963
|
+
expect(makePpa().getReleasedForDevelopmentItemAndFamilyIds({ assortmentItems: [bare] }, [])).toEqual([]);
|
|
1964
|
+
});
|
|
1965
|
+
it('released family WITH its own assortment row is in scope with or without the flag', () => {
|
|
1966
|
+
const rows = { assortmentItems: [familyRow(), optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE)] };
|
|
1967
|
+
expect(makePpa().getReleasedForDevelopmentItemAndFamilyIds(rows, [])).toEqual([FAMILY_ID]);
|
|
1968
|
+
});
|
|
1969
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
1970
|
+
// getItemFamilyChanges
|
|
1971
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
1972
|
+
it('ACTION 2: deleting a concept option marks the released family for republish', () => {
|
|
1973
|
+
const ppa = makePpa();
|
|
1974
|
+
const remaining = optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE);
|
|
1975
|
+
const deleted = optionRow(MAROON_ID, 'Maroon', BEFORE_SINCE);
|
|
1976
|
+
const pcd = makePcd([FAMILY_ID]);
|
|
1977
|
+
pcd.itemFamilyChanges = ppa.getItemFamilyChanges(pcd, emptyDetail, ppa.getFullChangeAssortmentMap({ assortmentItems: [remaining] }), ppa.getDeleteChangesAssortmentMap([deleted]));
|
|
1978
|
+
expect(pcd.itemFamilyChanges.size).toEqual(1);
|
|
1979
|
+
const ifc = pcd.itemFamilyChanges.get(FAMILY_ID);
|
|
1980
|
+
expect(ifc.preDevelopmentOptionChanges).toEqual([MAROON_ID]);
|
|
1981
|
+
expect(ifc.hasPreDevelopmentOnlyOptions).toBe(true);
|
|
1982
|
+
expect(ifc.colorDeletes).toEqual([]);
|
|
1983
|
+
expect(ifc.colorAdds).toEqual([]);
|
|
1984
|
+
expect(ifc.itemFamilyObject.id).toEqual(FAMILY_ID);
|
|
1985
|
+
});
|
|
1986
|
+
it('adding a concept option marks the family, not a colorAdd', () => {
|
|
1987
|
+
const ppa = makePpa();
|
|
1988
|
+
const added = optionRow(MAROON_ID, 'Maroon', BEFORE_SINCE);
|
|
1989
|
+
const pcd = makePcd([FAMILY_ID]);
|
|
1990
|
+
pcd.itemFamilyChanges = ppa.getItemFamilyChanges(pcd, { ...emptyDetail, adds: [{ id: MAROON_ID }] }, ppa.getFullChangeAssortmentMap({ assortmentItems: [added] }), new Map());
|
|
1991
|
+
const ifc = pcd.itemFamilyChanges.get(FAMILY_ID);
|
|
1992
|
+
expect(ifc.preDevelopmentOptionChanges).toEqual([MAROON_ID]);
|
|
1993
|
+
expect(ifc.colorAdds).toEqual([]);
|
|
1994
|
+
});
|
|
1995
|
+
it('ACTION 1: nothing changed - family bucket exists but signals no change', () => {
|
|
1996
|
+
const ppa = makePpa();
|
|
1997
|
+
const pcd = makePcd([FAMILY_ID]);
|
|
1998
|
+
const rows = { assortmentItems: [optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE),
|
|
1999
|
+
optionRow(MAROON_ID, 'Maroon', BEFORE_SINCE)] };
|
|
2000
|
+
pcd.itemFamilyChanges = ppa.getItemFamilyChanges(pcd, emptyDetail, ppa.getFullChangeAssortmentMap(rows), new Map());
|
|
2001
|
+
const ifc = pcd.itemFamilyChanges.get(FAMILY_ID);
|
|
2002
|
+
expect(ifc.preDevelopmentOptionChanges).toEqual([]);
|
|
2003
|
+
expect(ifc.colorUnchanged.sort()).toEqual([LIME_ID, MAROON_ID].sort());
|
|
2004
|
+
});
|
|
2005
|
+
it('a concept option updated after sinceDate becomes a preDevelopmentOptionChange', () => {
|
|
2006
|
+
const ppa = makePpa();
|
|
2007
|
+
const pcd = makePcd([FAMILY_ID]);
|
|
2008
|
+
pcd.itemFamilyChanges = ppa.getItemFamilyChanges(pcd, emptyDetail, ppa.getFullChangeAssortmentMap({ assortmentItems: [optionRow(LIME_ID, 'Lime Green', AFTER_SINCE)] }), new Map());
|
|
2009
|
+
expect(pcd.itemFamilyChanges.size).toEqual(1);
|
|
2010
|
+
const ifc = pcd.itemFamilyChanges.get(FAMILY_ID);
|
|
2011
|
+
expect(ifc.preDevelopmentOptionChanges).toEqual([LIME_ID]);
|
|
2012
|
+
expect(ifc.colorUnchanged).toEqual([]);
|
|
2013
|
+
expect(ifc.hasPreDevelopmentOnlyOptions).toBe(true);
|
|
2014
|
+
});
|
|
2015
|
+
it('REGRESSION: a released option is still a colorAdd, never a preDevelopmentOptionChange', () => {
|
|
2016
|
+
const ppa = makePpa();
|
|
2017
|
+
const released = optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE);
|
|
2018
|
+
released.item.lifecycleStage = 'development';
|
|
2019
|
+
const pcd = makePcd([FAMILY_ID, LIME_ID]);
|
|
2020
|
+
pcd.itemFamilyChanges = ppa.getItemFamilyChanges(pcd, { ...emptyDetail, adds: [{ id: LIME_ID }] }, ppa.getFullChangeAssortmentMap({ assortmentItems: [released] }), new Map());
|
|
2021
|
+
const ifc = pcd.itemFamilyChanges.get(FAMILY_ID);
|
|
2022
|
+
expect(ifc.colorAdds).toEqual([LIME_ID]);
|
|
2023
|
+
expect(ifc.preDevelopmentOptionChanges).toEqual([]);
|
|
2024
|
+
expect(ifc.hasPreDevelopmentOnlyOptions).toBe(false);
|
|
2025
|
+
});
|
|
2026
|
+
it('itemFamilyObject prefers the full family item when the OPTION row is iterated first', () => {
|
|
2027
|
+
const ppa = makePpa();
|
|
2028
|
+
const pcd = makePcd([FAMILY_ID]);
|
|
2029
|
+
const map = new Map();
|
|
2030
|
+
map.set(LIME_ID, optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE));
|
|
2031
|
+
map.set(FAMILY_ID, familyRow());
|
|
2032
|
+
pcd.itemFamilyChanges = ppa.getItemFamilyChanges(pcd, emptyDetail, map, new Map());
|
|
2033
|
+
const ifc = pcd.itemFamilyChanges.get(FAMILY_ID);
|
|
2034
|
+
expect(ifc.itemFamilyObject.richFamilyOnlyField).toEqual('PRESENT');
|
|
2035
|
+
});
|
|
2036
|
+
it('itemFamilyObject is the full family item when the FAMILY row is iterated first', () => {
|
|
2037
|
+
const ppa = makePpa();
|
|
2038
|
+
const pcd = makePcd([FAMILY_ID]);
|
|
2039
|
+
const map = new Map();
|
|
2040
|
+
map.set(FAMILY_ID, familyRow());
|
|
2041
|
+
map.set(LIME_ID, optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE));
|
|
2042
|
+
pcd.itemFamilyChanges = ppa.getItemFamilyChanges(pcd, emptyDetail, map, new Map());
|
|
2043
|
+
const ifc = pcd.itemFamilyChanges.get(FAMILY_ID);
|
|
2044
|
+
expect(ifc.itemFamilyObject.richFamilyOnlyField).toEqual('PRESENT');
|
|
2045
|
+
});
|
|
2046
|
+
it('delete record with a missing item entity is skipped safely', () => {
|
|
2047
|
+
const ppa = makePpa();
|
|
2048
|
+
const pcd = makePcd([FAMILY_ID]);
|
|
2049
|
+
const delMap = new Map();
|
|
2050
|
+
delMap.set('GHOST', { itemId: 'GHOST', item: undefined });
|
|
2051
|
+
pcd.itemFamilyChanges = ppa.getItemFamilyChanges(pcd, emptyDetail, new Map(), delMap);
|
|
2052
|
+
expect(pcd.itemFamilyChanges.size).toEqual(0);
|
|
2053
|
+
});
|
|
2054
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
2055
|
+
// getEventsForItemFamilyChanges
|
|
2056
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
2057
|
+
it('emits exactly one LCSProductSeasonLink and zero LCSSKUSeasonLink', async () => {
|
|
2058
|
+
const ppa = makePpa();
|
|
2059
|
+
const ifc = new item_family_changes_1.ItemFamilyChanges(FAMILY_ID, SINCE);
|
|
2060
|
+
ifc.itemFamilyObject = fullFamilyItem;
|
|
2061
|
+
ifc.hasPreDevelopmentOnlyOptions = true;
|
|
2062
|
+
ifc.preDevelopmentOptionChanges.push(MAROON_ID);
|
|
2063
|
+
ifc.assortmentItemFullChangeMap.set(LIME_ID, optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE));
|
|
2064
|
+
stubEventDeps(ppa);
|
|
2065
|
+
const events = await ppa.getEventsForItemFamilyChanges(ifc, 'a1', eventSeasonFed, new Map());
|
|
2066
|
+
expect(events).toHaveLength(1);
|
|
2067
|
+
expect(events[0].objectClass).toBe('LCSProductSeasonLink');
|
|
2068
|
+
expect(events[0].eventType).toBe('UPSERT_ON_SEASON');
|
|
2069
|
+
expect(events[0].entityReference).toBe('item:' + FAMILY_ID);
|
|
2070
|
+
expect(events[0].LCSProduct['itemNumber']).toBe(11);
|
|
2071
|
+
});
|
|
2072
|
+
it('REGRESSION: an ItemFamilyChanges with no changes still emits nothing', async () => {
|
|
2073
|
+
const ppa = makePpa();
|
|
2074
|
+
const ifc = new item_family_changes_1.ItemFamilyChanges(FAMILY_ID, SINCE);
|
|
2075
|
+
ifc.itemFamilyObject = fullFamilyItem;
|
|
2076
|
+
ifc.colorUnchanged.push(LIME_ID, MAROON_ID);
|
|
2077
|
+
ifc.assortmentItemFullChangeMap.set(LIME_ID, optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE));
|
|
2078
|
+
stubEventDeps(ppa);
|
|
2079
|
+
expect(await ppa.getEventsForItemFamilyChanges(ifc, 'a1', eventSeasonFed, new Map())).toHaveLength(0);
|
|
2080
|
+
});
|
|
2081
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
2082
|
+
// republish of an unchanged released family
|
|
2083
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
2084
|
+
const unchangedFamilyIfc = () => {
|
|
2085
|
+
const ifc = new item_family_changes_1.ItemFamilyChanges(FAMILY_ID, SINCE);
|
|
2086
|
+
ifc.itemFamilyObject = fullFamilyItem;
|
|
2087
|
+
ifc.hasPreDevelopmentOnlyOptions = true;
|
|
2088
|
+
ifc.colorUnchanged.push(LIME_ID, MAROON_ID);
|
|
2089
|
+
ifc.assortmentItemFullChangeMap.set(LIME_ID, optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE));
|
|
2090
|
+
return ifc;
|
|
2091
|
+
};
|
|
2092
|
+
it('ACTION 1: unchanged family with pre-development-only options emits nothing', async () => {
|
|
2093
|
+
const ppa = makePpa();
|
|
2094
|
+
stubEventDeps(ppa);
|
|
2095
|
+
expect(await ppa.getEventsForItemFamilyChanges(unchangedFamilyIfc(), 'a1', eventSeasonFed, new Map()))
|
|
2096
|
+
.toHaveLength(0);
|
|
2097
|
+
});
|
|
2098
|
+
it('REGRESSION: an ordinary unchanged released family is not republished', async () => {
|
|
2099
|
+
const ppa = makePpa();
|
|
2100
|
+
stubEventDeps(ppa);
|
|
2101
|
+
const ifc = new item_family_changes_1.ItemFamilyChanges(FAMILY_ID, SINCE);
|
|
2102
|
+
ifc.itemFamilyObject = fullFamilyItem;
|
|
2103
|
+
ifc.colorUnchanged.push(LIME_ID);
|
|
2104
|
+
ifc.assortmentItemFullChangeMap.set(LIME_ID, optionRow(LIME_ID, 'Lime Green', BEFORE_SINCE));
|
|
2105
|
+
expect(await ppa.getEventsForItemFamilyChanges(ifc, 'a1', eventSeasonFed, new Map())).toHaveLength(0);
|
|
2106
|
+
});
|
|
2107
|
+
});
|