@ui5/webcomponents-base 2.1.0 → 2.2.0-rc.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 (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 +10 -0
  28. package/dist/Location.js +43 -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 +4 -4
  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
@@ -0,0 +1,74 @@
1
+ import { setTheme } from "../../src/config/Theme.js";
2
+ import { getCurrentRuntimeIndex } from "../../src/Runtimes.js";
3
+ import "../../test/test-elements/Accessor.js";
4
+ import "../../test/assets/Themes.js";
5
+
6
+ describe("Theming works", () => {
7
+ it("Tests that the parameters for the default theme are embedded on boot", () => {
8
+ const currentRuntime = 0;
9
+ const dataPropAttr = `data-ui5-component-properties-${currentRuntime}`;
10
+
11
+ cy.wrap({ getCurrentRuntimeIndex })
12
+ .invoke("getCurrentRuntimeIndex")
13
+ .should("equal", currentRuntime);
14
+
15
+ cy.document()
16
+ .its("adoptedStyleSheets")
17
+ .then(adoptedStyleSheets => {
18
+ // eslint-disable-next-line
19
+ return adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === `${dataPropAttr}|@ui5/webcomponents-base-test`);
20
+ })
21
+ .its("cssRules")
22
+ .its(0)
23
+ .its("cssText")
24
+ .should("include", "--var1: grey");
25
+ });
26
+
27
+ it("Tests that the parameters for the default theme are embedded on boot", () => {
28
+ const newTheme = "sap_fiori_3_hcb";
29
+ const currentRuntime = 0;
30
+ const dataPropAttr = `data-ui5-component-properties-${currentRuntime}`;
31
+
32
+ cy.wrap({ getCurrentRuntimeIndex })
33
+ .invoke("getCurrentRuntimeIndex")
34
+ .should("equal", currentRuntime);
35
+
36
+ cy.wrap({ setTheme })
37
+ .invoke("setTheme", newTheme);
38
+
39
+ cy.document()
40
+ .its("adoptedStyleSheets")
41
+ .then(adoptedStyleSheets => {
42
+ // eslint-disable-next-line
43
+ return adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === `${dataPropAttr}|@ui5/webcomponents-base-test`);
44
+ })
45
+ .its("cssRules")
46
+ .its(0)
47
+ .its("cssText")
48
+ .should("include", "--var1: yellow");
49
+ });
50
+
51
+ it("Tests that the parameters for the default theme are embedded on boot", () => {
52
+ const unknownTheme = "sap_unknown_theme";
53
+ const currentRuntime = 0;
54
+ const dataPropAttr = `data-ui5-component-properties-${currentRuntime}`;
55
+
56
+ cy.wrap({ getCurrentRuntimeIndex })
57
+ .invoke("getCurrentRuntimeIndex")
58
+ .should("equal", currentRuntime);
59
+
60
+ cy.wrap({ setTheme })
61
+ .invoke("setTheme", unknownTheme);
62
+
63
+ cy.document()
64
+ .its("adoptedStyleSheets")
65
+ .then(adoptedStyleSheets => {
66
+ // eslint-disable-next-line
67
+ return adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === `${dataPropAttr}|@ui5/webcomponents-base-test`);
68
+ })
69
+ .its("cssRules")
70
+ .its(0)
71
+ .its("cssText")
72
+ .should("include", "--var1: grey");
73
+ });
74
+ });
@@ -0,0 +1,207 @@
1
+ import type UI5Element from "../../src/UI5Element.js";
2
+ import "../../test/test-elements/Generic.js";
3
+
4
+ describe("Invalidation works", () => {
5
+ it("Tests that changing a property invalidates", () => {
6
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
7
+
8
+ cy.get("[ui5-test-generic]")
9
+ .as("testGeneric")
10
+ .then(el => {
11
+ cy.spy<UI5Element>((el.get(0) as UI5Element), "onInvalidation").as("invalidations");
12
+ });
13
+
14
+ cy.get("@testGeneric")
15
+ .invoke("prop", "strProp", "new value");
16
+
17
+ cy.get("@testGeneric")
18
+ .invoke("prop", "boolProp", true);
19
+
20
+ cy.get("@invalidations")
21
+ .should("have.been.calledTwice");
22
+ });
23
+
24
+ it("Tests that setting a property to the same value does not invalidate", () => {
25
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
26
+
27
+ const text = "new value";
28
+
29
+ cy.get("[ui5-test-generic]")
30
+ .as("testGeneric")
31
+ .invoke("prop", "strProp", text)
32
+ .then(el => {
33
+ cy.spy<UI5Element>((el.get(0) as UI5Element), "onInvalidation").as("invalidations");
34
+ });
35
+
36
+ cy.get("@testGeneric")
37
+ .invoke("prop", "strProp", text);
38
+
39
+ cy.get("@invalidations")
40
+ .should("have.not.been.called");
41
+ });
42
+
43
+ it("Tests that setting a property of type Object always invalidates", () => {
44
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
45
+
46
+ const obj = {};
47
+ const otherObj = {};
48
+
49
+ cy.get("[ui5-test-generic]")
50
+ .as("testGeneric")
51
+ .invoke("prop", "objectProp", obj)
52
+ .then(el => {
53
+ cy.spy<UI5Element>((el.get(0) as UI5Element), "onInvalidation").as("invalidations");
54
+ });
55
+
56
+ cy.get("@testGeneric")
57
+ .invoke("prop", "objectProp", otherObj);
58
+
59
+ cy.get("@invalidations")
60
+ .should("have.been.calledOnce");
61
+ });
62
+
63
+ it("Tests that setting an array property always invalidates", () => {
64
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
65
+
66
+ const arr: Array<string> = [];
67
+ const otherArr: Array<string> = [];
68
+
69
+ cy.get("[ui5-test-generic]")
70
+ .as("testGeneric")
71
+ .invoke("prop", "multiProp", arr)
72
+ .then(el => {
73
+ cy.spy<UI5Element>((el.get(0) as UI5Element), "onInvalidation").as("invalidations");
74
+ });
75
+
76
+ cy.get("@testGeneric")
77
+ .invoke("prop", "multiProp", otherArr);
78
+
79
+ cy.get("@invalidations")
80
+ .should("have.been.calledOnce");
81
+ });
82
+
83
+ it("Tests that adding a child invalidates", () => {
84
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
85
+
86
+ cy.get("[ui5-test-generic]")
87
+ .as("testGeneric")
88
+ .then(el => {
89
+ cy.spy<UI5Element>((el.get(0) as UI5Element), "onInvalidation").as("invalidations");
90
+ });
91
+
92
+ cy.get("@testGeneric")
93
+ .then($testGeneric => {
94
+ const div = document.createElement("div");
95
+ $testGeneric.append(div);
96
+ });
97
+
98
+ cy.get("@invalidations")
99
+ .should("have.been.called");
100
+ });
101
+
102
+ it("Tests that removing a child invalidates", () => {
103
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
104
+
105
+ const div = document.createElement("div");
106
+
107
+ cy.get("[ui5-test-generic]")
108
+ .as("testGeneric")
109
+ .then($testGeneric => {
110
+ $testGeneric.append(div);
111
+
112
+ return $testGeneric;
113
+ })
114
+ .then($testGeneric => {
115
+ cy.spy<UI5Element>(($testGeneric.get(0) as UI5Element), "onInvalidation").as("invalidations");
116
+ });
117
+
118
+ cy.get("@invalidations")
119
+ .should("have.not.been.called");
120
+
121
+ cy.wrap(div)
122
+ .then($div => {
123
+ $div.remove();
124
+ });
125
+
126
+ cy.get("@invalidations")
127
+ .should("have.been.called");
128
+ });
129
+
130
+ it("Tests that modifying textContent invalidates", () => {
131
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
132
+
133
+ cy.get("[ui5-test-generic]")
134
+ .as("testGeneric")
135
+ .then($testGeneric => {
136
+ $testGeneric.text("test");
137
+
138
+ return $testGeneric;
139
+ })
140
+ .then($testGeneric => {
141
+ cy.spy<UI5Element>(($testGeneric.get(0) as UI5Element), "onInvalidation").as("invalidations");
142
+ });
143
+
144
+ cy.get("@invalidations")
145
+ .should("have.not.been.called");
146
+
147
+ cy.get("@testGeneric")
148
+ .then($testGeneric => {
149
+ $testGeneric.text("test2");
150
+ });
151
+
152
+ cy.get("@invalidations")
153
+ .should("have.been.called");
154
+ });
155
+
156
+ it("Tests that modifying nodeValue invalidates", () => {
157
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
158
+
159
+ cy.get("[ui5-test-generic]")
160
+ .as("testGeneric")
161
+ .then($testGeneric => {
162
+ $testGeneric.text("test");
163
+
164
+ return $testGeneric;
165
+ })
166
+ .then($testGeneric => {
167
+ cy.spy<UI5Element>(($testGeneric.get(0) as UI5Element), "onInvalidation").as("invalidations");
168
+ });
169
+
170
+ cy.get("@invalidations")
171
+ .should("have.not.been.called");
172
+
173
+ cy.get("@testGeneric")
174
+ .then($testGeneric => {
175
+ $testGeneric.get(0).childNodes[0].nodeValue = "test2";
176
+ });
177
+
178
+ cy.get("@invalidations")
179
+ .should("have.been.called");
180
+ });
181
+
182
+ it("Tests that multiple invalidations result in a single rendering", () => {
183
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
184
+
185
+ cy.get("[ui5-test-generic]")
186
+ .as("testGeneric");
187
+
188
+ cy.get("@testGeneric")
189
+ .then($testGeneric => {
190
+ cy.spy<UI5Element>(($testGeneric.get(0) as UI5Element), "onInvalidation").as("invalidations");
191
+
192
+ cy.spy<UI5Element>(($testGeneric.get(0) as UI5Element), "_render").as("rendering");
193
+ });
194
+
195
+ cy.get("@testGeneric")
196
+ .invoke("prop", "strProp", "new");
197
+
198
+ cy.get("@testGeneric")
199
+ .invoke("prop", "strProp", "new2");
200
+
201
+ cy.get("@invalidations")
202
+ .should("have.been.calledTwice");
203
+
204
+ cy.get("@rendering")
205
+ .should("have.been.calledOnce");
206
+ });
207
+ });
@@ -0,0 +1,82 @@
1
+ import type UI5Element from "../../src/UI5Element.js";
2
+ import "../../test/test-elements/Generic.js";
3
+
4
+ describe("Lifecycle works", () => {
5
+ it("Tests that changing a property invalidates", () => {
6
+ const el = document.createElement("ui5-test-generic");
7
+
8
+ cy.mount(`<div id="container"></div>`);
9
+
10
+ cy.spy<UI5Element>((el as UI5Element), "onBeforeRendering").as("onBeforeRendering");
11
+
12
+ cy.spy<UI5Element>((el as UI5Element), "onAfterRendering").as("onAfterRendering");
13
+
14
+ cy.spy<UI5Element>((el as UI5Element), "onEnterDOM").as("onEnterDOM");
15
+
16
+ cy.get("#container")
17
+ .then($container => {
18
+ $container.append(el);
19
+ });
20
+
21
+ cy.get("@onBeforeRendering")
22
+ .should("have.been.called")
23
+ .and("have.been.calledBefore", "@onAfterRendering")
24
+ .and("have.been.calledBefore", "@onEnterDOM");
25
+
26
+ cy.get("@onAfterRendering")
27
+ .should("have.been.called")
28
+ .and("have.been.calledBefore", "@onEnterDOM");
29
+
30
+ cy.get("@onEnterDOM")
31
+ .should("have.been.called");
32
+ });
33
+
34
+ it("Tests element invalidation callbacks", () => {
35
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
36
+
37
+ cy.get("[ui5-test-generic]")
38
+ .as("testGeneric")
39
+ .then($testGeneric => {
40
+ cy.spy<UI5Element>(($testGeneric.get(0) as UI5Element), "onBeforeRendering").as("onBeforeRendering");
41
+
42
+ cy.spy<UI5Element>(($testGeneric.get(0) as UI5Element), "onAfterRendering").as("onAfterRendering");
43
+ });
44
+
45
+ cy.get("@testGeneric")
46
+ .invoke("prop", "strProp", "some string");
47
+
48
+ cy.get("@onBeforeRendering")
49
+ .should("have.been.called")
50
+ .and("have.been.calledBefore", "@onAfterRendering");
51
+
52
+ cy.get("@onAfterRendering")
53
+ .should("have.been.called");
54
+ });
55
+
56
+ it("Tests element destruction callback", () => {
57
+ const el = document.createElement("ui5-test-generic");
58
+
59
+ cy.mount(`<div id="container"></div>`);
60
+
61
+ cy.spy<UI5Element>((el as UI5Element), "onExitDOM").as("onExitDOM");
62
+ cy.spy<UI5Element>((el as UI5Element), "onEnterDOM").as("onEnterDOM");
63
+
64
+ cy.get("#container")
65
+ .then($container => {
66
+ $container.append(el);
67
+
68
+ return $container;
69
+ });
70
+
71
+ cy.get("@onEnterDOM")
72
+ .should("have.been.called");
73
+
74
+ cy.wrap(el)
75
+ .then($el => {
76
+ $el.remove();
77
+ });
78
+
79
+ cy.get("@onExitDOM")
80
+ .should("have.been.called");
81
+ });
82
+ });
@@ -0,0 +1,62 @@
1
+ import type UI5Element from "../../src/UI5Element.js";
2
+
3
+ import "../../test/test-elements/Parent.js";
4
+ import "../../test/test-elements/Child.js";
5
+
6
+ describe("Invalidation works", () => {
7
+ it("Tests that changing a monitored property of a child invalidates the parent", () => {
8
+ cy.mount(`<ui5-test-parent>
9
+ <ui5-test-child></ui5-test-child>
10
+ </ui5-test-parent>`);
11
+
12
+ cy.get("[ui5-test-parent]")
13
+ .as("testParent")
14
+ .then(el => {
15
+ cy.spy<UI5Element>((el.get(0) as UI5Element), "onInvalidation").as("invalidations");
16
+ });
17
+
18
+ cy.get("[ui5-test-child]")
19
+ .invoke("prop", "prop1", "a");
20
+
21
+ cy.get("@invalidations")
22
+ .should("have.been.called");
23
+ });
24
+
25
+ it("Tests that changing a non-monitored property of a child does not invalidate the parent", () => {
26
+ cy.mount(`<ui5-test-parent>
27
+ <ui5-test-child></ui5-test-child>
28
+ </ui5-test-parent>`);
29
+
30
+ cy.get("[ui5-test-parent]")
31
+ .as("testParent")
32
+ .then(el => {
33
+ cy.spy<UI5Element>((el.get(0) as UI5Element), "onInvalidation").as("invalidations");
34
+ });
35
+
36
+ cy.get("[ui5-test-child]")
37
+ .invoke("prop", "prop2", "b");
38
+
39
+ cy.get("@invalidations")
40
+ .should("have.not.been.called");
41
+ });
42
+
43
+ it("Tests that changing a non-monitored property of a child does not invalidate the parent", () => {
44
+ cy.mount(`<ui5-test-parent>
45
+ <ui5-test-child slot="items"></ui5-test-child>
46
+ </ui5-test-parent>`);
47
+
48
+ cy.get("[ui5-test-parent]")
49
+ .as("testParent")
50
+ .then(el => {
51
+ cy.spy<UI5Element>((el.get(0) as UI5Element), "onInvalidation").as("invalidations");
52
+ });
53
+
54
+ cy.get("[ui5-test-child]")
55
+ .invoke("prop", "prop1", "a")
56
+ .invoke("prop", "prop2", "b")
57
+ .invoke("prop", "prop3", "c");
58
+
59
+ cy.get("@invalidations")
60
+ .should("have.been.calledThrice");
61
+ });
62
+ });
@@ -0,0 +1,42 @@
1
+ import type UI5Element from "../../src/UI5Element.js";
2
+ import "../../test/test-elements/GenericExt.js";
3
+
4
+ describe("Invalidation works", () => {
5
+ it("Tests that changing a monitored property of a child invalidates the parent", () => {
6
+ cy.mount(`<ui5-test-generic-ext></ui5-test-generic-ext>`);
7
+
8
+ cy.get("[ui5-test-generic-ext]")
9
+ .then($el => {
10
+ return ($el.get(0).constructor as typeof UI5Element).getMetadata();
11
+ })
12
+ .as("metadata");
13
+
14
+ cy.get("@metadata")
15
+ .invoke("getProperties")
16
+ .its("strProp")
17
+ .should("exist");
18
+
19
+ cy.get("@metadata")
20
+ .invoke("getProperties")
21
+ .its("extProp")
22
+ .should("exist");
23
+
24
+ cy.get("@metadata")
25
+ .invoke("getSlots")
26
+ .its("default")
27
+ .should("exist");
28
+
29
+ cy.get("@metadata")
30
+ .invoke("getSlots")
31
+ .its("extSlot")
32
+ .should("exist");
33
+ });
34
+
35
+ it("When extending metadata, property defaultValue can be modified", () => {
36
+ cy.mount(`<ui5-test-generic-ext></ui5-test-generic-ext>`);
37
+
38
+ cy.get("[ui5-test-generic-ext]")
39
+ .invoke("attr", "str-prop")
40
+ .should("equal", "Ext");
41
+ });
42
+ });
@@ -0,0 +1,17 @@
1
+ import "../../test/test-elements/Generic.js";
2
+
3
+ describe("Properties can only have values, restricted to their types", () => {
4
+ it("String property enforced to string", () => {
5
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
6
+
7
+ cy.get("[ui5-test-generic]")
8
+ .as("testGeneric");
9
+
10
+ cy.get("@testGeneric")
11
+ .invoke("prop", "strProp", 5);
12
+
13
+ cy.get("@testGeneric")
14
+ .invoke("prop", "strProp")
15
+ .should("equal", 5);
16
+ });
17
+ });
@@ -0,0 +1,113 @@
1
+ import "../../test/test-elements/Generic.js";
2
+
3
+ describe("Properties and attributes convert to each other", () => {
4
+ it("Tests that properties with default values are initialized with the default value", () => {
5
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
6
+
7
+ cy.get("[ui5-test-generic]")
8
+ .as("testGeneric");
9
+
10
+ cy.get("@testGeneric")
11
+ .invoke("prop", "defaultValueProp")
12
+ .should("equal", "Hello");
13
+ });
14
+
15
+ it("Tests that prop-attr conversion works for string properties", () => {
16
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
17
+
18
+ cy.get("[ui5-test-generic]")
19
+ .as("testGeneric");
20
+
21
+ cy.get("@testGeneric")
22
+ .invoke("prop", "strProp", "test1");
23
+
24
+ cy.get("@testGeneric")
25
+ .should("have.attr", "str-prop", "test1");
26
+
27
+ cy.get("@testGeneric")
28
+ .invoke("attr", "str-prop", "test2");
29
+
30
+ cy.get("@testGeneric")
31
+ .invoke("prop", "strProp")
32
+ .should("equal", "test2");
33
+ });
34
+
35
+ it("Tests that prop-attr conversion works for boolean properties", () => {
36
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
37
+
38
+ cy.get("[ui5-test-generic]")
39
+ .as("testGeneric");
40
+
41
+ cy.get("@testGeneric")
42
+ .invoke("prop", "boolProp", true);
43
+
44
+ cy.get("@testGeneric")
45
+ .should("have.attr", "bool-prop");
46
+
47
+ cy.get("@testGeneric")
48
+ .invoke("prop", "boolProp", false);
49
+
50
+ cy.get("@testGeneric")
51
+ .should("not.have.attr", "bool-prop");
52
+
53
+ cy.get("@testGeneric")
54
+ .invoke("attr", "bool-prop", true);
55
+
56
+ cy.get("@testGeneric")
57
+ .invoke("prop", "boolProp")
58
+ .should("be.true");
59
+
60
+ cy.get("@testGeneric")
61
+ .invoke("removeAttr", "bool-prop");
62
+
63
+ cy.get("@testGeneric")
64
+ .invoke("prop", "boolProp")
65
+ .should("be.false");
66
+ });
67
+
68
+ it("Tests that object properties have no attributes", () => {
69
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
70
+
71
+ cy.get("[ui5-test-generic]")
72
+ .as("testGeneric");
73
+
74
+ cy.get("@testGeneric")
75
+ .invoke("prop", "objectProp", {});
76
+
77
+ cy.get("@testGeneric")
78
+ .should("not.have.attr", "object-prop");
79
+ });
80
+
81
+ it("Tests that array properties have no attributes", () => {
82
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
83
+
84
+ cy.get("[ui5-test-generic]")
85
+ .as("testGeneric");
86
+
87
+ cy.get("@testGeneric")
88
+ .invoke("prop", "multiProp", ["a", "b"]);
89
+
90
+ cy.get("@testGeneric")
91
+ .should("not.have.attr", "multi-prop");
92
+ });
93
+
94
+ it("Tests that noAttribute properties have no attributes", () => {
95
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
96
+
97
+ cy.get("[ui5-test-generic]")
98
+ .as("testGeneric");
99
+
100
+ cy.get("@testGeneric")
101
+ .invoke("prop", "noAttributeProp", "some value");
102
+
103
+ cy.get("@testGeneric")
104
+ .should("not.have.attr", "no-attribute-prop");
105
+ });
106
+
107
+ it("Tests that properties with default values do automatically set attributes", () => {
108
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
109
+
110
+ cy.get("[ui5-test-generic]")
111
+ .should("have.attr", "default-value-prop", "Hello");
112
+ });
113
+ });
@@ -0,0 +1,30 @@
1
+ import "../../test/test-elements/Generic.js";
2
+ import "../../test/test-elements/NoShadowDOM.js";
3
+
4
+ describe("The framework can define web components", () => {
5
+ it("Tests that element's Shadow DOM is rendered if it has a template", () => {
6
+ cy.mount(`<ui5-test-generic></ui5-test-generic>`);
7
+
8
+ cy.get("[ui5-test-generic]")
9
+ .as("testGeneric")
10
+ .then($element => {
11
+ return !!$element.get(0).shadowRoot;
12
+ })
13
+ .should("be.true");
14
+
15
+ cy.get("@testGeneric")
16
+ .shadow()
17
+ .find("div > p")
18
+ .should("exist");
19
+ });
20
+
21
+ it("Tests that element's Shadow DOM is not rendered if it has no template", () => {
22
+ cy.mount(`<ui5-test-no-shadow></ui5-test-no-shadow>`);
23
+
24
+ cy.get("[ui5-test-no-shadow]")
25
+ .then($element => {
26
+ return !!$element.get(0).shadowRoot;
27
+ })
28
+ .should("be.false");
29
+ });
30
+ });