mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 03:12:15 +00:00
refactor: Overhaul nodes-testing setup - Part 3 (no-changelog) (#14967)
This commit is contained in:
committed by
GitHub
parent
3e43f9f8bc
commit
979f9e6327
@@ -1,8 +1,6 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import type { WorkflowTestData } from 'n8n-workflow';
|
||||
|
||||
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow';
|
||||
import * as Helpers from '@test/nodes/Helpers';
|
||||
|
||||
jest.mock('otpauth', () => {
|
||||
return {
|
||||
TOTP: jest.fn().mockImplementation(() => {
|
||||
@@ -14,15 +12,17 @@ jest.mock('otpauth', () => {
|
||||
});
|
||||
|
||||
describe('Execute TOTP node', () => {
|
||||
const testHarness = new NodeTestHarness();
|
||||
const tests: WorkflowTestData[] = [
|
||||
{
|
||||
description: 'Generate TOTP Token',
|
||||
input: {
|
||||
workflowData: Helpers.readJsonFileSync('nodes/Totp/test/Totp.workflow.test.json'),
|
||||
workflowData: testHarness.readWorkflowJSON('Totp.workflow.test.json'),
|
||||
},
|
||||
output: {
|
||||
nodeData: {
|
||||
TOTP: [[{ json: { token: '123456' } }]], // ignore secondsRemaining to prevent flakiness
|
||||
// ignore json.secondsRemaining to prevent flakiness
|
||||
TOTP: [[{ json: expect.objectContaining({ token: '123456' }) }]],
|
||||
},
|
||||
},
|
||||
credentials: {
|
||||
@@ -35,18 +35,6 @@ describe('Execute TOTP node', () => {
|
||||
];
|
||||
|
||||
for (const testData of tests) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
||||
test(testData.description, async () => {
|
||||
const { result } = await executeWorkflow(testData);
|
||||
|
||||
Helpers.getResultNodeData(result, testData).forEach(({ nodeName, resultData }) => {
|
||||
const expected = testData.output.nodeData[nodeName][0][0].json;
|
||||
const actual = resultData[0]?.[0].json;
|
||||
|
||||
expect(actual?.token).toEqual(expected.token);
|
||||
});
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
});
|
||||
testHarness.setupTest(testData);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user