Repository: Accenture/sfmc-devtools (js)

Issue:
[TASK] exclude event from fixKeys*
It breaks journeys because the key is used in decisionsplits and many other places. 
Show warning and require confirmation of somebody tries this with type event specified

Pull request:
Task/1334 exclude event from fixkeys
# PR details

## What changes did you make? (Give an overview)

- closes #1334 

## Further details (optional)

...

## Checklist

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] test scripts updated
- [ ] Wiki updated (if applicable)


Patch:
diff --git a/lib/index.js b/lib/index.js
index e87500ab..12284c28 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -1045,6 +1045,17 @@ class Mcdev {
         for (const selectedType of Array.isArray(selectedTypesArr)
             ? selectedTypesArr
             : Object.keys(selectedTypesArr)) {
+            if (selectedType === 'event') {
+                Util.logger.warn(
+                    `Type 'event' is not supported for fixKeys for compatibility reasons. Draft Journeys would otherwise be broken after the key change. If you do need to update an event key, use deploy --changeKeyValue or --changeKeyField instead.`
+                );
+                if (Array.isArray(selectedTypesArr)) {
+                    selectedTypesArr = selectedTypesArr.filter((type) => type !== 'event');
+                } else {
+                    delete selectedTypesArr.event;
+                }
+                continue;
+            }
             const temp = await this.#runMethod(
                 'fixKeys',
                 businessUnit,


Test patch:
diff --git a/test/type.event.test.js b/test/type.event.test.js
new file mode 100644
index 00000000..11731911
--- /dev/null
+++ b/test/type.event.test.js
@@ -0,0 +1,62 @@
+import * as chai from 'chai';
+const assert = chai.assert;
+// const expect = chai.expect;
+
+import chaiFiles from 'chai-files';
+// import cache from '../lib/util/cache.js';
+import * as testUtils from './utils.js';
+import handler from '../lib/index.js';
+chai.use(chaiFiles);
+// const file = chaiFiles.file;
+
+describe('type: event', () => {
+    beforeEach(() => {
+        testUtils.mockSetup();
+    });
+
+    afterEach(() => {
+        testUtils.mockReset();
+    });
+
+    describe('Retrieve ================', () => {});
+
+    describe('Deploy ================', () => {
+        beforeEach(() => {
+            testUtils.mockSetup(true);
+        });
+    });
+
+    describe('FixKeys ================', () => {
+        beforeEach(() => {
+            testUtils.mockSetup(true);
+        });
+
+        it('Should exit fixKeys because event is not supported intentionally', async () => {
+            // WHEN
+            handler.setOptions({ skipInteraction: { fixKeysReretrieve: false } });
+            const resultFixKeys = await handler.fixKeys('testInstance/testBU', ['event']);
+            // THEN
+            assert.equal(process.exitCode, 0, 'fixKeys should not have thrown an error');
+            // check which keys were fixed
+            assert.equal(
+                resultFixKeys['testInstance/testBU'],
+                undefined,
+                'expected to find no keys to be fixed'
+            );
+
+            // check number of API calls
+            assert.equal(
+                testUtils.getAPIHistoryLength(),
+                0,
+                'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
+            );
+            return;
+        });
+    });
+
+    describe('Templating ================', () => {});
+
+    describe('Delete ================', () => {});
+
+    describe('CI/CD ================', () => {});
+});