@ui5/webcomponents-base 0.34.0 → 1.0.1

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 (145) hide show
  1. package/.eslintignore +3 -1
  2. package/CHANGELOG.md +52 -0
  3. package/README.md +26 -2
  4. package/bundle.esm.js +6 -2
  5. package/dist/CSP.js +59 -0
  6. package/dist/Device.js +7 -0
  7. package/dist/EventProvider.js +19 -25
  8. package/dist/FontFace.js +7 -95
  9. package/dist/InitialConfiguration.js +31 -14
  10. package/dist/Keys.js +15 -0
  11. package/dist/ManagedStyles.js +83 -0
  12. package/dist/Render.js +3 -1
  13. package/dist/StaticAreaItem.js +11 -9
  14. package/dist/SystemCSSVars.js +4 -25
  15. package/dist/UI5Element.js +46 -60
  16. package/dist/UI5ElementMetadata.js +9 -1
  17. package/dist/asset-registries/Icons.js +29 -8
  18. package/dist/asset-registries/Illustrations.js +30 -0
  19. package/dist/asset-registries/LocaleData.js +11 -2
  20. package/dist/assets-meta/IconCollectionsAlias.js +18 -0
  21. package/dist/config/Theme.js +14 -0
  22. package/dist/css/FontFace.css +45 -0
  23. package/dist/css/OverrideFontFace.css +32 -0
  24. package/dist/css/SystemCSSVars.css +17 -0
  25. package/dist/delegate/ItemNavigation.js +66 -0
  26. package/dist/delegate/ScrollEnablement.js +7 -1
  27. package/dist/generated/AssetParameters.js +1 -1
  28. package/dist/generated/css/FontFace.css.js +5 -0
  29. package/dist/generated/css/OverrideFontFace.css.js +5 -0
  30. package/dist/generated/css/SystemCSSVars.css.js +5 -0
  31. package/dist/i18nBundle.js +33 -2
  32. package/dist/renderer/LitRenderer.js +24 -21
  33. package/dist/renderer/directives/style-map.js +72 -0
  34. package/dist/resources/bundle.esm.js +17 -101
  35. package/dist/resources/bundle.esm.js.map +1 -1
  36. package/dist/sap/base/Log.js +241 -0
  37. package/dist/sap/base/assert.js +8 -0
  38. package/dist/sap/base/security/URLListValidator.js +148 -0
  39. package/dist/sap/base/security/sanitizeHTML.js +16 -0
  40. package/dist/sap/base/util/now.js +7 -0
  41. package/dist/sap/ui/thirdparty/caja-html-sanitizer.js +3585 -0
  42. package/dist/test-resources/elements/WithStaticArea.js +2 -1
  43. package/dist/test-resources/pages/AllTestElements.html +3 -0
  44. package/dist/test-resources/pages/i18n.html +1 -3
  45. package/dist/test-resources/specs/ConfigurationChange.spec.js +9 -9
  46. package/dist/test-resources/specs/ConfigurationScript.spec.js +24 -24
  47. package/dist/test-resources/specs/ConfigurationURL.spec.js +64 -18
  48. package/dist/test-resources/specs/CustomTheme.spec.js +7 -7
  49. package/dist/test-resources/specs/EventProvider.spec.js +63 -0
  50. package/dist/test-resources/specs/StaticArea.spec.js +55 -13
  51. package/dist/test-resources/specs/Theming.spec.js +11 -11
  52. package/dist/test-resources/specs/UI5ElementInvalidation.js +29 -29
  53. package/dist/test-resources/specs/UI5ElementLifecycle.js +11 -11
  54. package/dist/test-resources/specs/UI5ElementListenForChildPropChanges.spec.js +11 -11
  55. package/dist/test-resources/specs/UI5ElementMetadataExt.js +8 -8
  56. package/dist/test-resources/specs/UI5ElementPropertyValidation.js +6 -6
  57. package/dist/test-resources/specs/UI5ElementPropsAndAttrs.spec.js +36 -36
  58. package/dist/test-resources/specs/UI5ElementShadowDOM.js +9 -9
  59. package/dist/test-resources/specs/UI5ElementSlots.js +9 -9
  60. package/dist/theming/CustomStyle.js +23 -3
  61. package/dist/theming/applyTheme.js +5 -8
  62. package/dist/theming/getEffectiveLinksHrefs.js +20 -0
  63. package/dist/theming/getStylesString.js +4 -2
  64. package/dist/theming/getThemeDesignerTheme.js +2 -1
  65. package/dist/theming/preloadLinks.js +23 -0
  66. package/dist/types/DataType.js +12 -0
  67. package/dist/types/Float.js +4 -0
  68. package/dist/types/Integer.js +4 -0
  69. package/dist/types/InvisibleMessageMode.js +30 -0
  70. package/dist/updateShadowRoot.js +8 -4
  71. package/dist/util/AriaLabelHelper.js +4 -4
  72. package/dist/util/FocusableElements.js +5 -1
  73. package/dist/util/HTMLSanitizer.js +7 -0
  74. package/dist/util/InvisibleMessage.js +58 -0
  75. package/dist/util/PopupUtils.js +1 -1
  76. package/dist/util/TabbableElements.js +1 -1
  77. package/dist/util/createLinkInHead.js +19 -0
  78. package/dist/util/encodeXML.js +35 -0
  79. package/dist/util/escapeRegex.js +10 -0
  80. package/dist/util/generateHighlightedMarkup.js +42 -0
  81. package/dist/util/getClassCopy.js +7 -2
  82. package/dist/util/isNodeTabbable.js +4 -4
  83. package/hash.txt +1 -1
  84. package/index.js +1 -1
  85. package/lib/generate-asset-parameters/index.js +0 -1
  86. package/lib/generate-styles/index.js +18 -0
  87. package/package-scripts.js +25 -3
  88. package/package.json +17 -9
  89. package/src/CSP.js +59 -0
  90. package/src/Device.js +7 -0
  91. package/src/EventProvider.js +19 -25
  92. package/src/FontFace.js +7 -95
  93. package/src/InitialConfiguration.js +31 -14
  94. package/src/Keys.js +15 -0
  95. package/src/ManagedStyles.js +83 -0
  96. package/src/Render.js +3 -1
  97. package/src/StaticAreaItem.js +11 -9
  98. package/src/SystemCSSVars.js +4 -25
  99. package/src/UI5Element.js +46 -60
  100. package/src/UI5ElementMetadata.js +9 -1
  101. package/src/asset-registries/Icons.js +29 -8
  102. package/src/asset-registries/Illustrations.js +30 -0
  103. package/src/asset-registries/LocaleData.js +11 -2
  104. package/src/assets-meta/IconCollectionsAlias.js +18 -0
  105. package/src/config/Theme.js +14 -0
  106. package/src/css/FontFace.css +45 -0
  107. package/src/css/OverrideFontFace.css +32 -0
  108. package/src/css/SystemCSSVars.css +17 -0
  109. package/src/delegate/ItemNavigation.js +66 -0
  110. package/src/delegate/ScrollEnablement.js +7 -1
  111. package/src/i18nBundle.js +33 -2
  112. package/src/renderer/LitRenderer.js +24 -21
  113. package/src/renderer/directives/style-map.js +72 -0
  114. package/src/theming/CustomStyle.js +23 -3
  115. package/src/theming/applyTheme.js +5 -8
  116. package/src/theming/getEffectiveLinksHrefs.js +20 -0
  117. package/src/theming/getStylesString.js +4 -2
  118. package/src/theming/getThemeDesignerTheme.js +2 -1
  119. package/src/theming/preloadLinks.js +23 -0
  120. package/src/types/DataType.js +12 -0
  121. package/src/types/Float.js +4 -0
  122. package/src/types/Integer.js +4 -0
  123. package/src/types/InvisibleMessageMode.js +30 -0
  124. package/src/updateShadowRoot.js +8 -4
  125. package/src/util/AriaLabelHelper.js +4 -4
  126. package/src/util/FocusableElements.js +5 -1
  127. package/src/util/HTMLSanitizer.js +7 -0
  128. package/src/util/InvisibleMessage.js +58 -0
  129. package/src/util/PopupUtils.js +1 -1
  130. package/src/util/TabbableElements.js +1 -1
  131. package/src/util/createLinkInHead.js +19 -0
  132. package/src/util/encodeXML.js +35 -0
  133. package/src/util/escapeRegex.js +10 -0
  134. package/src/util/generateHighlightedMarkup.js +42 -0
  135. package/src/util/getClassCopy.js +7 -2
  136. package/src/util/isNodeTabbable.js +4 -4
  137. package/used-modules.txt +7 -0
  138. package/dist/config/AssetsPath.js +0 -17
  139. package/dist/renderer/ifDefined.js +0 -21
  140. package/dist/renderer/scopeHTML.js +0 -32
  141. package/dist/theming/createThemePropertiesStyleTag.js +0 -20
  142. package/src/config/AssetsPath.js +0 -17
  143. package/src/renderer/ifDefined.js +0 -21
  144. package/src/renderer/scopeHTML.js +0 -32
  145. package/src/theming/createThemePropertiesStyleTag.js +0 -20
@@ -27,8 +27,9 @@ class WithStaticArea extends UI5Element {
27
27
 
28
28
  static get template() {
29
29
  return element => {
30
+ // access effectiveDir getter to mark control as RTL-aware (test changes dir attribute and expects rerender)
30
31
  return html`
31
- <div>
32
+ <div dir=${element.effectiveDir}>
32
33
  WithStaticArea works!
33
34
  </div>`;
34
35
  };
@@ -35,5 +35,8 @@
35
35
 
36
36
  <ui5-with-static-area id="no-static-area"></ui5-with-static-area>
37
37
  <ui5-with-static-area id="with-static-area" static-content></ui5-with-static-area>
38
+ <div id="with-static-area-rtl-container" dir="rtl">
39
+ <ui5-with-static-area id="with-static-area-rtl" static-content></ui5-with-static-area>
40
+ </div>
38
41
  </body>
39
42
  </html>
@@ -17,9 +17,7 @@
17
17
  const demo = async () => {
18
18
  ["de", "es", "fr", "en"].forEach(localeId => registerI18nLoader("myApp", localeId, () => `./assets/messagebundle_${localeId}.properties`));
19
19
 
20
- await fetchI18nBundle("myApp");
21
-
22
- const bundle = getI18nBundle("myApp");
20
+ const bundle = await getI18nBundle("myApp");
23
21
 
24
22
  const pleaseWait = bundle.getText("PLEASE_WAIT");
25
23
  console.log("Please wait in the current language is: ", pleaseWait);
@@ -1,27 +1,27 @@
1
1
  const assert = require("chai").assert;
2
2
 
3
3
  describe("Some configuration options can be changed at runtime", () => {
4
- before(() => {
5
- browser.url("http://localhost:9191/test-resources/pages/Configuration.html");
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/Configuration.html");
6
6
  });
7
7
 
8
- it("Tests that theme can be changed", () => {
8
+ it("Tests that theme can be changed", async () => {
9
9
  const newTheme = 'sap_belize_hcb';
10
10
 
11
- const res = browser.executeAsync( async (newTheme, done) => {
11
+ const res = await browser.executeAsync( async (newTheme, done) => {
12
12
  const config = window['sap-ui-webcomponents-bundle'].configuration;
13
13
  await config.setTheme(newTheme);
14
- return done(config.getTheme());
14
+ done(config.getTheme());
15
15
  }, newTheme);
16
16
  assert.strictEqual(res, newTheme, "Theme changed to HCB");
17
17
  });
18
18
 
19
- it("Tests that noConflict can be changed", () => {
20
- const res = browser.execute( () => {
19
+ it("Tests that noConflict can be changed", async () => {
20
+ const res = await browser.executeAsync(done => {
21
21
  const config = window['sap-ui-webcomponents-bundle'].configuration;
22
22
  config.setNoConflict({events: ["selection-change"]});
23
- return config.getNoConflict();
23
+ done(config.getNoConflict());
24
24
  });
25
- assert.strictEqual(res.events.includes("selection-change"), true, "selection-change was successfully registered as a no conflict event");
25
+ assert.include(res.events, "selection-change", "selection-change was successfully registered as a no conflict event");
26
26
  });
27
27
  });
@@ -1,62 +1,62 @@
1
1
  const assert = require("chai").assert;
2
2
 
3
3
  describe("Configuration script has effect", () => {
4
- before(() => {
5
- browser.url("http://localhost:9191/test-resources/pages/ConfigurationScript.html?do-not-change-configuration");
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/ConfigurationScript.html?do-not-change-configuration");
6
6
  });
7
7
 
8
- it("Tests that RTL is applied", () => {
9
- const res = browser.execute( () => {
8
+ it("Tests that RTL is applied", async () => {
9
+ const res = await browser.executeAsync(done => {
10
10
  const config = window['sap-ui-webcomponents-bundle'].configuration;
11
- return config.getRTL();
11
+ done(config.getRTL());
12
12
  });
13
13
  assert.strictEqual(res, true, "RTL is true");
14
14
  });
15
15
 
16
- it("Tests that language is applied", () => {
17
- const res = browser.execute( () => {
16
+ it("Tests that language is applied", async () => {
17
+ const res = await browser.executeAsync(done => {
18
18
  const config = window['sap-ui-webcomponents-bundle'].configuration;
19
- return config.getLanguage();
19
+ done(config.getLanguage());
20
20
  });
21
21
  assert.strictEqual(res, 'ja', "language is japanese");
22
22
  });
23
23
 
24
- it("Tests that calendarType is applied", () => {
25
- const res = browser.execute( () => {
24
+ it("Tests that calendarType is applied", async () => {
25
+ const res = await browser.executeAsync(done => {
26
26
  const config = window['sap-ui-webcomponents-bundle'].configuration;
27
- return config.getCalendarType();
27
+ done(config.getCalendarType());
28
28
  });
29
29
  assert.strictEqual(res, 'Japanese', "calendarType is japanese");
30
30
  });
31
31
 
32
- it("Tests that formatSettings are applied", () => {
33
- const res = browser.execute( () => {
32
+ it("Tests that formatSettings are applied", async () => {
33
+ const res = await browser.executeAsync(done => {
34
34
  const config = window['sap-ui-webcomponents-bundle'].configuration;
35
- return config.getFirstDayOfWeek();
35
+ done(config.getFirstDayOfWeek());
36
36
  });
37
37
  assert.strictEqual(res, 0, "First day of week is applied");
38
38
  });
39
39
 
40
- it("Tests that theme is applied", () => {
41
- const res = browser.execute( () => {
40
+ it("Tests that theme is applied", async () => {
41
+ const res = await browser.executeAsync(done => {
42
42
  const config = window['sap-ui-webcomponents-bundle'].configuration;
43
- return config.getTheme();
43
+ done(config.getTheme());
44
44
  });
45
45
  assert.strictEqual(res, 'sap_belize_hcb', "Thems is HCB");
46
46
  });
47
47
 
48
- it("Tests that noConflict is applied", () => {
49
- const res = browser.execute( () => {
48
+ it("Tests that noConflict is applied", async () => {
49
+ const res = await browser.executeAsync(done => {
50
50
  const config = window['sap-ui-webcomponents-bundle'].configuration;
51
- return config.getNoConflict();
51
+ done(config.getNoConflict());
52
52
  });
53
- assert.strictEqual(res.events.includes("selection-change"), true, "selectionChange was successfully registered as a no conflict event");
53
+ assert.include(res.events, "selection-change", "selectionChange was successfully registered as a no conflict event");
54
54
  });
55
55
 
56
- it("Tests that animationMode is applied", () => {
57
- const res = browser.execute( () => {
56
+ it("Tests that animationMode is applied", async () => {
57
+ const res = await browser.executeAsync(done => {
58
58
  const config = window['sap-ui-webcomponents-bundle'].configuration;
59
- return config.getAnimationMode();
59
+ done(config.getAnimationMode());
60
60
  });
61
61
  assert.strictEqual(res, 'basic', "animationMode is basic");
62
62
  });
@@ -1,47 +1,93 @@
1
1
  const assert = require("chai").assert;
2
2
 
3
- describe("Some settings can be set via URL params", () => {
4
- before(() => {
5
- browser.url("http://localhost:9191/test-resources/pages/Configuration.html?sap-ui-rtl=true&sap-ui-language=ja&sap-ui-calendarType=Japanese&sap-ui-theme=sap_belize_hcb&sap-ui-animationMode=basic");
3
+ describe("Some settings can be set via SAP UI URL params", () => {
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/Configuration.html?sap-ui-rtl=true&sap-ui-language=ja&sap-ui-calendarType=Japanese&sap-ui-theme=sap_belize_hcb&sap-ui-animationMode=basic");
6
6
  });
7
7
 
8
- it("Tests that RTL is applied", () => {
9
- const res = browser.execute( () => {
8
+ it("Tests that RTL is applied", async () => {
9
+ const res = await browser.executeAsync(done => {
10
10
  const config = window['sap-ui-webcomponents-bundle'].configuration;
11
- return config.getRTL();
11
+ done(config.getRTL());
12
12
  });
13
13
  assert.strictEqual(res, true, "RTL is true");
14
14
  });
15
15
 
16
- it("Tests that language is applied", () => {
17
- const res = browser.execute( () => {
16
+ it("Tests that language is applied", async () => {
17
+ const res = await browser.executeAsync(done => {
18
18
  const config = window['sap-ui-webcomponents-bundle'].configuration;
19
- return config.getLanguage();
19
+ done(config.getLanguage());
20
20
  });
21
21
  assert.strictEqual(res, 'ja', "language is japanese");
22
22
  });
23
23
 
24
- it("Tests that calendarType is applied", () => {
25
- const res = browser.execute( () => {
24
+ it("Tests that calendarType is applied", async () => {
25
+ const res = await browser.executeAsync(done => {
26
26
  const config = window['sap-ui-webcomponents-bundle'].configuration;
27
- return config.getCalendarType();
27
+ done(config.getCalendarType());
28
28
  });
29
29
  assert.strictEqual(res, 'Japanese', "calendarType is japanese");
30
30
  });
31
31
 
32
- it("Tests that theme is applied", () => {
33
- const res = browser.execute( () => {
32
+ it("Tests that theme is applied", async () => {
33
+ const res = await browser.executeAsync(done => {
34
34
  const config = window['sap-ui-webcomponents-bundle'].configuration;
35
- return config.getTheme();
35
+ done(config.getTheme());
36
36
  });
37
37
  assert.strictEqual(res, 'sap_belize_hcb', "Thems is HCB");
38
38
  });
39
39
 
40
- it("Tests that animationMode is applied", () => {
41
- const res = browser.execute( () => {
40
+ it("Tests that animationMode is applied", async () => {
41
+ const res = await browser.executeAsync(done => {
42
42
  const config = window['sap-ui-webcomponents-bundle'].configuration;
43
- return config.getAnimationMode();
43
+ done(config.getAnimationMode());
44
44
  });
45
45
  assert.strictEqual(res, 'basic', "animationMode is basic");
46
46
  });
47
47
  });
48
+
49
+
50
+ describe("Some settings can be set via SAP URL params", () => {
51
+ before(async () => {
52
+ await browser.url("http://localhost:9191/test-resources/pages/Configuration.html?sap-language=bg&sap-theme=sap_fiori_3_dark");
53
+ });
54
+
55
+ it("Tests that language is applied", async () => {
56
+ const res = await browser.executeAsync(done => {
57
+ const config = window['sap-ui-webcomponents-bundle'].configuration;
58
+ done(config.getLanguage());
59
+ });
60
+ assert.strictEqual(res, 'bg', "language is bulgarian");
61
+ });
62
+
63
+ it("Tests that theme is applied", async () => {
64
+ const res = await browser.executeAsync(done => {
65
+ const config = window['sap-ui-webcomponents-bundle'].configuration;
66
+ done(config.getTheme());
67
+ });
68
+ assert.strictEqual(res, 'sap_fiori_3_dark', "Thems is Fiori Dark");
69
+ });
70
+ });
71
+
72
+
73
+ describe("SAP UI params take precedence over the SAP params", () => {
74
+ before(async () => {
75
+ await browser.url("http://localhost:9191/test-resources/pages/Configuration.html?sap-language=bg&sap-ui-language=de&sap-theme=sap_fiori_3_dark&sap-theme=sap_fiori_3_hcb");
76
+ });
77
+
78
+ it("Tests that language is applied via sap-ui-language", async () => {
79
+ const res = await browser.executeAsync(done => {
80
+ const config = window['sap-ui-webcomponents-bundle'].configuration;
81
+ done(config.getLanguage());
82
+ });
83
+ assert.strictEqual(res, 'de', "language is german");
84
+ });
85
+
86
+ it("Tests that theme is applied via sap-ui-theme", async () => {
87
+ const res = await browser.executeAsync(done => {
88
+ const config = window['sap-ui-webcomponents-bundle'].configuration;
89
+ done(config.getTheme());
90
+ });
91
+ assert.strictEqual(res, 'sap_fiori_3_hcb', "Thems is Fiori HCB");
92
+ });
93
+ });
@@ -1,14 +1,14 @@
1
1
  const assert = require("chai").assert;
2
2
 
3
3
  describe("Custom themes can be registered", () => {
4
- before(() => {
5
- browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
6
6
  });
7
7
 
8
- it("Tests that theme parameters are changed on theme change", () => {
8
+ it("Tests that theme parameters are changed on theme change", async () => {
9
9
  const newTheme = 'my_custom_theme';
10
10
 
11
- const res = browser.executeAsync( async (newTheme, done) => {
11
+ const res = await browser.executeAsync( async (newTheme, done) => {
12
12
  const var1 = "--var1: #555555";
13
13
 
14
14
  window.registerThemePropertiesLoader("@ui5/webcomponents-base-test", newTheme, () => `:root{ ${var1}; }`);
@@ -16,9 +16,9 @@ describe("Custom themes can be registered", () => {
16
16
  const config = window['sap-ui-webcomponents-bundle'].configuration;
17
17
  await config.setTheme(newTheme);
18
18
 
19
- const style = document.querySelector(`style[data-ui5-theme-properties="@ui5/webcomponents-base-test"]`);
20
- const varsFound = style && style.textContent.includes(var1);
21
- return done(varsFound);
19
+ const style = document.adoptedStyleSheets.find(sh => sh._ui5StyleId === "data-ui5-theme-properties|@ui5/webcomponents-base-test").cssRules[0].cssText;
20
+ const varsFound = style && style.includes(var1);
21
+ done(varsFound);
22
22
  }, newTheme);
23
23
 
24
24
  assert.strictEqual(res, true, "Theme parameters changed");
@@ -0,0 +1,63 @@
1
+ const assert = require("chai").assert;
2
+
3
+ describe("Event provider attaches and detaches listeners properly", () => {
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
6
+ });
7
+
8
+ it("Tests that listeners can be removed (1 listener)", async () => {
9
+
10
+ const res = await browser.executeAsync(done => {
11
+ let timesCalled = 0;
12
+ const ep = new window["sap-ui-webcomponents-bundle"].EventProvider();
13
+ const callback = () => {
14
+ timesCalled++;
15
+ };
16
+
17
+ // Setup
18
+ ep.attachEvent("test", callback);
19
+
20
+ // Act
21
+ ep.fireEvent("test"); // should execute the callback and increase the counter
22
+
23
+ // Setup
24
+ ep.detachEvent("test", callback);
25
+
26
+ // Act
27
+ ep.fireEvent("test"); // should not execute the callback and increase the counter
28
+
29
+ done(timesCalled);
30
+ });
31
+
32
+ assert.strictEqual(res, 1, "The callback should be called exactly once");
33
+ });
34
+
35
+ it("Tests that listeners can be removed (more than 1 listener)", async () => {
36
+
37
+ const res = await browser.executeAsync(done => {
38
+ let timesCalled = 0;
39
+ const ep = new window["sap-ui-webcomponents-bundle"].EventProvider();
40
+ const callback = () => {
41
+ timesCalled++;
42
+ };
43
+ const somePreviousCallback = () => {};
44
+
45
+ // Setup
46
+ ep.attachEvent("test", somePreviousCallback); // Attach something so that after detachEvent the listeners array is not empty!
47
+ ep.attachEvent("test", callback);
48
+
49
+ // Act
50
+ ep.fireEvent("test"); // should execute the callback and increase the counter
51
+
52
+ // Setup
53
+ ep.detachEvent("test", callback);
54
+
55
+ // Act
56
+ ep.fireEvent("test"); // should not execute the callback and increase the counter
57
+
58
+ done(timesCalled);
59
+ });
60
+
61
+ assert.strictEqual(res, 1, "The callback should be called exactly once");
62
+ });
63
+ });
@@ -1,26 +1,26 @@
1
1
  const assert = require("chai").assert;
2
2
 
3
3
  describe("Some configuration options can be changed at runtime", () => {
4
- before(() => {
5
- browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
6
6
  });
7
7
 
8
- it("Tests control with no static area item", () => {
9
- const componentId = browser.$("#no-static-area").getProperty("_id");
10
- const staticArea = browser.$("ui5-static-area");
8
+ it("Tests control with no static area item", async () => {
9
+ const componentId = await browser.$("#no-static-area").getProperty("_id");
10
+ const staticArea = await browser.$("ui5-static-area");
11
11
 
12
- assert.notOk(staticArea.$(`.${componentId}`).isExisting(), "No static area item is defined for this control");
12
+ assert.notOk(await staticArea.$(`.${componentId}`).isExisting(), "No static area item is defined for this control");
13
13
  });
14
14
 
15
- it("Tests control with static area item", () => {
16
- const componentId = browser.$("#with-static-area").getProperty("_id");
17
- const staticArea = browser.$("ui5-static-area");
15
+ it("Tests control with static area item", async () => {
16
+ const componentId = await browser.$("#with-static-area").getProperty("_id");
17
+ const staticArea = await browser.$("ui5-static-area");
18
18
 
19
- assert.ok(staticArea.$(`.${componentId}`).isExisting(), "No static area item is defined for this control");
19
+ assert.ok(await staticArea.$(`.${componentId}`).isExisting(), "No static area item is defined for this control");
20
20
  });
21
21
 
22
- it("Tests removing an element with static area", () => {
23
- const result = browser.execute(() => {
22
+ it("Tests removing an element with static area", async () => {
23
+ const result = await browser.executeAsync(done => {
24
24
  let res = true;
25
25
  window.onerror = (errorMsg, url, lineNumber) => {
26
26
  res = false;
@@ -28,9 +28,51 @@ describe("Some configuration options can be changed at runtime", () => {
28
28
 
29
29
  document.querySelector("#no-static-area").remove();
30
30
 
31
- return res;
31
+ done(res);
32
32
  });
33
33
 
34
34
  assert.ok(result, "Static area removed from DOM successfully");
35
35
  });
36
+
37
+ it("Test RTL not set for static area items", async () => {
38
+ const componentId = await browser.$("#with-static-area").getProperty("_id");
39
+ const staticArea = await browser.$("ui5-static-area");
40
+
41
+ assert.notOk(await staticArea.$(`.${componentId}`).getAttribute("dir"), "dir attribute not set for static area item");
42
+ });
43
+
44
+ it("Test RTL set for static area items", async () => {
45
+ const componentId = await browser.$("#with-static-area-rtl").getProperty("_id");
46
+ const staticArea = await browser.$("ui5-static-area");
47
+
48
+ assert.equal(await staticArea.$(`.${componentId}`).getAttribute("dir"), "rtl", "dir property correctly set for static area item");
49
+ });
50
+
51
+ it("Test setting RTL for a static area item owner", async () => {
52
+ const componentId = await browser.$("#with-static-area").getProperty("_id");
53
+ const staticArea = await browser.$("ui5-static-area");
54
+
55
+ await browser.$("#with-static-area").setAttribute("dir", "rtl");
56
+ await browser.executeAsync( async (done) => {
57
+ await window["sap-ui-webcomponents-bundle"].applyDirection();
58
+ await window["sap-ui-webcomponents-bundle"].renderFinished();
59
+
60
+ done();
61
+ });
62
+ assert.equal(await staticArea.$(`.${componentId}`).getAttribute("dir"), "rtl", "dir attribute dynamically set for static area item owner");
63
+ });
64
+
65
+ it("Test removing RTL for a static area item owner", async () => {
66
+ const componentId = await browser.$("#with-static-area-rtl").getProperty("_id");
67
+ const staticArea = await browser.$("ui5-static-area");
68
+
69
+ await browser.$("#with-static-area-rtl-container").removeAttribute("dir");
70
+ await browser.executeAsync( async (done) => {
71
+ await window["sap-ui-webcomponents-bundle"].applyDirection();
72
+ await window["sap-ui-webcomponents-bundle"].renderFinished();
73
+
74
+ done();
75
+ });
76
+ assert.notOk(await staticArea.$(`.${componentId}`).getAttribute("dir"), "dir attribute dynamically removed for static area item owner");
77
+ });
36
78
  });
@@ -1,30 +1,30 @@
1
1
  const assert = require("chai").assert;
2
2
 
3
3
  describe("Theming works", () => {
4
- before(() => {
5
- browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
6
6
  });
7
7
 
8
- it("Tests that the parameters for the default theme are embedded on boot", () => {
8
+ it("Tests that the parameters for the default theme are embedded on boot", async () => {
9
9
 
10
- const res = browser.execute(() => {
11
- const style = document.querySelector(`style[data-ui5-theme-properties="@ui5/webcomponents-base-test"]`);
12
- return style && style.textContent.includes("--var1: red"); // see test/assets/Themes.js
10
+ const res = await browser.executeAsync(done => {
11
+ const style = document.adoptedStyleSheets.find(sh => sh._ui5StyleId === "data-ui5-theme-properties|@ui5/webcomponents-base-test").cssRules[0].cssText
12
+ done(style && style.includes("--var1: red")); // see test/assets/Themes.js
13
13
  });
14
14
 
15
15
  assert.strictEqual(res, true, "The fiori3 vars are found");
16
16
  });
17
17
 
18
- it("Tests that theme parameters are changed on theme change", () => {
18
+ it("Tests that theme parameters are changed on theme change", async () => {
19
19
  const newTheme = 'sap_belize_hcb';
20
20
 
21
- const res = browser.executeAsync( async (newTheme, done) => {
21
+ const res = await browser.executeAsync( async (newTheme, done) => {
22
22
  const config = window['sap-ui-webcomponents-bundle'].configuration;
23
23
  await config.setTheme(newTheme);
24
24
 
25
- const style = document.querySelector(`style[data-ui5-theme-properties="@ui5/webcomponents-base-test"]`);
26
- const varsFound = style && style.textContent.includes("--var1: orange"); // see test/assets/Themes.js
27
- return done(varsFound);
25
+ const style = document.adoptedStyleSheets.find(sh => sh._ui5StyleId === "data-ui5-theme-properties|@ui5/webcomponents-base-test").cssRules[0].cssText
26
+ const varsFound = style && style.includes("--var1: orange"); // see test/assets/Themes.js
27
+ done(varsFound);
28
28
  }, newTheme);
29
29
 
30
30
  assert.strictEqual(res, true, "Theme parameters changed");