refactor: Use string ids on Credentials, Workflows, Tags, and Executions DB entities (#5041)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-01-02 17:42:32 +01:00
committed by GitHub
parent 8bee04cd2a
commit ee28213538
83 changed files with 468 additions and 645 deletions

View File

@@ -22,13 +22,13 @@ jest.mock('@/Db', () => {
collections: {
Workflow: {
update: jest.fn(({ id, dataLoaded }, updateArgs) => {
if (id === 1) return { affected: 1 };
if (id === '1') return { affected: 1 };
return { affected: 0 };
}),
},
WorkflowStatistics: {
insert: jest.fn(({ count, name, workflowId }) => {
if (workflowId === -1) throw new Error('test error');
if (workflowId === '-1') throw new Error('test error');
return null;
}),
update: jest.fn((...args) => {}),
@@ -104,7 +104,7 @@ describe('Events', () => {
expect(mockedFirstProductionWorkflowSuccess).toBeCalledTimes(1);
expect(mockedFirstProductionWorkflowSuccess).toHaveBeenNthCalledWith(1, {
user_id: FAKE_USER_ID,
workflow_id: parseInt(workflow.id, 10),
workflow_id: workflow.id,
});
});
@@ -180,7 +180,7 @@ describe('Events', () => {
expect(mockedFirstWorkflowDataLoad).toBeCalledTimes(1);
expect(mockedFirstWorkflowDataLoad).toHaveBeenNthCalledWith(1, {
user_id: FAKE_USER_ID,
workflow_id: parseInt(workflowId, 10),
workflow_id: workflowId,
node_type: node.type,
node_id: node.id,
});
@@ -207,7 +207,7 @@ describe('Events', () => {
expect(mockedFirstWorkflowDataLoad).toBeCalledTimes(1);
expect(mockedFirstWorkflowDataLoad).toHaveBeenNthCalledWith(1, {
user_id: FAKE_USER_ID,
workflow_id: parseInt(workflowId, 10),
workflow_id: workflowId,
node_type: node.type,
node_id: node.id,
credential_type: 'testCredentials',

View File

@@ -129,7 +129,7 @@ describe('PermissionChecker.check()', () => {
position: [0, 0],
credentials: {
actionNetworkApi: {
id: ownerCred.id.toString(),
id: ownerCred.id,
name: ownerCred.name,
},
},
@@ -143,7 +143,7 @@ describe('PermissionChecker.check()', () => {
position: [0, 0],
credentials: {
actionNetworkApi: {
id: memberCred.id.toString(),
id: memberCred.id,
name: memberCred.name,
},
},
@@ -160,7 +160,7 @@ describe('PermissionChecker.check()', () => {
const memberCred = await saveCredential(randomCred(), { user: member });
const workflowDetails = {
id: randomPositiveDigit(),
id: randomPositiveDigit().toString(),
name: 'test',
active: false,
connections: {},
@@ -175,7 +175,7 @@ describe('PermissionChecker.check()', () => {
position: [0, 0] as [number, number],
credentials: {
actionNetworkApi: {
id: memberCred.id.toString(),
id: memberCred.id,
name: memberCred.name,
},
},
@@ -205,7 +205,7 @@ describe('PermissionChecker.check()', () => {
role: workflowOwnerRole,
});
const workflow = new Workflow({ ...workflowDetails, id: workflowDetails.id.toString() });
const workflow = new Workflow(workflowDetails);
expect(PermissionChecker.check(workflow, member.id)).rejects.toThrow();
});

View File

@@ -8,7 +8,7 @@ async function mockFind({
id,
type,
}: {
id: string | number;
id: string;
type: string;
}): Promise<IWorkflowCredentials | null> {
// Simple statement that maps a return value based on the `id` parameter

View File

@@ -148,7 +148,7 @@ describe('WorkflowHelpers', () => {
function generateCredentialEntity(credentialId: string) {
const credentialEntity = new CredentialsEntity();
credentialEntity.id = parseInt(credentialId, 10);
credentialEntity.id = credentialId;
return credentialEntity;
}