@mindful-web/marko-web-omeda-identity-x 1.85.4 → 1.85.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-omeda-identity-x$1.85.4/components/identify.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-omeda-identity-x$1.85.5/components/identify.marko",
6
6
  marko_component = require("./identify.marko"),
7
7
  marko_renderer = require("marko/dist/runtime/components/renderer"),
8
8
  module_getCookieId = require("@mindful-web/marko-web-omeda-identity-x/utils/get-cookie-id"),
@@ -51,7 +51,7 @@ marko_template._ = marko_renderer(render, {
51
51
  }, marko_component);
52
52
 
53
53
  marko_template.meta = {
54
- id: "/@mindful-web/marko-web-omeda-identity-x$1.85.4/components/identify.marko",
54
+ id: "/@mindful-web/marko-web-omeda-identity-x$1.85.5/components/identify.marko",
55
55
  component: "./identify.marko",
56
56
  tags: [
57
57
  "@mindful-web/marko-web-identity-x/components/identify.marko",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindful-web/marko-web-omeda-identity-x",
3
- "version": "1.85.4",
3
+ "version": "1.85.5",
4
4
  "description": "Marko Omeda+IdentityX integration tools",
5
5
  "repository": "https://github.com/parameter1/mindful-web/tree/main/packages/marko-web-omeda-identity-x",
6
6
  "author": "Josh Worden <josh@parameter1.com>",
@@ -10,10 +10,10 @@
10
10
  "lint": "eslint --ext .js --ext .vue --max-warnings 5 ./",
11
11
  "compile": "mindful-web-marko-compile compile",
12
12
  "prepublish": "yarn compile --silent",
13
- "test": "yarn compile --no-clean && yarn lint"
13
+ "test": "yarn compile --no-clean && yarn lint && mocha --reporter spec"
14
14
  },
15
15
  "dependencies": {
16
- "@mindful-web/marko-web-identity-x": "^1.85.4",
16
+ "@mindful-web/marko-web-identity-x": "^1.85.5",
17
17
  "@mindful-web/marko-web-omeda": "^1.85.0",
18
18
  "@mindful-web/object-path": "^1.83.1",
19
19
  "@mindful-web/utils": "^1.83.1",
@@ -29,5 +29,9 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "gitHead": "e793692becf12f650680a93a12f36f227aaace30"
32
+ "devDependencies": {
33
+ "chai": "^4.3.7",
34
+ "mocha": "^6.2.3"
35
+ },
36
+ "gitHead": "26553d897cb2c39e798031e4e2727a81123b1402"
33
37
  }
@@ -0,0 +1,2 @@
1
+ --recursive
2
+ --timeout 2000
@@ -0,0 +1,82 @@
1
+ const { describe, it } = require('mocha');
2
+ const { expect } = require('chai');
3
+ const idxOmedaRapidIdentify = require('../rapid-identify');
4
+
5
+ const BRAND = 'athlcd';
6
+
7
+ const productBooleanAnswer = ({ id = 'chan-1', productId = 28, answer = false } = {}) => ({
8
+ id,
9
+ hasAnswered: true,
10
+ answer,
11
+ value: answer,
12
+ field: {
13
+ id,
14
+ label: 'Athletic Business (magazine)',
15
+ active: true,
16
+ externalId: {
17
+ id: `omeda.product.${BRAND}*${productId}`,
18
+ namespace: { provider: 'omeda', tenant: BRAND, type: 'product' },
19
+ identifier: { value: `${productId}`, type: null },
20
+ },
21
+ },
22
+ });
23
+
24
+ const deploymentBooleanAnswer = ({ id = 'chan-2', deploymentTypeId = 17, answer = false } = {}) => ({
25
+ id,
26
+ hasAnswered: true,
27
+ answer,
28
+ value: answer,
29
+ field: {
30
+ id,
31
+ label: 'AB Today',
32
+ active: true,
33
+ externalId: {
34
+ id: `omeda.deploymentType.${BRAND}*${deploymentTypeId}`,
35
+ namespace: { provider: 'omeda', tenant: BRAND, type: 'deploymentType' },
36
+ identifier: { value: `${deploymentTypeId}`, type: null },
37
+ },
38
+ },
39
+ });
40
+
41
+ const run = async (appUser) => {
42
+ let captured;
43
+ await idxOmedaRapidIdentify({
44
+ brandKey: BRAND,
45
+ productId: 41,
46
+ appUser: { email: 'someone@example.com', ...appUser },
47
+ identityX: { addExternalUserId: async () => ({}) },
48
+ omedaRapidIdentify: async (payload) => { captured = payload; return { id: 1, encryptedCustomerId: 'x' }; },
49
+ });
50
+ return captured;
51
+ };
52
+
53
+ describe('rapid-identify (idx → omeda payload)', () => {
54
+ it('maps product-linked boolean answers into subscriptions — including receive: false', async () => {
55
+ // Documents the hazard: any boolean answer on the passed user becomes a provider write.
56
+ // Callers whose forms did not collect booleans must strip customBooleanFieldAnswers.
57
+ const payload = await run({
58
+ customBooleanFieldAnswers: [
59
+ productBooleanAnswer({ answer: false }),
60
+ deploymentBooleanAnswer({ answer: false }),
61
+ ],
62
+ });
63
+ expect(payload.subscriptions).to.deep.equal([{ id: 28, receive: false }]);
64
+ expect(payload.deploymentTypes).to.deep.equal([{ id: 17, optedIn: false }]);
65
+ });
66
+
67
+ it('emits NO subscriptions or deploymentTypes when boolean answers are empty', async () => {
68
+ const payload = await run({ customBooleanFieldAnswers: [] });
69
+ expect(payload).to.not.have.property('subscriptions');
70
+ expect(payload).to.not.have.property('deploymentTypes');
71
+ });
72
+
73
+ it('ignores unanswered and inactive boolean fields', async () => {
74
+ const unanswered = productBooleanAnswer({});
75
+ unanswered.hasAnswered = false;
76
+ const inactive = deploymentBooleanAnswer({});
77
+ inactive.field.active = false;
78
+ const payload = await run({ customBooleanFieldAnswers: [unanswered, inactive] });
79
+ expect(payload).to.not.have.property('subscriptions');
80
+ expect(payload).to.not.have.property('deploymentTypes');
81
+ });
82
+ });