Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions apps/api/src/manifest/manifest.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
WebhookParams,
} from '../models';
import { EmailHookFixture, WebHookFixture } from '../../test/fixtures';
import { WebHookResponse } from '../hook/models';
import { Test, TestingModule } from '@nestjs/testing';
import { decrypt, generateHmac, verifyHmac } from '../utils/crypto-helpers';

Expand All @@ -20,6 +19,7 @@ import { HttpService } from '@nestjs/axios';
import { ManifestService } from './manifest.service';
import { MockFactory } from 'mockingbird';
import { TildaManifestFixture } from '../../test/fixtures/manifest/tilda-manifest.fixture';
import { WebHookResponse } from '../hook/models';
import { WebhookProcessor } from '../hook/processors/webhook.processor';
import { faker } from '@faker-js/faker';
import { of } from 'rxjs';
Expand Down Expand Up @@ -618,7 +618,7 @@ describe('ManifestService', () => {

expect(transformedPatternValues).toEqual(expectedValues);
});
it('should generate the correct all key values with inputName', () => {
it('should generate only key values with ui.label', () => {
const manifest = JSON.parse(
JSON.stringify(validManifest),
) as TildaManifest;
Expand All @@ -628,10 +628,9 @@ describe('ManifestService', () => {
surname,
testName: name,
};

delete manifest.data.fields['name'].ui.label;
const expectedOutput = {
[manifest.data.fields['surname'].ui.label]: surname,
[manifest.data.fields['name'].ui.label]: name,
};

const generatedKeyValues = manifestService.getDataWithUiLabels(
Expand Down
25 changes: 13 additions & 12 deletions apps/api/src/manifest/manifest.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ export class ManifestService {
if (hook.factory === HookType.email) {
const emailParams: EmailParams = hook.params as EmailParams;
this.encryptManifestEmailRecipients(emailParams.recipients, secret);
this.encryptSmtpConfigValues((hook.params as EmailParams).config, secret);
this.encryptSmtpConfigValues(
(hook.params as EmailParams).config,
secret,
);
}
});

Expand Down Expand Up @@ -212,7 +215,10 @@ export class ManifestService {
if (hook.factory === HookType.email) {
const emailParams: EmailParams = hook.params as EmailParams;
this.decryptManifestEmailRecipients(emailParams.recipients, secret);
this.decryptSmtpConfigValues((hook.params as EmailParams).config, secret);
this.decryptSmtpConfigValues(
(hook.params as EmailParams).config,
secret,
);
}
});

Expand Down Expand Up @@ -349,17 +355,12 @@ export class ManifestService {
const dataWithUiLabels: DataWithUiLabels = {};
for (const payloadName in payload) {
for (const fieldKey in manifest.data.fields) {
if (manifest.data.fields.hasOwnProperty(fieldKey)) {
if (payloadName == fieldKey) {
dataWithUiLabels[manifest.data.fields[fieldKey].ui.label] =
payload[payloadName];
break;
}
if (manifest.data.fields[fieldKey].inputName == payloadName) {
dataWithUiLabels[manifest.data.fields[fieldKey].ui.label] =
payload[payloadName];
break;
const field = manifest.data.fields[fieldKey];
if (payloadName == fieldKey || field.inputName == payloadName) {
if (field?.ui?.label) {
dataWithUiLabels[field.ui.label] = payload[payloadName];
}
break;
}
}
}
Expand Down