@ui5/webcomponents-base 2.1.1 → 2.2.0-rc.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 (117) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/cypress/specs/Accessor.cy.ts +83 -0
  3. package/cypress/specs/Boot.cy.ts +23 -0
  4. package/cypress/specs/ConfigurationChange.cy.ts +41 -0
  5. package/cypress/specs/ConfigurationScript.cy.ts +116 -0
  6. package/cypress/specs/ConfigurationURL.cy.ts +182 -0
  7. package/cypress/specs/CustomMount.cy.ts +34 -0
  8. package/cypress/specs/CustomTheme.cy.ts +36 -0
  9. package/cypress/specs/EventProvider.cy.ts +59 -0
  10. package/cypress/specs/SystemDOMElements.cy.ts +8 -0
  11. package/cypress/specs/Theming.cy.ts +74 -0
  12. package/cypress/specs/UI5ElementInvalidation.cy.ts +207 -0
  13. package/cypress/specs/UI5ElementLifecycle.cy.ts +82 -0
  14. package/cypress/specs/UI5ElementListenForChildPropChanges.cy.ts +62 -0
  15. package/cypress/specs/UI5ElementMetadataExt.cy.ts +42 -0
  16. package/cypress/specs/UI5ElementPropertyValidation.cy.ts +17 -0
  17. package/cypress/specs/UI5ElementPropsAndAttrs.cy.ts +113 -0
  18. package/cypress/specs/UI5ElementShadowDOM.cy.ts +30 -0
  19. package/cypress/specs/UI5ElementSlots.cy.ts +116 -0
  20. package/cypress/specs/WithComplexTemplate.cy.ts +32 -0
  21. package/cypress/tsconfig.json +20 -0
  22. package/cypress.config.js +3 -0
  23. package/dist/.tsbuildinfobuild +1 -0
  24. package/dist/InitialConfiguration.d.ts +7 -1
  25. package/dist/InitialConfiguration.js +20 -3
  26. package/dist/InitialConfiguration.js.map +1 -1
  27. package/dist/Location.d.ts +11 -0
  28. package/dist/Location.js +49 -0
  29. package/dist/Location.js.map +1 -0
  30. package/dist/Runtimes.js +11 -0
  31. package/dist/Runtimes.js.map +1 -1
  32. package/dist/UI5Element.js +19 -11
  33. package/dist/UI5Element.js.map +1 -1
  34. package/dist/config/AnimationMode.js +4 -0
  35. package/dist/config/AnimationMode.js.map +1 -1
  36. package/dist/config/CalendarType.js +5 -0
  37. package/dist/config/CalendarType.js.map +1 -1
  38. package/dist/config/ConfigurationReset.d.ts +4 -0
  39. package/dist/config/ConfigurationReset.js +11 -0
  40. package/dist/config/ConfigurationReset.js.map +1 -0
  41. package/dist/config/Fonts.js +4 -0
  42. package/dist/config/Fonts.js.map +1 -1
  43. package/dist/config/FormatSettings.js +4 -0
  44. package/dist/config/FormatSettings.js.map +1 -1
  45. package/dist/config/Language.js +6 -1
  46. package/dist/config/Language.js.map +1 -1
  47. package/dist/config/NoConflict.js +4 -0
  48. package/dist/config/NoConflict.js.map +1 -1
  49. package/dist/config/Theme.js +4 -0
  50. package/dist/config/Theme.js.map +1 -1
  51. package/dist/config/ThemeRoot.js +4 -0
  52. package/dist/config/ThemeRoot.js.map +1 -1
  53. package/dist/config/Timezone.js +4 -0
  54. package/dist/config/Timezone.js.map +1 -1
  55. package/dist/config/Tooltips.d.ts +19 -0
  56. package/dist/config/Tooltips.js +29 -0
  57. package/dist/config/Tooltips.js.map +1 -0
  58. package/dist/custom-elements-internal.json +48 -0
  59. package/dist/custom-elements.json +48 -0
  60. package/dist/decorators/query.d.ts +25 -0
  61. package/dist/decorators/query.js +32 -0
  62. package/dist/decorators/query.js.map +1 -0
  63. package/dist/decorators/queryAll.d.ts +27 -0
  64. package/dist/decorators/queryAll.js +34 -0
  65. package/dist/decorators/queryAll.js.map +1 -0
  66. package/dist/generated/VersionInfo.js +5 -5
  67. package/dist/generated/VersionInfo.js.map +1 -1
  68. package/dist/prod/InitialConfiguration.js +1 -1
  69. package/dist/prod/InitialConfiguration.js.map +3 -3
  70. package/dist/prod/Location.js +2 -0
  71. package/dist/prod/Location.js.map +7 -0
  72. package/dist/prod/Runtimes.js +1 -1
  73. package/dist/prod/Runtimes.js.map +3 -3
  74. package/dist/prod/UI5Element.js +1 -1
  75. package/dist/prod/UI5Element.js.map +2 -2
  76. package/dist/prod/config/AnimationMode.js +1 -1
  77. package/dist/prod/config/AnimationMode.js.map +3 -3
  78. package/dist/prod/config/CalendarType.js +1 -1
  79. package/dist/prod/config/CalendarType.js.map +3 -3
  80. package/dist/prod/config/ConfigurationReset.js +2 -0
  81. package/dist/prod/config/ConfigurationReset.js.map +7 -0
  82. package/dist/prod/config/Fonts.js +1 -1
  83. package/dist/prod/config/Fonts.js.map +3 -3
  84. package/dist/prod/config/FormatSettings.js +1 -1
  85. package/dist/prod/config/FormatSettings.js.map +3 -3
  86. package/dist/prod/config/Language.js +1 -1
  87. package/dist/prod/config/Language.js.map +3 -3
  88. package/dist/prod/config/NoConflict.js +1 -1
  89. package/dist/prod/config/NoConflict.js.map +3 -3
  90. package/dist/prod/config/Theme.js +1 -1
  91. package/dist/prod/config/Theme.js.map +3 -3
  92. package/dist/prod/config/ThemeRoot.js +1 -1
  93. package/dist/prod/config/ThemeRoot.js.map +3 -3
  94. package/dist/prod/config/Timezone.js +1 -1
  95. package/dist/prod/config/Timezone.js.map +3 -3
  96. package/dist/prod/config/Tooltips.js +2 -0
  97. package/dist/prod/config/Tooltips.js.map +7 -0
  98. package/dist/prod/decorators/query.js +2 -0
  99. package/dist/prod/decorators/query.js.map +7 -0
  100. package/dist/prod/decorators/queryAll.js +2 -0
  101. package/dist/prod/decorators/queryAll.js.map +7 -0
  102. package/dist/prod/generated/VersionInfo.js +1 -1
  103. package/dist/prod/generated/VersionInfo.js.map +2 -2
  104. package/dist/prod/validateThemeRoot.js +1 -1
  105. package/dist/prod/validateThemeRoot.js.map +3 -3
  106. package/dist/validateThemeRoot.js +3 -2
  107. package/dist/validateThemeRoot.js.map +1 -1
  108. package/package-scripts.cjs +5 -3
  109. package/package.json +4 -3
  110. package/tsconfig.json +19 -19
  111. package/config/wdio.conf.cjs +0 -392
  112. package/dist/.tsbuildinfo +0 -1
  113. package/dist/generated/templates/elements/WithComplexTemplateTemplate.lit.d.ts +0 -4
  114. package/dist/generated/templates/elements/WithComplexTemplateTemplate.lit.js +0 -9
  115. package/dist/generated/templates/elements/WithComplexTemplateTemplate.lit.js.map +0 -1
  116. package/dist/prod/generated/templates/elements/WithComplexTemplateTemplate.lit.js +0 -2
  117. package/dist/prod/generated/templates/elements/WithComplexTemplateTemplate.lit.js.map +0 -7
package/CHANGELOG.md CHANGED
@@ -3,6 +3,32 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.2.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v2.2.0-rc.0...v2.2.0-rc.1) (2024-08-15)
7
+
8
+ **Note:** Version bump only for package @ui5/webcomponents-base
9
+
10
+
11
+
12
+
13
+
14
+ # [2.2.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.1.1...v2.2.0-rc.0) (2024-08-08)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **core:** invalidation no longer leaves component broken after error in onBeforeRendering ([#9635](https://github.com/SAP/ui5-webcomponents/issues/9635)) ([136bd5a](https://github.com/SAP/ui5-webcomponents/commit/136bd5acef5dcf25bb3ec9f46b66e33aa819f49a))
20
+ * stop attribute change calling property setter when coming from a setter ([#9592](https://github.com/SAP/ui5-webcomponents/issues/9592)) ([95e61dd](https://github.com/SAP/ui5-webcomponents/commit/95e61ddc097658c49509889c8454901a8a8ef0b4))
21
+
22
+
23
+ ### Features
24
+
25
+ * add `enableDefaultTooltips ` config option ([#9559](https://github.com/SAP/ui5-webcomponents/issues/9559)) ([a672788](https://github.com/SAP/ui5-webcomponents/commit/a6727880e9fc648a8999643a2d2dac4eaff5c58c)), closes [#9494](https://github.com/SAP/ui5-webcomponents/issues/9494)
26
+ * **framework:** add `[@query](https://github.com/query)(All)` decorators ([#9567](https://github.com/SAP/ui5-webcomponents/issues/9567)) ([242024c](https://github.com/SAP/ui5-webcomponents/commit/242024c38a0703809840cd0c9ef9e38a4b2613c8)), closes [#6743](https://github.com/SAP/ui5-webcomponents/issues/6743)
27
+
28
+
29
+
30
+
31
+
6
32
  ## [2.1.1](https://github.com/SAP/ui5-webcomponents/compare/v2.1.0...v2.1.1) (2024-08-02)
7
33
 
8
34
  **Note:** Version bump only for package @ui5/webcomponents-base
@@ -0,0 +1,83 @@
1
+ import "../../test/test-elements/Accessor.js";
2
+
3
+ describe("Framework boot", () => {
4
+ it("Setting property updates attribute, state and DOM", () => {
5
+ cy.mount(`<ui5-test-accessor></ui5-test-accessor>`);
6
+
7
+ cy.get("[ui5-test-accessor]")
8
+ .as("testAccessor")
9
+ .invoke("prop", "myProp", true);
10
+
11
+ cy.get("@testAccessor")
12
+ .should("have.attr", "my-prop");
13
+
14
+ cy.get("@testAccessor")
15
+ .shadow()
16
+ .find("div")
17
+ .should("have.text", "true");
18
+
19
+ cy.get("@testAccessor")
20
+ .invoke("prop", "storage")
21
+ .should("be.true");
22
+
23
+ cy.get("[ui5-test-accessor]")
24
+ .as("testAccessor")
25
+ .invoke("prop", "myProp", false);
26
+
27
+ cy.get("@testAccessor")
28
+ .should("not.have.attr", "my-prop");
29
+
30
+ cy.get("@testAccessor")
31
+ .shadow()
32
+ .find("div")
33
+ .should("have.text", "false");
34
+
35
+ cy.get("@testAccessor")
36
+ .invoke("prop", "storage")
37
+ .should("be.false");
38
+ });
39
+
40
+ it("Setting attribute updates property, state and DOM", () => {
41
+ cy.mount(`<ui5-test-accessor></ui5-test-accessor>`);
42
+
43
+ cy.get("[ui5-test-accessor]")
44
+ .as("testAccessor")
45
+ .invoke("attr", "my-prop", "");
46
+
47
+ cy.get("@testAccessor")
48
+ .should("have.attr", "my-prop");
49
+
50
+ cy.get("@testAccessor")
51
+ .shadow()
52
+ .find("div")
53
+ .should("have.text", "true");
54
+
55
+ cy.get("@testAccessor")
56
+ .invoke("prop", "storage")
57
+ .should("be.true");
58
+
59
+ cy.get("[ui5-test-accessor]")
60
+ .as("testAccessor")
61
+ .invoke("removeAttr", "my-prop");
62
+
63
+ cy.get("@testAccessor")
64
+ .should("not.have.attr", "my-prop");
65
+
66
+ cy.get("@testAccessor")
67
+ .shadow()
68
+ .find("div")
69
+ .should("have.text", "false");
70
+
71
+ cy.get("@testAccessor")
72
+ .invoke("prop", "storage")
73
+ .should("be.false");
74
+ });
75
+
76
+ it("should stop searching for accessors when HTMLElement is reached", () => {
77
+ cy.mount(`<ui5-test-accessor></ui5-test-accessor>`);
78
+
79
+ cy.get("[ui5-test-accessor]")
80
+ .invoke("prop", "title")
81
+ .should("be.undefined");
82
+ });
83
+ });
@@ -0,0 +1,23 @@
1
+ import { registerThemePropertiesLoader } from "../../src/AssetRegistry.js";
2
+ import { boot } from "../../src/Boot.js";
3
+ import { hasStyle } from "../../src/ManagedStyles.js";
4
+
5
+ describe("Framework boot", () => {
6
+ it("Tests theme loading, when registered after 'attachBoot' and 'boot'", () => {
7
+ cy.wrap({ boot })
8
+ .invoke("boot");
9
+
10
+ cy.wrap({ registerThemePropertiesLoader })
11
+ .invoke("registerThemePropertiesLoader", "@ui5/webcomponents-theming", "sap_horizon", () => {
12
+ return Promise.resolve({
13
+ content: `:root{ --customCol: #fff; --customBg: #000; }`,
14
+ packageName: "",
15
+ fileName: "",
16
+ });
17
+ });
18
+
19
+ cy.wrap({ hasStyle })
20
+ .invoke("hasStyle", "data-ui5-theme-properties", "@ui5/webcomponents-theming")
21
+ .should("be.true");
22
+ });
23
+ });
@@ -0,0 +1,41 @@
1
+ import "../../test/test-elements/Accessor.js";
2
+ import { setTheme, getTheme } from "../../src/config/Theme.js";
3
+ import { setThemeRoot, getThemeRoot } from "../../src/config/ThemeRoot.js";
4
+ import { setNoConflict, getNoConflict } from "../../src/config/NoConflict.js";
5
+
6
+ describe("Some configuration options can be changed at runtime", () => {
7
+ it("Tests that theme can be changed", () => {
8
+ const newTheme = "sap_horizon_hcb";
9
+
10
+ cy.wrap({ setTheme })
11
+ .invoke("setTheme", newTheme);
12
+
13
+ cy.wrap({ getTheme })
14
+ .invoke("getTheme")
15
+ .should("equal", newTheme);
16
+ });
17
+
18
+ it("Tests that noConflict can be changed", () => {
19
+ const noConflictObject = { events: ["selection-change"] };
20
+
21
+ cy.wrap({ setNoConflict })
22
+ .invoke("setNoConflict", noConflictObject);
23
+
24
+ cy.wrap({ getNoConflict })
25
+ .invoke("getNoConflict")
26
+ .should("deep.equal", noConflictObject)
27
+ .its("events")
28
+ .should("deep.equal", noConflictObject.events);
29
+ });
30
+
31
+ it("Tests that theme root is applied", () => {
32
+ const newThemeRoot = "https://example.com/";
33
+
34
+ cy.wrap({ setThemeRoot })
35
+ .invoke("setThemeRoot", newThemeRoot);
36
+
37
+ cy.wrap({ getThemeRoot })
38
+ .invoke("getThemeRoot")
39
+ .should("deep.equal", newThemeRoot);
40
+ });
41
+ });
@@ -0,0 +1,116 @@
1
+ import { getAnimationMode } from "../../src/config/AnimationMode.js";
2
+ import { getCalendarType } from "../../src/config/CalendarType.js";
3
+ import { getDefaultFontLoading } from "../../src/config/Fonts.js";
4
+ import { getFirstDayOfWeek, getLegacyDateCalendarCustomizing } from "../../src/config/FormatSettings.js";
5
+ import { getLanguage } from "../../src/config/Language.js";
6
+ import { getNoConflict } from "../../src/config/NoConflict.js";
7
+ import { getTheme } from "../../src/config/Theme.js";
8
+ import { getEnableDefaultTooltips } from "../../src/config/Tooltips.js";
9
+ import { resetConfiguration } from "../../src/InitialConfiguration.js";
10
+
11
+ describe("Configuration script", () => {
12
+ const configurationObject = {
13
+ "theme": "sap_horizon_hcb",
14
+ "animationMode": "basic",
15
+ "rtl": true,
16
+ "language": "ja",
17
+ "calendarType": "Japanese",
18
+ "formatSettings": {
19
+ "firstDayOfWeek": 0,
20
+ "legacyDateCalendarCustomizing": [
21
+ {
22
+ "dateFormat": "A",
23
+ "islamicMonthStart": "14351201",
24
+ "gregDate": "20140925",
25
+ },
26
+ {
27
+ "dateFormat": "A",
28
+ "islamicMonthStart": "14360101",
29
+ "gregDate": "20141024",
30
+ },
31
+ {
32
+ "dateFormat": "A",
33
+ "islamicMonthStart": "14360201",
34
+ "gregDate": "20141123",
35
+ },
36
+ ],
37
+ },
38
+ "noConflict": {
39
+ "events": ["selection-change", "header-click"],
40
+ },
41
+ "defaultFontLoading": false,
42
+ "enableDefaultTooltips": false,
43
+ };
44
+
45
+ before(() => {
46
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`, {
47
+ ui5Configuration: configurationObject,
48
+ });
49
+
50
+ cy.wrap({ resetConfiguration })
51
+ .invoke("resetConfiguration", true);
52
+
53
+ cy.get("script[data-ui5-config]")
54
+ .should("exist")
55
+ .then($el => {
56
+ return $el.get(0).innerHTML;
57
+ })
58
+ .should("equal", JSON.stringify(configurationObject));
59
+ });
60
+
61
+ it("getLanguage", () => {
62
+ cy.wrap({ getLanguage })
63
+ .invoke("getLanguage")
64
+ .should("equal", configurationObject.language);
65
+ });
66
+
67
+ it("getCalendarType", () => {
68
+ cy.wrap({ getCalendarType })
69
+ .invoke("getCalendarType")
70
+ .should("equal", configurationObject.calendarType);
71
+ });
72
+
73
+ it("getFirstDayOfWeek", () => {
74
+ cy.wrap({ getFirstDayOfWeek })
75
+ .invoke("getFirstDayOfWeek")
76
+ .should("equal", configurationObject.formatSettings.firstDayOfWeek);
77
+ });
78
+
79
+ it("getLegacyDateCalendarCustomizing", () => {
80
+ cy.wrap({ getLegacyDateCalendarCustomizing })
81
+ .invoke("getLegacyDateCalendarCustomizing")
82
+ .should("deep.equal", configurationObject.formatSettings.legacyDateCalendarCustomizing);
83
+ });
84
+
85
+ it("getAnimationMode", () => {
86
+ cy.wrap({ getAnimationMode })
87
+ .invoke("getAnimationMode")
88
+ .should("equal", configurationObject.animationMode);
89
+ });
90
+
91
+ it("getEnableDefaultTooltips", () => {
92
+ cy.wrap({ getTheme })
93
+ .invoke("getTheme")
94
+ .should("equal", configurationObject.theme);
95
+ });
96
+
97
+ it("getNoConflict", () => {
98
+ cy.wrap({ getNoConflict })
99
+ .invoke("getNoConflict")
100
+ .should("deep.equal", configurationObject.noConflict)
101
+ .its("events")
102
+ .should("deep.equal", configurationObject.noConflict.events);
103
+ });
104
+
105
+ it("getDefaultFontLoading", () => {
106
+ cy.wrap({ getDefaultFontLoading })
107
+ .invoke("getDefaultFontLoading")
108
+ .should("equal", false);
109
+ });
110
+
111
+ it("getEnableDefaultTooltips", () => {
112
+ cy.wrap({ getEnableDefaultTooltips })
113
+ .invoke("getEnableDefaultTooltips")
114
+ .should("equal", false);
115
+ });
116
+ });
@@ -0,0 +1,182 @@
1
+ import { internals } from "../../src/Location.js";
2
+ import "../../test/test-elements/Generic.js";
3
+ import { resetConfiguration } from "../../src/InitialConfiguration.js";
4
+ import { getLanguage } from "../../src/config/Language.js";
5
+ import { getCalendarType } from "../../src/config/CalendarType.js";
6
+ import { getTheme } from "../../src/config/Theme.js";
7
+ import { getAnimationMode } from "../../src/config/AnimationMode.js";
8
+ import { getThemeRoot } from "../../src/config/ThemeRoot.js";
9
+
10
+ describe("Some settings can be set via SAP UI URL params", () => {
11
+ before(() => {
12
+ const searchParams = "sap-ui-rtl=true&sap-ui-language=ja&sap-ui-calendarType=Japanese&sap-ui-theme=sap_horizon_hcb&sap-ui-animationMode=basic";
13
+
14
+ cy.stub(internals, "search", () => {
15
+ return searchParams;
16
+ });
17
+
18
+ cy.then(() => {
19
+ return resetConfiguration(true);
20
+ });
21
+
22
+ cy.wrap(internals)
23
+ .invoke("search")
24
+ .should("be.equal", searchParams);
25
+
26
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
27
+ });
28
+
29
+ it("Tests that language is applied", () => {
30
+ cy.wrap({ getLanguage })
31
+ .invoke("getLanguage")
32
+ .should("equal", "ja");
33
+ });
34
+
35
+ it("Tests that calendarType is applied", () => {
36
+ cy.wrap({ getCalendarType })
37
+ .invoke("getCalendarType")
38
+ .should("equal", "Japanese");
39
+ });
40
+
41
+ it("Tests that theme is applied", () => {
42
+ cy.wrap({ getTheme })
43
+ .invoke("getTheme")
44
+ .should("equal", "sap_horizon_hcb");
45
+ });
46
+
47
+ it("Tests that animationMode is applied", () => {
48
+ cy.wrap({ getAnimationMode })
49
+ .invoke("getAnimationMode")
50
+ .should("equal", "basic");
51
+ });
52
+ });
53
+
54
+ describe("Different themeRoot configurations", () => {
55
+ it("Allowed theme root", () => {
56
+ const searchParams = "sap-ui-theme=sap_horizon_hcb@https://example.com";
57
+
58
+ cy.stub(internals, "search", () => {
59
+ return searchParams;
60
+ });
61
+
62
+ cy.wrap({ resetConfiguration })
63
+ .invoke("resetConfiguration", true);
64
+
65
+ cy.wrap(internals)
66
+ .invoke("search")
67
+ .should("be.equal", searchParams);
68
+
69
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
70
+
71
+ cy.wrap({ getThemeRoot })
72
+ .invoke("getThemeRoot")
73
+ .should("equal", "https://example.com/UI5/");
74
+ });
75
+
76
+ it("Unallowed theme root", () => {
77
+ const searchParams = "sap-ui-theme=sap_horizon_hcb@https://another-example.com";
78
+
79
+ cy.stub(internals, "search", () => {
80
+ return searchParams;
81
+ });
82
+
83
+ cy.wrap({ resetConfiguration })
84
+ .invoke("resetConfiguration", true);
85
+
86
+ cy.wrap(internals)
87
+ .invoke("search")
88
+ .should("be.equal", searchParams);
89
+
90
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
91
+
92
+ cy.wrap({ getThemeRoot })
93
+ .invoke("getThemeRoot")
94
+ .should("equal", `${window.location.origin}/UI5/`);
95
+ });
96
+
97
+ it("Relative theme root", () => {
98
+ const searchParams = "sap-ui-theme=sap_horizon_hcb@./test";
99
+
100
+ cy.stub(internals, "search", () => {
101
+ return searchParams;
102
+ });
103
+
104
+ cy.wrap({ resetConfiguration })
105
+ .invoke("resetConfiguration", true);
106
+
107
+ cy.wrap(internals)
108
+ .invoke("search")
109
+ .should("be.equal", searchParams);
110
+
111
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
112
+
113
+ cy.wrap({ getThemeRoot })
114
+ .invoke("getThemeRoot")
115
+ .then(themeRoot => {
116
+ return themeRoot?.endsWith("/test/UI5/");
117
+ })
118
+ .should("be.true");
119
+ });
120
+ });
121
+
122
+ describe("Some settings can be set via SAP URL params", () => {
123
+ before(() => {
124
+ const searchParams = "sap-language=bg&sap-theme=sap_fiori_3_dark";
125
+
126
+ cy.stub(internals, "search", () => {
127
+ return searchParams;
128
+ });
129
+
130
+ cy.wrap({ resetConfiguration })
131
+ .invoke("resetConfiguration", true);
132
+
133
+ cy.wrap(internals)
134
+ .invoke("search")
135
+ .should("be.equal", searchParams);
136
+
137
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
138
+ });
139
+
140
+ it("Tests that language is applied via sap-ui-language", () => {
141
+ cy.wrap({ getLanguage })
142
+ .invoke("getLanguage")
143
+ .should("equal", "bg");
144
+ });
145
+
146
+ it("Tests that theme is applied via sap-ui-theme", () => {
147
+ cy.wrap({ getTheme })
148
+ .invoke("getTheme")
149
+ .should("equal", "sap_fiori_3_dark");
150
+ });
151
+ });
152
+
153
+ describe("Some settings can be set via SAP UI URL params", () => {
154
+ before(() => {
155
+ const searchParams = "sap-language=bg&sap-ui-language=de&sap-theme=sap_fiori_3_dark&sap-theme=sap_fiori_3_hcb";
156
+
157
+ cy.stub(internals, "search", () => {
158
+ return searchParams;
159
+ });
160
+
161
+ cy.wrap({ resetConfiguration })
162
+ .invoke("resetConfiguration", true);
163
+
164
+ cy.wrap(internals)
165
+ .invoke("search")
166
+ .should("be.equal", searchParams);
167
+
168
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
169
+ });
170
+
171
+ it("Tests that language is applied via sap-ui-language", () => {
172
+ cy.wrap({ getLanguage })
173
+ .invoke("getLanguage")
174
+ .should("equal", "de");
175
+ });
176
+
177
+ it("Tests that theme is applied via sap-ui-theme", () => {
178
+ cy.wrap({ getTheme })
179
+ .invoke("getTheme")
180
+ .should("equal", "sap_fiori_3_hcb");
181
+ });
182
+ });
@@ -0,0 +1,34 @@
1
+ import { getAnimationMode } from "../../src/config/AnimationMode.js";
2
+
3
+ describe("Custom mount", () => {
4
+ it("mount", () => {
5
+ cy.mount(`<button>Test</button>`);
6
+
7
+ cy.get("button")
8
+ .should("exist")
9
+ .and("have.text", "Test");
10
+ });
11
+
12
+ it("mount with configuration", () => {
13
+ const configurationObject = { "animationMode": "basic" };
14
+
15
+ cy.mount(`<button>Test with configuration</button>`, {
16
+ ui5Configuration: configurationObject,
17
+ });
18
+
19
+ cy.get("button")
20
+ .should("exist")
21
+ .and("have.text", "Test with configuration");
22
+
23
+ cy.get("script[data-ui5-config]")
24
+ .should("exist")
25
+ .then($el => {
26
+ return $el.get(0).innerHTML;
27
+ })
28
+ .should("equal", JSON.stringify(configurationObject));
29
+
30
+ cy.wrap({ getAnimationMode })
31
+ .invoke("getAnimationMode")
32
+ .should("equal", configurationObject.animationMode);
33
+ });
34
+ });
@@ -0,0 +1,36 @@
1
+ import { registerThemePropertiesLoader } from "../../src/AssetRegistry.js";
2
+ import { setTheme } from "../../src/config/Theme.js";
3
+ import { getCurrentRuntimeIndex } from "../../src/Runtimes.js";
4
+ import "../../test/test-elements/Generic.js";
5
+
6
+ describe("Custom themes can be registered", () => {
7
+ it("Tests that theme parameters are changed on theme change", () => {
8
+ const newTheme = "my_custom_theme";
9
+ const var1 = "--var1: #555555";
10
+ const currentRuntime = 0;
11
+ const dataPropAttr = `data-ui5-component-properties-${currentRuntime}`;
12
+
13
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
14
+
15
+ cy.wrap({ getCurrentRuntimeIndex })
16
+ .invoke("getCurrentRuntimeIndex")
17
+ .should("equal", currentRuntime);
18
+
19
+ cy.wrap({ registerThemePropertiesLoader })
20
+ .invoke("registerThemePropertiesLoader", "@ui5/webcomponents-base-test", newTheme, () => Promise.resolve(`:root{ ${var1}; }`));
21
+
22
+ cy.wrap({ setTheme })
23
+ .invoke("setTheme", newTheme);
24
+
25
+ cy.document()
26
+ .its("adoptedStyleSheets")
27
+ .then(adoptedStyleSheets => {
28
+ // eslint-disable-next-line
29
+ return adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === `${dataPropAttr}|@ui5/webcomponents-base-test`);
30
+ })
31
+ .its("cssRules")
32
+ .its(0)
33
+ .its("cssText")
34
+ .should("include", var1);
35
+ });
36
+ });
@@ -0,0 +1,59 @@
1
+ import EventProvider from "../../src/EventProvider.js";
2
+
3
+ describe("Event provider attaches and detaches listeners properly", () => {
4
+ it("Tests that listeners can be removed (1 listener)", () => {
5
+ let timesCalled = 0;
6
+
7
+ cy.then(() => {
8
+ const ep = new EventProvider();
9
+ const callback = () => {
10
+ timesCalled++;
11
+ };
12
+
13
+ // Setup
14
+ ep.attachEvent("test", callback);
15
+
16
+ // Act
17
+ ep.fireEvent("test", undefined); // should execute the callback and increase the counter
18
+
19
+ // Setup
20
+ ep.detachEvent("test", callback);
21
+
22
+ // Act
23
+ ep.fireEvent("test", undefined); // should not execute the callback and increase the counter
24
+ })
25
+ .then(() => {
26
+ return timesCalled;
27
+ })
28
+ .should("equal", 1);
29
+ });
30
+
31
+ it("Tests that listeners can be removed (more than 1 listener)", () => {
32
+ let timesCalled = 0;
33
+
34
+ cy.then(() => {
35
+ const ep = new EventProvider();
36
+ const callback = () => {
37
+ timesCalled++;
38
+ };
39
+ const somePreviousCallback = () => { };
40
+
41
+ // Setup
42
+ ep.attachEvent("test", somePreviousCallback); // Attach something so that after detachEvent the listeners array is not empty!
43
+ ep.attachEvent("test", callback);
44
+
45
+ // Act
46
+ ep.fireEvent("test", undefined); // should execute the callback and increase the counter
47
+
48
+ // Setup
49
+ ep.detachEvent("test", callback);
50
+
51
+ // Act
52
+ ep.fireEvent("test", undefined); // should not execute the callback and increase the counter
53
+ })
54
+ .then(() => {
55
+ return timesCalled;
56
+ })
57
+ .should("equal", 1);
58
+ });
59
+ });
@@ -0,0 +1,8 @@
1
+ import "../../test/test-elements/Accessor.js";
2
+
3
+ describe("Shared Resources", () => {
4
+ it("Tests the presense of the shared resources 'meta' element", () => {
5
+ cy.get(`meta[name="ui5-shared-resources"]`)
6
+ .should("exist");
7
+ });
8
+ });