diff --git a/packages/integration-sdk-cli/src/__tests__/cli-run.test.ts b/packages/integration-sdk-cli/src/__tests__/cli-run.test.ts index f854f044c..8575d9d52 100644 --- a/packages/integration-sdk-cli/src/__tests__/cli-run.test.ts +++ b/packages/integration-sdk-cli/src/__tests__/cli-run.test.ts @@ -80,7 +80,8 @@ test('disables graph object schema validation', async () => { expect(process.env.ENABLE_GRAPH_OBJECT_SCHEMA_VALIDATION).toBeUndefined(); }); -test('step should fail if enableSchemaValidation = true', async () => { +test('step should warn if enableSchemaValidation = true', async () => { + const consoleSpy = jest.spyOn(console, 'warn'); loadProjectStructure('instanceWithNonValidatingSteps'); const job = generateSynchronizationJob(); @@ -101,26 +102,11 @@ test('step should fail if enableSchemaValidation = true', async () => { expect(log.displaySynchronizationResults).toHaveBeenCalledTimes(1); expect(log.displayExecutionResults).toHaveBeenCalledTimes(1); - expect(log.displayExecutionResults).toHaveBeenCalledWith({ - integrationStepResults: [ - { - id: 'fetch-users', - name: 'Fetch Users', - declaredTypes: ['my_user'], - partialTypes: [], - encounteredTypes: [], - status: StepResultStatus.FAILURE, - }, - ], - metadata: { - partialDatasets: { - types: ['my_user'], - }, - }, - }); + expect(consoleSpy).toHaveBeenCalled(); }); -test('step should pass if enableSchemaValidation = false', async () => { +test('step should pass and not warn if enableSchemaValidation = false', async () => { + const consoleSpy = jest.spyOn(console, 'warn'); loadProjectStructure('instanceWithNonValidatingSteps'); const job = generateSynchronizationJob(); @@ -159,6 +145,7 @@ test('step should pass if enableSchemaValidation = false', async () => { }, }, }); + expect(consoleSpy).not.toHaveBeenCalled(); }); test('executes integration and performs upload', async () => { diff --git a/packages/integration-sdk-cli/src/__tests__/cli.test.ts b/packages/integration-sdk-cli/src/__tests__/cli.test.ts index 1e1a9c796..88faba8a3 100644 --- a/packages/integration-sdk-cli/src/__tests__/cli.test.ts +++ b/packages/integration-sdk-cli/src/__tests__/cli.test.ts @@ -199,30 +199,14 @@ describe('collect', () => { delete process.env.ENABLE_GRAPH_OBJECT_SCHEMA_VALIDATION; }); - test('step should fail if enableSchemaValidation = true', async () => { + test('step should warn if enableSchemaValidation = true', async () => { + const consoleSpy = jest.spyOn(console, 'warn'); await createCli().parseAsync(['node', 'j1-integration', 'collect']); - - expect(log.displayExecutionResults).toHaveBeenCalledTimes(1); - expect(log.displayExecutionResults).toHaveBeenCalledWith({ - integrationStepResults: [ - { - id: 'fetch-users', - name: 'Fetch Users', - declaredTypes: ['my_user'], - partialTypes: [], - encounteredTypes: [], - status: StepResultStatus.FAILURE, - }, - ], - metadata: { - partialDatasets: { - types: ['my_user'], - }, - }, - }); + expect(consoleSpy).toHaveBeenCalled(); }); - test('step should pass if enableSchemaValidation = false', async () => { + test('step should pass and not warn if enableSchemaValidation = false', async () => { + const consoleSpy = jest.spyOn(console, 'warn'); await createCli().parseAsync([ 'node', 'j1-integration', @@ -248,6 +232,7 @@ describe('collect', () => { }, }, }); + expect(consoleSpy).not.toHaveBeenCalled(); }); }); diff --git a/packages/integration-sdk-core/src/data/__tests__/createIntegrationEntity.test.ts b/packages/integration-sdk-core/src/data/__tests__/createIntegrationEntity.test.ts index 8061ea6c2..d8cb3eefd 100644 --- a/packages/integration-sdk-core/src/data/__tests__/createIntegrationEntity.test.ts +++ b/packages/integration-sdk-core/src/data/__tests__/createIntegrationEntity.test.ts @@ -329,7 +329,8 @@ describe('schema validation on', () => { delete process.env.ENABLE_GRAPH_OBJECT_SCHEMA_VALIDATION; }); - test('throws if an a required property is not set', () => { + test('warns if an a required property is not set', () => { + const consoleSpy = jest.spyOn(console, 'warn'); expect(() => createIntegrationEntity({ entityData: { @@ -340,7 +341,8 @@ describe('schema validation on', () => { }, }, }), - ).toThrow(/required property 'name'/); + ).not.toThrow(); + expect(consoleSpy).toHaveBeenCalled(); }); }); @@ -349,7 +351,8 @@ describe('schema validation off', () => { delete process.env.ENABLE_GRAPH_OBJECT_SCHEMA_VALIDATION; }); - test('does not throw if class is not in data model', () => { + test('does not warn if class is not in data model', () => { + const consoleSpy = jest.spyOn(console, 'warn'); expect(() => createIntegrationEntity({ entityData: { @@ -361,5 +364,6 @@ describe('schema validation off', () => { }, }), ).not.toThrow(); + expect(consoleSpy).not.toHaveBeenCalled(); }); }); diff --git a/packages/integration-sdk-core/src/data/createIntegrationEntity.ts b/packages/integration-sdk-core/src/data/createIntegrationEntity.ts index ce0f821e2..fb5418471 100644 --- a/packages/integration-sdk-core/src/data/createIntegrationEntity.ts +++ b/packages/integration-sdk-core/src/data/createIntegrationEntity.ts @@ -103,7 +103,12 @@ export function createIntegrationEntity( validateRawData(generatedEntity); if (process.env.ENABLE_GRAPH_OBJECT_SCHEMA_VALIDATION) { - validateEntityWithSchema(generatedEntity); + try { + validateEntityWithSchema(generatedEntity); + } catch (err) { + /* eslint-disable no-console */ + console.warn(err); + } } return generatedEntity;