mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(Summarize Node): Fix spaces in Fields to Split By values converted to underscores (#15020)
This commit is contained in:
@@ -88,6 +88,95 @@ describe('Test Summarize Node, aggregateAndSplitData', () => {
|
||||
expect(flattenAggregationResultToArray(result)).toMatchSnapshot('array');
|
||||
});
|
||||
|
||||
test('should handle split field values containing spaces when convertKeysToString is not set', () => {
|
||||
const data = [
|
||||
{
|
||||
Product: 'Widget A',
|
||||
Warehouse: 'WH1',
|
||||
Qty: '5',
|
||||
_itemIndex: 0,
|
||||
},
|
||||
{
|
||||
Product: 'Widget B',
|
||||
Warehouse: 'WH2',
|
||||
Qty: '3',
|
||||
_itemIndex: 1,
|
||||
},
|
||||
{
|
||||
Product: 'Widget A',
|
||||
Warehouse: 'WH3',
|
||||
Qty: '2',
|
||||
_itemIndex: 2,
|
||||
},
|
||||
];
|
||||
|
||||
const aggregations: Aggregations = [
|
||||
{
|
||||
aggregation: 'append',
|
||||
field: 'Warehouse',
|
||||
includeEmpty: true,
|
||||
},
|
||||
];
|
||||
|
||||
const result = aggregateAndSplitData({
|
||||
splitKeys: ['Product'],
|
||||
inputItems: data,
|
||||
fieldsToSummarize: aggregations,
|
||||
options: { continueIfFieldNotFound: true },
|
||||
getValue: fieldValueGetter(),
|
||||
});
|
||||
|
||||
expect(result).toMatchSnapshot('split-field-with-spaces-result');
|
||||
expect(flattenAggregationResultToArray(result)).toMatchSnapshot(
|
||||
'split-field-with-spaces-array',
|
||||
);
|
||||
});
|
||||
|
||||
test('should handle split field values containing spaces when convertKeysToString is true', () => {
|
||||
const data = [
|
||||
{
|
||||
Product: 'Widget A',
|
||||
Warehouse: 'WH1',
|
||||
Qty: '5',
|
||||
_itemIndex: 0,
|
||||
},
|
||||
{
|
||||
Product: 'Widget B',
|
||||
Warehouse: 'WH2',
|
||||
Qty: '3',
|
||||
_itemIndex: 1,
|
||||
},
|
||||
{
|
||||
Product: 'Widget A',
|
||||
Warehouse: 'WH3',
|
||||
Qty: '2',
|
||||
_itemIndex: 2,
|
||||
},
|
||||
];
|
||||
|
||||
const aggregations: Aggregations = [
|
||||
{
|
||||
aggregation: 'append',
|
||||
field: 'Warehouse',
|
||||
includeEmpty: true,
|
||||
},
|
||||
];
|
||||
|
||||
const result = aggregateAndSplitData({
|
||||
splitKeys: ['Product'],
|
||||
inputItems: data,
|
||||
fieldsToSummarize: aggregations,
|
||||
options: { continueIfFieldNotFound: true },
|
||||
getValue: fieldValueGetter(),
|
||||
convertKeysToString: true,
|
||||
});
|
||||
|
||||
expect(result).toMatchSnapshot('split-field-with-spaces-result');
|
||||
expect(flattenAggregationResultToArray(result)).toMatchSnapshot(
|
||||
'split-field-with-spaces-array',
|
||||
);
|
||||
});
|
||||
|
||||
describe('with skipEmptySplitFields=true', () => {
|
||||
test('should skip empty split fields', () => {
|
||||
const data = [
|
||||
|
||||
Reference in New Issue
Block a user