@adobe/exc-app 0.2.45 → 1.0.0

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.
Files changed (98) hide show
  1. package/RuntimeConfiguration.d.ts +4 -0
  2. package/appapi.d.ts +0 -1
  3. package/appapi.js +0 -1
  4. package/appapi.js.map +1 -1
  5. package/build/preBuild.js +14 -0
  6. package/capabilityapi.d.ts +2 -2
  7. package/capabilityapi.js +2 -2
  8. package/capabilityapi.js.map +1 -1
  9. package/docs/README.md +1 -0
  10. package/docs/enums/appapi.appids.md +14 -7
  11. package/docs/enums/capabilityapi.capabilityids.md +21 -0
  12. package/docs/enums/capabilityapi.capabilitynames.md +21 -0
  13. package/docs/interfaces/ims.activeproductcontext.md +13 -0
  14. package/docs/interfaces/ims.imsprofile.md +130 -0
  15. package/docs/interfaces/ims.productcontext.md +141 -0
  16. package/docs/interfaces/ims.projectedproductcontext.md +21 -0
  17. package/docs/interfaces/network.queryrequest.md +11 -0
  18. package/docs/interfaces/root.poller.md +56 -0
  19. package/docs/interfaces/root.pollerhandle.md +21 -0
  20. package/docs/interfaces/root.pollingconfiguration.md +28 -0
  21. package/docs/interfaces/root.runtimeconfiguration.md +10 -1
  22. package/docs/interfaces/root.useractivityemitter.md +110 -0
  23. package/docs/interfaces/root.useractivitymonitor.md +151 -0
  24. package/docs/interfaces/user.userapi.md +1 -1
  25. package/docs/modules/ims.md +14 -0
  26. package/docs/modules/root.md +5 -0
  27. package/docs/modules/settings.md +8 -57
  28. package/docs/modules/user.md +14 -0
  29. package/index.js +7 -0
  30. package/index.js.map +1 -1
  31. package/internal.d.ts +9 -0
  32. package/internal.js +3 -0
  33. package/internal.js.map +1 -1
  34. package/network.d.ts +0 -11
  35. package/network.js +1 -10
  36. package/network.js.map +1 -1
  37. package/package.json +5 -6
  38. package/src/Global.d.ts +3 -1
  39. package/src/Global.js.map +1 -1
  40. package/tests/index.test.js +5 -0
  41. package/tests/index.test.js.map +1 -1
  42. package/tests/version.test.d.ts +1 -0
  43. package/tests/version.test.js +23 -0
  44. package/tests/version.test.js.map +1 -0
  45. package/user.d.ts +10 -1
  46. package/user.js.map +1 -1
  47. package/{settings/SettingsLevel.ts → version.d.ts} +2 -20
  48. package/{metrics/Level.ts → version.js} +6 -20
  49. package/version.js.map +1 -0
  50. package/RuntimeConfiguration.ts +0 -272
  51. package/appapi.ts +0 -140
  52. package/capabilityapi.ts +0 -162
  53. package/helpcenter.ts +0 -253
  54. package/ims/ImsProfile.ts +0 -57
  55. package/index.ts +0 -76
  56. package/internal.ts +0 -102
  57. package/metrics/Analytics.ts +0 -55
  58. package/metrics/Application.ts +0 -24
  59. package/metrics/Configuration.ts +0 -33
  60. package/metrics/Events.ts +0 -28
  61. package/metrics/History.ts +0 -36
  62. package/metrics/Metric.ts +0 -52
  63. package/metrics/Metrics.ts +0 -129
  64. package/metrics/RecordType.ts +0 -139
  65. package/metrics/User.ts +0 -30
  66. package/metrics.ts +0 -94
  67. package/network.ts +0 -568
  68. package/nps.ts +0 -83
  69. package/orgswitcher.ts +0 -109
  70. package/page.ts +0 -497
  71. package/permissions.ts +0 -103
  72. package/pulse.ts +0 -198
  73. package/session.ts +0 -116
  74. package/settings.ts +0 -147
  75. package/shell.ts +0 -107
  76. package/sidebar.ts +0 -208
  77. package/sidenav.ts +0 -287
  78. package/src/EventEmitter.ts +0 -44
  79. package/src/Global.ts +0 -109
  80. package/src/Runtime.ts +0 -23
  81. package/tests/MockRuntime.ts +0 -28
  82. package/tests/appapi.test.ts +0 -78
  83. package/tests/capabilityapi.test.ts +0 -55
  84. package/tests/helpCenter.test.ts +0 -80
  85. package/tests/index.test.ts +0 -50
  86. package/tests/metrics.test.ts +0 -34
  87. package/tests/nps.test.ts +0 -37
  88. package/tests/page.test.ts +0 -110
  89. package/tests/permissions.test.ts +0 -96
  90. package/tests/pulse.test.ts +0 -37
  91. package/tests/shell.test.ts +0 -89
  92. package/tests/sidenav.test.ts +0 -91
  93. package/tests/topbar.test.ts +0 -85
  94. package/tests/user.test.ts +0 -129
  95. package/tests/userprofile.test.ts +0 -31
  96. package/topbar.ts +0 -288
  97. package/user.ts +0 -228
  98. package/userprofile.ts +0 -93
@@ -1,78 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
- import appapi, {AppIds} from '../appapi';
12
- import Global, {Modules} from '../src/Global';
13
-
14
- describe('appapi', () => {
15
- beforeEach(() => {
16
- (Global['exc-module-runtime'] as Modules) = {
17
- appApi: () => {
18
- return {
19
- get: (type) => {
20
- if (type === 'analytics') {
21
- return {
22
- adobeBrandType: 'application',
23
- appId: 'analytics',
24
- description: 'Collect, organize, analyze and report on everything your customers do',
25
- enabled: false,
26
- functionalIconReact: 'DataAnalytics',
27
- functionalIconUrl: 'https://exc-unifiedcontent.experience-stage.adobe.net/assets/BrandIcons.33cbb3cf.svg#DataAnalytics',
28
- href: 'https://app-discovery-qe.corp.ethos11-stage-or1.ethos.adobe.net/1.0/loginRedirect?allow_project_redirect=1&IMS=1',
29
- icon: 'adobeAnalytics',
30
- iconReact: 'AdobeAnalytics',
31
- iconUrl: '',
32
- learnMoreLink: 'http://www.adobe.com/marketing-cloud/web-analytics.html',
33
- longName: 'Adobe Analytics',
34
- name: 'Analytics',
35
- settingsAppId: 'analytics',
36
- visible: false
37
- };
38
- }
39
- if (type === 'target') {
40
- return {
41
- adobeBrandType: 'application',
42
- appId: 'target',
43
- description: 'Use experimentation, testing and machine learning automation to deliver the best content to each visitor',
44
- enabled: false,
45
- functionalIconReact: 'ContentProfile',
46
- functionalIconUrl: 'https://exc-unifiedcontent.experience-stage.adobe.net/assets/BrandIcons.33cbb3cf.svg#ContentProfile',
47
- href: 'https://experience-stage.adobe.com/#/target',
48
- icon: 'adobeTarget',
49
- iconReact: 'AdobeTarget',
50
- iconUrl: '',
51
- learnMoreLink: 'https://www.adobe.com/marketing/target.html',
52
- longName: 'Adobe Target',
53
- name: 'Target',
54
- settingsAppId: '',
55
- visible: false
56
- };
57
- }
58
- return {};
59
- }
60
- };
61
- }
62
- } as Modules;
63
- });
64
-
65
- test('get', async () => {
66
- const analytics = await appapi.get(AppIds.ANALYTICS);
67
- const target = await appapi.get(AppIds.TARGET);
68
- expect(analytics.appId).toBe('analytics');
69
- expect(analytics.enabled).toBe(false);
70
- expect(analytics.functionalIconUrl).toBe('https://exc-unifiedcontent.experience-stage.adobe.net/assets/BrandIcons.33cbb3cf.svg#DataAnalytics');
71
- expect(analytics.href).toBe('https://app-discovery-qe.corp.ethos11-stage-or1.ethos.adobe.net/1.0/loginRedirect?allow_project_redirect=1&IMS=1');
72
-
73
- expect(target.appId).toBe('target');
74
- expect(target.enabled).toBe(false);
75
- expect(target.functionalIconUrl).toBe('https://exc-unifiedcontent.experience-stage.adobe.net/assets/BrandIcons.33cbb3cf.svg#ContentProfile');
76
- expect(target.href).toBe('https://experience-stage.adobe.com/#/target');
77
- });
78
- });
@@ -1,55 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
- import capabilityapi, {CapabilityIds, CapabilityNames} from '../capabilityapi';
12
- import Global, {Modules} from '../src/Global';
13
-
14
- describe('capabilityapi', () => {
15
- beforeEach(() => {
16
- (Global['exc-module-runtime'] as Modules) = {
17
- capabilityApi: () => {
18
- return {
19
- get: (type) => {
20
- if (type === 'home' || type === 'Home') {
21
- return {
22
- capabilityId: 'home',
23
- iconUrl: 'https://exc-unifiedcontent.experience-stage.adobe.net/assets/CapabilityIcons.33cbb3cf.svg#Home'
24
- };
25
- }
26
- if (type === 'assets' || type === 'Assets') {
27
- return {
28
- capabilityId: 'assets',
29
- iconUrl: 'https://exc-unifiedcontent.experience-stage.adobe.net/assets/CapabilityIcons.33cbb3cf.svg#Assets'
30
- };
31
- }
32
- return {};
33
- }
34
- };
35
- }
36
- } as Modules;
37
- });
38
-
39
- test('get', async () => {
40
- const homeById = await capabilityapi.get(CapabilityIds.HOME);
41
- const homeByName = await capabilityapi.get(CapabilityNames.HOME);
42
- const assetsById = await capabilityapi.get(CapabilityIds.ASSETS);
43
- const assetsByName = await capabilityapi.get(CapabilityNames.ASSETS);
44
-
45
- expect(homeById.capabilityId).toBe('home');
46
- expect(homeByName.capabilityId).toBe('home');
47
- expect(homeById.iconUrl).toBe('https://exc-unifiedcontent.experience-stage.adobe.net/assets/CapabilityIcons.33cbb3cf.svg#Home');
48
- expect(homeByName.iconUrl).toBe('https://exc-unifiedcontent.experience-stage.adobe.net/assets/CapabilityIcons.33cbb3cf.svg#Home');
49
-
50
- expect(assetsById.capabilityId).toBe('assets');
51
- expect(assetsByName.capabilityId).toBe('assets');
52
- expect(assetsById.iconUrl).toBe('https://exc-unifiedcontent.experience-stage.adobe.net/assets/CapabilityIcons.33cbb3cf.svg#Assets');
53
- expect(assetsByName.iconUrl).toBe('https://exc-unifiedcontent.experience-stage.adobe.net/assets/CapabilityIcons.33cbb3cf.svg#Assets');
54
- });
55
- });
@@ -1,80 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
- import Global, {Modules} from '../src/Global';
12
- import helpCenter, {HelpCenterButtonConfig} from '../helpcenter';
13
-
14
- describe('helpCenter/index.js', () => {
15
- const helpCenterConfig = {
16
- featured: [{
17
- href: 'https://feature.com',
18
- label: 'Adobe Experience Cloud Learn & Support',
19
- path: '/feature'
20
- }],
21
- questions: [
22
- 'Question 1?',
23
- 'Question 2?'
24
- ],
25
- recommendations: {
26
- enabled: true,
27
- terms: [{
28
- path: '/terms',
29
- term: 'get started'
30
- }]
31
- },
32
- resources: [{
33
- href: 'https://marketing.adobe.com/resources/help/en_US/home/index.html',
34
- label: 'Help Home'
35
- }]
36
- };
37
-
38
- beforeEach(() => {
39
- (Global['exc-module-runtime'] as Modules) = {
40
- helpCenter: {
41
- config: helpCenterConfig,
42
- open: (config) => {
43
- console.log(config); // eslint-disable-line no-console
44
- },
45
- setButton: (config: HelpCenterButtonConfig | HelpCenterButtonConfig[] | null) => {
46
- console.log(config); // eslint-disable-line no-console
47
- },
48
- setButtons: (buttons: HelpCenterButtonConfig[] | null) => {
49
- console.log(buttons); // eslint-disable-line no-console
50
- }
51
- }
52
- } as Modules;
53
- });
54
-
55
- it('correctly sets up the connection with module-runtime', () => {
56
- const setButton = jest.spyOn(Global['exc-module-runtime'].helpCenter, 'setButton');
57
- const callbackFn = jest.fn();
58
- helpCenter.setButton({callback: callbackFn, label: 'myButton'});
59
- expect(setButton).toBeCalledTimes(1);
60
-
61
- const setButtons = jest.spyOn(Global['exc-module-runtime'].helpCenter, 'setButtons');
62
- helpCenter.setButtons([{callback: callbackFn, id: '1', label: 'myButton'}]);
63
- expect(setButtons).toBeCalledTimes(1);
64
-
65
- expect(helpCenter.config).toBe(helpCenterConfig);
66
- const newConfig = Object.assign(helpCenterConfig, {resources: [{href: 'https://newlink.com', label: 'NewLink'}]});
67
- helpCenter.config = newConfig;
68
- expect(Global['exc-module-runtime'].helpCenter.config).toBe(newConfig);
69
-
70
- const openSpy = jest.spyOn(Global['exc-module-runtime'].helpCenter, 'open');
71
- helpCenter.open({
72
- config: {
73
- subject: 'Subject',
74
- type: 'CONTEXTUAL_FEEDBACK_SUBMISSION'
75
- },
76
- selectedTab: 'feedback'
77
- });
78
- expect(openSpy).toBeCalledTimes(1);
79
- });
80
- });
@@ -1,50 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
- import Global, {getImpl, Modules} from '../src/Global';
12
- import runtime, {init, Runtime} from '../index';
13
-
14
- describe('index.js', () => {
15
- it('throws error if module-runtime not available on page', () => {
16
- (Global['exc-module-runtime'] as any) = null;
17
- expect(getImpl).toThrow('module-runtime APIs not available.');
18
- });
19
-
20
- it('configures bootstrap function if module-runtime not ready', () => {
21
- (Global['exc-module-runtime'] as any) = null;
22
- const bootstrap = () => { };
23
- expect(Global.EXC_MR_READY).not.toBeDefined();
24
- init(bootstrap);
25
- expect(Global.EXC_MR_READY).toBeDefined();
26
- });
27
-
28
- it('executes bootstrap function if module-runtime ready', () => {
29
- const runtime = {};
30
- (Global['exc-module-runtime'] as Modules) = {
31
- default: () => runtime
32
- } as Modules;
33
- const data = {
34
- bootstrap: () => { }
35
- };
36
- const spy = jest.spyOn(data, 'bootstrap');
37
- init(data.bootstrap);
38
- expect(spy).toBeCalledTimes(1);
39
- expect(spy).toBeCalledWith(runtime);
40
- });
41
-
42
- it('allows access to runtime object', () => {
43
- const expectedRuntime = {} as Runtime;
44
- (Global['exc-module-runtime'] as Modules) = {
45
- default: () => expectedRuntime
46
- } as Modules;
47
- expect(runtime()).toBe(expectedRuntime);
48
-
49
- });
50
- });
@@ -1,34 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
- import Global, {Modules} from '../src/Global';
12
- import metrics, {Metrics} from '../metrics';
13
-
14
- describe('metrics/index.js', () => {
15
- const expectedInstance = {} as Metrics;
16
- beforeEach(() => {
17
- (Global['exc-module-runtime'] as Modules) = {
18
- metrics: {
19
- create: name => {
20
- console.log(name); // eslint-disable-line no-console
21
- return expectedInstance;
22
- }
23
- }
24
- } as Modules;
25
- });
26
-
27
- it('correctly sets up the connection with module-runtime', () => {
28
- const createSpy = jest.spyOn(Global['exc-module-runtime'].metrics, 'create');
29
- const actualInstance = metrics.create('component_name');
30
- expect(createSpy).toBeCalledTimes(1);
31
- expect(createSpy).toBeCalledWith('component_name');
32
- expect(actualInstance).toBe(expectedInstance);
33
- });
34
- });
package/tests/nps.test.ts DELETED
@@ -1,37 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
- import Global, {Modules} from '../src/Global';
12
- import nps from '../nps';
13
-
14
- describe('nps/index.js', () => {
15
- beforeEach(() => {
16
- (Global['exc-module-runtime'] as Modules) = {
17
- nps: {
18
- config: {
19
- enabled: true,
20
- sampling: 100,
21
- showToAdobeUsers: true
22
- },
23
- triggerNps: () => {}
24
- }
25
- } as Modules;
26
- });
27
- it('correctly sets up the connection with module-runtime for triggerNps function', () => {
28
- const triggerNpsSpy = jest.spyOn(Global['exc-module-runtime'].nps, 'triggerNps');
29
- nps.triggerNps();
30
- expect(triggerNpsSpy).toBeCalledTimes(1);
31
- });
32
-
33
- it('correctly sets up the connection with module-runtime for config object', () => {
34
- nps.config = {enabled: true, sampling: 55};
35
- expect(Global['exc-module-runtime'].nps.config).toStrictEqual({enabled: true, sampling: 55});
36
- });
37
- });
@@ -1,110 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
- import Global, {Modules} from '../src/Global';
12
- import page from '../page';
13
-
14
- describe('page/index.js', () => {
15
- beforeEach(() => {
16
- (Global['exc-module-runtime'] as Modules) = {
17
- page: {
18
- appContainer: 'testContainer',
19
- blockNavigation: (enabled, options) => {
20
- console.log(enabled, options); // eslint-disable-line no-console
21
- },
22
- done: () => {},
23
- favicon: 'test.ico',
24
- generateShellUrl: (location, newApp) => {
25
- console.log(location, newApp); // eslint-disable-line no-console
26
- },
27
- iframeReload: () => {},
28
- modal: true,
29
- notFound: () => {},
30
- preventDefaultCombos: [{ctrlKey: true, key: 'A'}],
31
- shellRedirect: (path, options) => {
32
- console.log(path, options); // eslint-disable-line no-console
33
- },
34
- spinner: true,
35
- title: 'test title',
36
- unloadPromptMessage: 'Are you sure?'
37
- }
38
- } as Modules;
39
- });
40
-
41
- it('correctly sets up the connection with module-runtime', () => {
42
- const doneSpy = jest.spyOn(Global['exc-module-runtime'].page, 'done');
43
- page.done();
44
- expect(doneSpy).toBeCalledTimes(1);
45
-
46
- expect(page.appContainer).toBe('testContainer');
47
- page.appContainer = 'testingContainer';
48
- expect(Global['exc-module-runtime'].page.appContainer).toBe('testingContainer');
49
-
50
- const notFoundSpy = jest.spyOn(Global['exc-module-runtime'].page, 'notFound');
51
- page.notFound();
52
- expect(notFoundSpy).toBeCalledTimes(1);
53
-
54
- expect(page.favicon).toBe('test.ico');
55
- page.favicon = 'updated.ico';
56
- expect(Global['exc-module-runtime'].page.favicon).toBe('updated.ico');
57
-
58
- const iframeReloadSpy = jest.spyOn(Global['exc-module-runtime'].page, 'iframeReload');
59
- page.iframeReload();
60
- expect(iframeReloadSpy).toBeCalledTimes(1);
61
- expect(iframeReloadSpy).toBeCalledWith();
62
- page.iframeReload(false);
63
- expect(iframeReloadSpy).toBeCalledTimes(2);
64
- expect(iframeReloadSpy).toBeCalledWith(false);
65
-
66
- const generateShellUrlSpy = jest.spyOn(Global['exc-module-runtime'].page, 'generateShellUrl');
67
- page.generateShellUrl({path: '/path'}, false);
68
- expect(generateShellUrlSpy).toBeCalledTimes(1);
69
- expect(generateShellUrlSpy).toBeCalledWith({path: '/path'}, false);
70
- page.generateShellUrl({path: '/path', sandbox: 'sbox'}, false);
71
- expect(generateShellUrlSpy).toBeCalledWith({path: '/path', sandbox: 'sbox'}, false);
72
-
73
- expect(page.modal).toBe(true);
74
- page.modal = false;
75
- expect(Global['exc-module-runtime'].page.modal).toBe(false);
76
-
77
- expect(page.preventDefaultCombos.length).toBe(1);
78
- expect(page.preventDefaultCombos[0].key).toBe('A');
79
- page.preventDefaultCombos = [{ctrlKey: true, key: 'A'}, {altKey: false, key: 'B'}];
80
- expect(Global['exc-module-runtime'].page.preventDefaultCombos.length).toBe(2);
81
- expect(page.preventDefaultCombos[1].key).toBe('B');
82
-
83
- const shellRedirectSpy = jest.spyOn(Global['exc-module-runtime'].page, 'shellRedirect');
84
- page.shellRedirect('test path');
85
- expect(shellRedirectSpy).toBeCalledTimes(1);
86
- expect(shellRedirectSpy).toBeCalledWith('test path');
87
- page.shellRedirect('new path', {discovery: true});
88
- expect(shellRedirectSpy).toBeCalledTimes(2);
89
- expect(shellRedirectSpy).toBeCalledWith('new path', {discovery: true});
90
- page.shellRedirect('new path', {replace: false});
91
- expect(shellRedirectSpy).toBeCalledTimes(3);
92
- expect(shellRedirectSpy).toBeCalledWith('new path', {replace: false});
93
-
94
- expect(page.spinner).toBe(true);
95
- page.spinner = false;
96
- expect(Global['exc-module-runtime'].page.spinner).toBe(false);
97
-
98
- expect(page.title).toBe('test title');
99
- page.title = 'updated title';
100
- expect(Global['exc-module-runtime'].page.title).toBe('updated title');
101
-
102
- const blockNavSpy = jest.spyOn(Global['exc-module-runtime'].page, 'blockNavigation');
103
- page.blockNavigation(true);
104
- expect(blockNavSpy).toBeCalledTimes(1);
105
-
106
- expect(page.unloadPromptMessage).toBe('Are you sure?');
107
- page.unloadPromptMessage = 'But are you sure you are sure?';
108
- expect(Global['exc-module-runtime'].page.unloadPromptMessage).toBe('But are you sure you are sure?');
109
- });
110
- });
@@ -1,96 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2021 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
- import Global, {Modules} from '../src/Global';
12
- import {
13
- Permissions,
14
- default as permissionsApi,
15
- PermissionsApi,
16
- PermissionsResponse
17
- } from '../permissions';
18
-
19
- describe('permissions.ts', () => {
20
- let getSpy: any;
21
-
22
- beforeAll(() => {
23
- const permissionsMock = {get: jest.fn()} as PermissionsApi;
24
- (Global['exc-module-runtime'] as Modules) = {
25
- permissions: () => {
26
- return permissionsMock;
27
- }
28
- } as Modules;
29
- getSpy = jest.spyOn(permissionsMock, 'get');
30
- });
31
-
32
- afterEach(() => jest.clearAllMocks());
33
-
34
- it('calls runtime permissions service with permissions', async () => {
35
- getSpy.mockImplementationOnce(() => Promise.resolve<PermissionsResponse<Permissions>>({permissions: {
36
- permission1: ['*'],
37
- permission2: ['read', 'write']
38
- }}));
39
-
40
- const {permissions} = await permissionsApi.get<Permissions>({permissions: ['permission1', 'permission2']});
41
- expect(getSpy).toBeCalledTimes(1);
42
- expect(getSpy).toBeCalledWith({permissions: ['permission1', 'permission2']});
43
- expect(permissions).toEqual({
44
- permission1: ['*'],
45
- permission2: ['read', 'write']
46
- });
47
- });
48
-
49
- it('calls runtime permissions service with resourceTypes', async () => {
50
- getSpy.mockImplementationOnce(() => Promise.resolve<PermissionsResponse<Permissions>>({resourceTypes: {
51
- permission1: ['*'],
52
- permission2: ['read', 'write']
53
- }}));
54
-
55
- const {resourceTypes} = await permissionsApi.get<Permissions>({resourceTypes: ['permission1', 'permission2']});
56
- expect(getSpy).toBeCalledTimes(1);
57
- expect(getSpy).toBeCalledWith({resourceTypes: ['permission1', 'permission2']});
58
- expect(resourceTypes).toEqual({
59
- permission1: ['*'],
60
- permission2: ['read', 'write']
61
- });
62
- });
63
-
64
- it('calls runtime permissions service with resourceTypes', async () => {
65
- getSpy.mockImplementationOnce(() => Promise.resolve<PermissionsResponse<Permissions>>({
66
- permissions: {
67
- permission1: ['*'],
68
- permission2: ['read', 'write']
69
- },
70
- resourceTypes: {
71
- permission1: ['*'],
72
- permission2: ['read', 'write']
73
- }
74
- }));
75
-
76
- const res = await permissionsApi.get<Permissions>({
77
- permissions: ['permission1', 'permission2'],
78
- resourceTypes: ['permission1', 'permission2']
79
- });
80
- expect(getSpy).toBeCalledTimes(1);
81
- expect(getSpy).toBeCalledWith({
82
- permissions: ['permission1', 'permission2'],
83
- resourceTypes: ['permission1', 'permission2']
84
- });
85
- expect(res).toEqual({
86
- permissions: {
87
- permission1: ['*'],
88
- permission2: ['read', 'write']
89
- },
90
- resourceTypes: {
91
- permission1: ['*'],
92
- permission2: ['read', 'write']
93
- }
94
- });
95
- });
96
- });
@@ -1,37 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
- import Global, {Modules} from '../src/Global';
12
- import pulse, {PulseApi, PulseNotification, PulseResponse} from '../pulse';
13
-
14
- describe('pulse.ts', () => {
15
- it('correctly sets up the connection with module-runtime', () => {
16
- // setup
17
- const pulseMock = {
18
- send: () => Promise.resolve<PulseResponse>({notifications: {notification: []}}),
19
- setButton: () => {},
20
- setCount: () => {}
21
- } as PulseApi;
22
- (Global['exc-module-runtime'] as Modules) = {
23
- pulse: () => {
24
- return pulseMock;
25
- }
26
- } as Modules;
27
- const sendSpy = jest.spyOn(pulseMock, 'send');
28
- const expected = [{} as PulseNotification];
29
-
30
- // action
31
- pulse.send(expected);
32
-
33
- // verify
34
- expect(sendSpy).toBeCalledTimes(1);
35
- expect(sendSpy).toBeCalledWith(expected);
36
- });
37
- });
@@ -1,89 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
- import Global, {Modules} from '../src/Global';
12
- import shell, {ShellApi, ShellInfo} from '../shell';
13
-
14
- describe('shell.ts', () => {
15
- const evt = '';
16
- const handler = () => {};
17
- const shellMock = {
18
- emit: (type, evt) => {
19
- return {evt, type};
20
- },
21
- get: (param: ShellInfo) => {
22
- return Promise.resolve(param);
23
- },
24
- off: (type, handler) => {
25
- return {handler, type};
26
- },
27
- on: (type, handler) => {
28
- return {handler, type};
29
- }
30
- } as ShellApi;
31
-
32
- beforeEach(() => {
33
- (Global['exc-module-runtime'] as Modules) = {
34
- shell: () => {
35
- return shellMock;
36
- }
37
- } as Modules;
38
- });
39
-
40
- it('can emit()', () => {
41
- const spy = jest.spyOn(shellMock, 'emit');
42
-
43
- // action
44
- shell.emit('change:environment', evt),
45
-
46
- // verify
47
- expect(spy).toBeCalledTimes(1);
48
- expect(spy).toBeCalledWith('change:environment', evt);
49
- });
50
-
51
- it('can get()', async () => {
52
- const spy = jest.spyOn(shellMock, 'get');
53
-
54
- // action
55
- await Promise.all([
56
- shell.get('environment'),
57
- shell.get('imsEnvironment'),
58
- shell.get('shellInfo')
59
- ]);
60
-
61
- // verify
62
- expect(spy).toBeCalledTimes(3);
63
- expect(spy).toBeCalledWith('environment');
64
- expect(spy).toBeCalledWith('imsEnvironment');
65
- expect(spy).toBeCalledWith('shellInfo');
66
- });
67
-
68
- it('can off()', () => {
69
- const spy = jest.spyOn(shellMock, 'off');
70
-
71
- // action
72
- shell.off('change:environment', handler),
73
-
74
- // verify
75
- expect(spy).toBeCalledTimes(1);
76
- expect(spy).toBeCalledWith('change:environment', handler);
77
- });
78
-
79
- it('can on()', () => {
80
- const spy = jest.spyOn(shellMock, 'on');
81
-
82
- // action
83
- shell.on('change:environment', handler),
84
-
85
- // verify
86
- expect(spy).toBeCalledTimes(1);
87
- expect(spy).toBeCalledWith('change:environment', handler);
88
- });
89
- });