mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
fix(Google Sheets Node): Check for column names changes before upsert, append, update (#9649)
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import type { IExecuteFunctions, INode } from 'n8n-workflow';
|
||||
import type { IExecuteFunctions, INode, ResourceMapperField } from 'n8n-workflow';
|
||||
import { GoogleSheet } from '../../../v2/helpers/GoogleSheet';
|
||||
import {
|
||||
addRowNumber,
|
||||
autoMapInputData,
|
||||
checkForSchemaChanges,
|
||||
prepareSheetData,
|
||||
removeEmptyColumns,
|
||||
removeEmptyRows,
|
||||
@@ -400,3 +401,46 @@ describe('Test Google Sheets, lookupValues', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test Google Sheets, checkForSchemaChanges', () => {
|
||||
it('should not to throw error', async () => {
|
||||
const node: INode = {
|
||||
id: '1',
|
||||
name: 'Google Sheets',
|
||||
typeVersion: 4.4,
|
||||
type: 'n8n-nodes-base.googleSheets',
|
||||
position: [60, 760],
|
||||
parameters: {
|
||||
operation: 'append',
|
||||
},
|
||||
};
|
||||
|
||||
expect(() =>
|
||||
checkForSchemaChanges(node, ['id', 'name', 'data'], [
|
||||
{ id: 'id' },
|
||||
{ id: 'name' },
|
||||
{ id: 'data' },
|
||||
] as ResourceMapperField[]),
|
||||
).not.toThrow();
|
||||
});
|
||||
it('should throw error when columns were renamed', async () => {
|
||||
const node: INode = {
|
||||
id: '1',
|
||||
name: 'Google Sheets',
|
||||
typeVersion: 4.4,
|
||||
type: 'n8n-nodes-base.googleSheets',
|
||||
position: [60, 760],
|
||||
parameters: {
|
||||
operation: 'append',
|
||||
},
|
||||
};
|
||||
|
||||
expect(() =>
|
||||
checkForSchemaChanges(node, ['id', 'name', 'data'], [
|
||||
{ id: 'id' },
|
||||
{ id: 'name' },
|
||||
{ id: 'text' },
|
||||
] as ResourceMapperField[]),
|
||||
).toThrow("Column names were updated after the node's setup");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user