Skip to content

Commit

Permalink
fix: inconsisted definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumarrs committed Feb 23, 2024
1 parent 03eef2e commit 06a72a7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 27 deletions.
2 changes: 0 additions & 2 deletions src/configurations/destinations/fb/db-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"supportedConnectionModes": {
"android": ["cloud", "device"],
"ios": ["cloud", "device"],
"web": ["cloud"],
"unity": ["cloud"],
"amp": ["cloud"],
"reactnative": ["cloud"],
Expand All @@ -63,7 +62,6 @@
"ketchConsentPurposes"
],
"ios": ["useNativeSDK", "connectionMode", "oneTrustCookieCategories", "ketchConsentPurposes"],
"web": ["oneTrustCookieCategories"],
"unity": ["oneTrustCookieCategories", "ketchConsentPurposes"],
"reactnative": ["oneTrustCookieCategories", "ketchConsentPurposes"],
"flutter": ["oneTrustCookieCategories", "ketchConsentPurposes"],
Expand Down
6 changes: 2 additions & 4 deletions src/configurations/destinations/pipedrive/db-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"flutter": ["cloud"],
"cordova": ["cloud"],
"shopify": ["cloud"],
"cloud": ["cloud"],
"warehouse": ["cloud"]
"cloud": ["cloud"]
},
"destConfig": {
"defaultConfig": [
Expand All @@ -50,8 +49,7 @@
"flutter": ["connectionMode", "oneTrustCookieCategories", "ketchConsentPurposes"],
"cordova": ["connectionMode", "oneTrustCookieCategories", "ketchConsentPurposes"],
"shopify": ["connectionMode", "oneTrustCookieCategories", "ketchConsentPurposes"],
"cloud": ["connectionMode", "oneTrustCookieCategories", "ketchConsentPurposes"],
"warehouse": ["connectionMode"]
"cloud": ["connectionMode", "oneTrustCookieCategories", "ketchConsentPurposes"]
},
"secretKeys": ["apiToken"]
},
Expand Down
4 changes: 0 additions & 4 deletions src/configurations/destinations/singular/db-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
"ios": ["cloud", "device"],
"reactnative": ["cloud", "device"],
"cordova": ["cloud", "device"],
"web": ["cloud"],
"unity": ["cloud"],
"amp": ["cloud"],
"flutter": ["cloud"],
"shopify": ["cloud"]
Expand All @@ -59,8 +57,6 @@
"ios": ["useNativeSDK", "oneTrustCookieCategories", "ketchConsentPurposes"],
"reactnative": ["useNativeSDK", "oneTrustCookieCategories", "ketchConsentPurposes"],
"cordova": ["useNativeSDK", "oneTrustCookieCategories", "ketchConsentPurposes"],
"web": ["oneTrustCookieCategories"],
"unity": ["oneTrustCookieCategories"],
"flutter": ["oneTrustCookieCategories", "ketchConsentPurposes"],
"amp": ["oneTrustCookieCategories", "ketchConsentPurposes"],
"cloud": ["oneTrustCookieCategories", "ketchConsentPurposes"],
Expand Down
38 changes: 21 additions & 17 deletions test/consentManagementFieldsIntegrity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,23 @@ const getJSONDataFromFile = (filePath: string) => {
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
} catch (e) {
console.error(e);
console.error(`Unable to load test data for: "${filePath}"`);
console.error(`Unable to load file: "${filePath}"`);
return null;
}
};

const deepSearch = (obj: any, value: string) => {
const deepSearch = (obj: any, value: string, count = 0) => {
// eslint-disable-next-line no-restricted-syntax, guard-for-in
for (const k in obj) {
if (typeof obj[k] === 'object') {
const result = deepSearch(obj[k], value);
if (result) {
return result;
}
// eslint-disable-next-line no-param-reassign
count = deepSearch(obj[k], value, count);
} else if (obj[k] === value) {
return obj;
// eslint-disable-next-line no-param-reassign
count += 1;
}
}
return null;
return count;
};

describe('Consent Management Fields Integrity tests', () => {
Expand Down Expand Up @@ -67,6 +66,11 @@ describe('Consent Management Fields Integrity tests', () => {
});

expect(fail).toBe(false);

// Remove defaultConfig from the list of source types
const destConfigSrcTypes = Object.keys(destConfig);
destConfigSrcTypes.splice(destConfigSrcTypes.indexOf('defaultConfig'), 1);
expect(destConfigSrcTypes.sort()).toEqual(supportedSourceTypes.sort());
});

// Validate schema.json
Expand All @@ -84,23 +88,23 @@ describe('Consent Management Fields Integrity tests', () => {
expect(schema.configSchema.properties.ketchConsentPurposes.properties).toBeDefined();

expect(
Object.keys(schema.configSchema.properties.oneTrustCookieCategories.properties),
).toEqual(supportedSourceTypes);
expect(Object.keys(schema.configSchema.properties.ketchConsentPurposes.properties)).toEqual(
supportedSourceTypes,
);
Object.keys(schema.configSchema.properties.oneTrustCookieCategories.properties).sort(),
).toEqual(supportedSourceTypes.sort());
expect(
Object.keys(schema.configSchema.properties.ketchConsentPurposes.properties).sort(),
).toEqual(supportedSourceTypes.sort());
});

// Validate ui-config.json
const uiConfigFilePath = path.resolve(`${destDir}/${destName}/ui-config.json`);
const uiConfig = getJSONDataFromFile(uiConfigFilePath);

it(`should have oneTrustCookieCategories and ketchConsentPurposes properly defined in ui-config.json in ${destName}`, () => {
const oneTrustUIElement = deepSearch(uiConfig, 'oneTrustCookieCategories');
expect(oneTrustUIElement).toBeDefined();
const oneTrustUIElementCount = deepSearch(uiConfig, 'oneTrustCookieCategories');
expect(oneTrustUIElementCount).toEqual(1);

const ketchUIElement = deepSearch(uiConfig, 'ketchConsentPurposes');
expect(ketchUIElement).toBeDefined();
const ketchUIElementCount = deepSearch(uiConfig, 'ketchConsentPurposes');
expect(ketchUIElementCount).toEqual(1);
});
});
});

0 comments on commit 06a72a7

Please sign in to comment.