@syncfusion/ej2-base 24.2.7 → 25.1.35-579988

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 (163) hide show
  1. package/.eslintrc.json +2 -1
  2. package/CHANGELOG.md +641 -677
  3. package/{README.md → ReadMe.md} +100 -100
  4. package/dist/ej2-base.umd.min.js +1 -10
  5. package/dist/ej2-base.umd.min.js.map +1 -1
  6. package/dist/es6/ej2-base.es2015.js +178 -1025
  7. package/dist/es6/ej2-base.es2015.js.map +1 -1
  8. package/dist/es6/ej2-base.es5.js +226 -934
  9. package/dist/es6/ej2-base.es5.js.map +1 -1
  10. package/dist/global/ej2-base.min.js +1 -10
  11. package/dist/global/ej2-base.min.js.map +1 -1
  12. package/dist/global/index.d.ts +0 -9
  13. package/dist/ts/ajax.ts +236 -0
  14. package/dist/ts/animation.ts +544 -0
  15. package/dist/ts/base.ts +357 -0
  16. package/dist/ts/browser.ts +387 -0
  17. package/dist/ts/child-property.ts +192 -0
  18. package/dist/ts/component.ts +519 -0
  19. package/dist/ts/dom.ts +488 -0
  20. package/dist/ts/draggable.ts +1155 -0
  21. package/dist/ts/droppable.ts +172 -0
  22. package/dist/ts/event-handler.ts +169 -0
  23. package/dist/ts/internationalization.ts +369 -0
  24. package/dist/ts/intl/date-formatter.ts +317 -0
  25. package/dist/ts/intl/date-parser.ts +426 -0
  26. package/dist/ts/intl/intl-base.ts +1104 -0
  27. package/dist/ts/intl/number-formatter.ts +411 -0
  28. package/dist/ts/intl/number-parser.ts +158 -0
  29. package/dist/ts/intl/parser-base.ts +394 -0
  30. package/dist/ts/keyboard.ts +238 -0
  31. package/dist/ts/l10n.ts +94 -0
  32. package/dist/ts/module-loader.ts +149 -0
  33. package/dist/ts/notify-property-change.ts +726 -0
  34. package/dist/ts/observer.ts +236 -0
  35. package/dist/ts/sanitize-helper.ts +224 -0
  36. package/dist/ts/template-engine.ts +191 -0
  37. package/dist/ts/template.ts +329 -0
  38. package/dist/ts/touch.ts +544 -0
  39. package/dist/ts/util.ts +523 -0
  40. package/dist/ts/validate-lic.ts +0 -0
  41. package/e2e/crypto.js +16 -16
  42. package/e2e/m.protractor.config.js +286 -286
  43. package/e2e/modified-protractor/protractor.config.js +316 -316
  44. package/e2e/protractor.config.js +389 -332
  45. package/helpers/e2e/index.js +3 -3
  46. package/license +10 -10
  47. package/package.json +225 -174
  48. package/src/ajax.d.ts +1 -1
  49. package/src/ajax.js +3 -8
  50. package/src/animation-model.d.ts +41 -41
  51. package/src/animation.d.ts +6 -6
  52. package/src/animation.js +25 -25
  53. package/src/base.d.ts +2 -1
  54. package/src/base.js +9 -7
  55. package/src/component-model.d.ts +16 -16
  56. package/src/component.d.ts +9 -3
  57. package/src/component.js +50 -38
  58. package/src/draggable-model.d.ts +113 -113
  59. package/src/draggable.d.ts +2 -0
  60. package/src/draggable.js +45 -29
  61. package/src/droppable-model.d.ts +23 -23
  62. package/src/droppable.js +19 -19
  63. package/src/event-handler.js +2 -1
  64. package/src/index.d.ts +0 -3
  65. package/src/index.js +0 -3
  66. package/src/intl/date-formatter.js +2 -6
  67. package/src/intl/date-parser.js +1 -20
  68. package/src/intl/intl-base.js +1 -164
  69. package/src/intl/number-formatter.d.ts +3 -0
  70. package/src/intl/number-formatter.js +7 -7
  71. package/src/intl/number-parser.js +1 -0
  72. package/src/keyboard-model.d.ts +16 -16
  73. package/src/keyboard.js +19 -19
  74. package/src/module-loader.d.ts +12 -0
  75. package/src/module-loader.js +11 -0
  76. package/src/notify-property-change.js +3 -2
  77. package/src/observer.js +2 -0
  78. package/src/sanitize-helper.js +5 -0
  79. package/src/template-engine.js +1 -0
  80. package/src/template.js +3 -2
  81. package/src/touch-model.d.ts +39 -39
  82. package/src/touch.js +19 -19
  83. package/src/validate-lic.d.ts +0 -11
  84. package/src/validate-lic.js +1 -259
  85. package/styles/_all.scss +2 -2
  86. package/styles/_bds-dark-definition.scss +15 -0
  87. package/styles/_bds-definition.scss +15 -0
  88. package/styles/_bootstrap-dark-definition.scss +42 -42
  89. package/styles/_bootstrap-definition.scss +42 -42
  90. package/styles/_bootstrap4-definition.scss +11 -11
  91. package/styles/_bootstrap5-dark-definition.scss +9 -9
  92. package/styles/_bootstrap5-definition.scss +8 -8
  93. package/styles/_fabric-dark-definition.scss +42 -42
  94. package/styles/_fabric-definition.scss +42 -42
  95. package/styles/_fluent-dark-definition.scss +9 -9
  96. package/styles/_fluent-definition.scss +9 -9
  97. package/styles/_fluent2-definition.scss +9 -0
  98. package/styles/_fusionnew-dark-definition.scss +8 -8
  99. package/styles/_fusionnew-definition.scss +8 -8
  100. package/styles/_highcontrast-definition.scss +42 -42
  101. package/styles/_highcontrast-light-definition.scss +42 -42
  102. package/styles/_material-dark-definition.scss +48 -48
  103. package/styles/_material-definition.scss +49 -49
  104. package/styles/_material3-dark-definition.scss +14 -14
  105. package/styles/_material3-definition.scss +15 -15
  106. package/styles/_tailwind-dark-definition.scss +15 -15
  107. package/styles/_tailwind-definition.scss +15 -15
  108. package/styles/animation/_all.scss +560 -560
  109. package/styles/bootstrap-dark.css +10 -1
  110. package/styles/bootstrap.css +10 -1
  111. package/styles/bootstrap4.css +10 -1
  112. package/styles/bootstrap5-dark.css +10 -1
  113. package/styles/bootstrap5.css +10 -1
  114. package/styles/common/_all.scss +2 -2
  115. package/styles/common/_core.scss +117 -117
  116. package/styles/common/_mixin.scss +9 -9
  117. package/styles/definition/_bds-dark.scss +1179 -0
  118. package/styles/definition/_bds.scss +1474 -0
  119. package/styles/definition/_bootstrap-dark.scss +219 -219
  120. package/styles/definition/_bootstrap.scss +215 -215
  121. package/styles/definition/_bootstrap4.scss +167 -167
  122. package/styles/definition/_bootstrap5-dark.scss +493 -493
  123. package/styles/definition/_bootstrap5.scss +494 -494
  124. package/styles/definition/_fabric-dark.scss +200 -200
  125. package/styles/definition/_fabric.scss +198 -198
  126. package/styles/definition/_fluent-dark.scss +557 -557
  127. package/styles/definition/_fluent.scss +558 -558
  128. package/styles/definition/_fluent2.scss +2198 -0
  129. package/styles/definition/_fusionnew-dark.scss +362 -362
  130. package/styles/definition/_fusionnew.scss +363 -363
  131. package/styles/definition/_highcontrast-light.scss +193 -193
  132. package/styles/definition/_highcontrast.scss +195 -195
  133. package/styles/definition/_material-dark.scss +198 -198
  134. package/styles/definition/_material.scss +192 -192
  135. package/styles/definition/_material3-dark.scss +710 -710
  136. package/styles/definition/_material3.scss +792 -792
  137. package/styles/definition/_tailwind-dark.scss +488 -488
  138. package/styles/definition/_tailwind.scss +485 -485
  139. package/styles/fabric-dark.css +10 -1
  140. package/styles/fabric.css +10 -1
  141. package/styles/fluent-dark.css +10 -1
  142. package/styles/fluent.css +10 -1
  143. package/styles/highcontrast-light.css +10 -1
  144. package/styles/highcontrast.css +10 -1
  145. package/styles/material-dark.css +10 -1
  146. package/styles/material.css +10 -1
  147. package/styles/material3-dark.css +10 -1
  148. package/styles/material3.css +10 -1
  149. package/styles/offline-theme/material-dark.css +10 -1
  150. package/styles/offline-theme/material.css +10 -1
  151. package/styles/offline-theme/tailwind-dark.css +10 -1
  152. package/styles/offline-theme/tailwind.css +10 -1
  153. package/styles/tailwind-dark.css +10 -1
  154. package/styles/tailwind.css +10 -1
  155. package/.github/PULL_REQUEST_TEMPLATE/Bug.md +0 -60
  156. package/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -42
  157. package/bin/syncfusion-license.js +0 -2
  158. package/dist/ej2-base.min.js +0 -10
  159. package/e2e/index.d.ts +0 -27
  160. package/src/fetch.d.ts +0 -114
  161. package/src/fetch.js +0 -116
  162. package/src/hijri-parser.d.ts +0 -19
  163. package/src/hijri-parser.js +0 -204
@@ -1,332 +1,389 @@
1
- var shell = require('shelljs');
2
- var os = require('os');
3
- var camelCase = require('pix-diff/lib/camelCase.js');
4
- var seleniumAddress = 'http://150.107.121.2:4444/wd/hub';
5
- var request = require('request');
6
- var config = require('../../../../config.json');
7
- var RepalceRegex = /"/g;
8
- var isDashBoardReport = config['dashBoardReport'];
9
- var timeCal = {};
10
- var fs = require('fs');
11
- var enableW3c = '{W3cdisabled}';
12
- var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
13
- var reporter = new HtmlScreenshotReporter({
14
- dest: 'e2e_report/' + config.browsers[0],
15
- filename: config.browsers[0] + '.html'
16
- });
17
- isDashBoardReport = isDashBoardReport === undefined ? true : isDashBoardReport;
18
- if (isDashBoardReport) {
19
- var currentRepo = shell.exec('git config --get remote.origin.url', {
20
- silent: true
21
- })
22
- .stdout.split('essential-studio/')[1].replace('.git', '').replace('/', '').trim();
23
- var components = JSON.stringify(config.components);
24
- components = components.replace(RepalceRegex, '').replace('[', '').replace(']', '').trim();
25
- var branch = JSON.stringify(config.branchName);
26
- branch = branch.replace(RepalceRegex, '').trim();
27
- var toMail = config.toMailAddress;
28
- var ccMail = config.ccMailAddress;
29
- }
30
-
31
- exports.config = {
32
- allScriptsTimeout: 600000,
33
-
34
- getPageTimeout: 60000,
35
-
36
- framework: 'jasmine',
37
-
38
- jasmineNodeOpts: {
39
- defaultTimeoutInterval: 100000
40
- },
41
- multiCapabilities: [],
42
-
43
- specs: ['../../../../e2e/tests/**/*.spec.js'],
44
-
45
- onComplete: function () {
46
- if (isDashBoardReport) {
47
- var failurecount = 0;
48
- var resultjson = require('../../../../jasmine-test-results.json');
49
- var key = Object.keys(resultjson);
50
- var totalcount = 0;
51
- for (var i = 0; i < key.length; i++) {
52
- var Objects = resultjson[key[i]]["specs"];
53
- totalcount = totalcount + Objects.length;
54
- for (var j = 0; j < Objects.length; j++) {
55
- if (Objects[j].status === "failed") {
56
- failurecount++;
57
- }
58
- }
59
- }
60
- ccMail.push("ej2core@syncfusion.com");
61
- var data = {
62
- RepositoryName: currentRepo,
63
- ComponentName: components,
64
- BranchName: branch,
65
- StartDate: new Date(),
66
- EndDate: new Date(),
67
- Type: "Desktop",
68
- TotalTestCaseCount: totalcount,
69
- FailureTestCaseCount: failurecount,
70
- SuccessTestCaseCount: totalcount - failurecount,
71
- Browser: browser.browserName,
72
- toMailAddress: toMail,
73
- ccMailAddress: ccMail
74
- };
75
- var status = failurecount.length ? 'Failure' : 'Success';
76
- var successCount = totalcount - failurecount;
77
- var notRun = totalcount - (successCount + failurecount);
78
- if (fs.existsSync('./testreport')) {
79
- shell.cd('./testreport');
80
- shell.exec('Syncfusion.UpdateTestResults.exe /Platform:"JavaScript - EJ2" /Control:"' + components +
81
- '" /TestingTool:"Selenium" /StartTime:"' + new Date().toLocaleTimeString() + '" /EndTime:"' + new Date().toLocaleTimeString() +
82
- '" /Status:"' + status + '" /TotalTestCase:' + totalcount +
83
- ' /SuccessCount:' + successCount + ' /FailureCount:' + failurecount + ' /NotRunCount:' + notRun + ' /UpdatedBy:"' + toMail[0] + '"');
84
- shell.cd('../');
85
- }
86
- request({
87
- url: 'https://ej2services.syncfusion.com/cicentral/api/getE2EReport',
88
- method: 'POST',
89
- json: true,
90
- body: data,
91
- headers: {
92
- 'authorization': 'ej2centrailzedstatus',
93
- 'content-type': 'application/json'
94
- }
95
- });
96
- }
97
-
98
- browser.driver.quit();
99
- console.log(browser.browserName + ' driver closed!');
100
- },
101
- beforeLaunch: function () {
102
- return new Promise(function (resolve) {
103
- reporter.beforeLaunch(resolve);
104
- });
105
- },
106
-
107
- onPrepare: function () {
108
- const PixDiff = require('pix-diff');
109
- const fs = require('fs');
110
- const path = require('path');
111
- browser.ignoreSynchronization = true;
112
- browser.waitForAngularEnabled = false;
113
- browser.isDesktop = true;
114
- timeCal['startTime'] = new Date().toLocaleTimeString();
115
- browser.basePath = require('../../../../protractor.browser.json').basePath;
116
-
117
- browser.driver.manage().window().setSize(1600, 1200);
118
- var JSONReporter = require('jasmine-json-test-reporter');
119
- jasmine.getEnv().addReporter(new JSONReporter({
120
- file: 'jasmine-test-results.json',
121
- beautify: true,
122
- indentationLevel: 4 // used if beautify === true
123
- }));
124
-
125
- //move to out off user screen
126
- browser.driver.manage().window().setPosition(2500, 0);
127
-
128
- browser.load = function (path) {
129
- browser.get(browser.basePath + path);
130
- browser.wait(function () {
131
- return element(By.css('.e-control')).isDisplayed();
132
- }, 3000);
133
-
134
- if (browser.css) {
135
- browser.injectCss(browser.css);
136
- }
137
- }
138
-
139
- browser.loadAsync = function (path) {
140
- return browser.get(browser.basePath + path);
141
- }
142
-
143
- browser.getCapabilities().then(function (cap) {
144
-
145
- browser.browserName = cap.get('browserName');
146
-
147
- browser.pixResult = PixDiff;
148
-
149
- browser.pixDiff = new PixDiff({
150
- basePath: './e2e',
151
- diffPath: './e2e',
152
- formatImageName: '{tag}'
153
- });
154
-
155
- //override difference path
156
- browser.pixDiff.diffPath = path.normalize(camelCase('./e2e/Diff/' + browser.browserName));
157
- //create folder if not present
158
- createF(browser.pixDiff.diffPath);
159
-
160
- browser.compareScreen = function (element, fileName, opt) {
161
- var folderName = fileName;
162
- var fArr = fileName.split('/');
163
- if (fArr.length > 1) {
164
- fArr.splice(-1, 1);
165
- folderName = fArr.join('/')
166
- createF(camelCase('e2e/expected/' + browser.pixDiff.browserName + '/' + folderName));
167
- createF(camelCase('e2e/actual/' + browser.pixDiff.browserName + '/' + folderName));
168
- }
169
-
170
- // thresholdType: 'percent',
171
- // threshold: 0.009,
172
- var option = {
173
- imageAPath: '/expected/' + browser.pixDiff.browserName + '/' + fileName, // Use file-path
174
- imageBPath: '/actual/' + browser.pixDiff.browserName + '/' + fileName,
175
- filter: ['grayScale'],
176
- debug: true,
177
- hideShift: true
178
- };
179
- var doneFn = arguments[arguments.length - 1];
180
- if (typeof opt === 'object' && Object.keys(opt).length) {
181
- Object.assign(option, opt);
182
- }
183
- browser.pixDiff.saveRegion(element, '/Actual/' + browser.pixDiff.browserName + '/' + fileName, option).then(() => {
184
- var fPathName = path.resolve(__dirname, '../../../../' + camelCase('e2e/expected/' + browser.pixDiff.browserName + '/' + fileName) + '.png');
185
- if (!fs.existsSync(fPathName) && fs.existsSync(fPathName.replace("Expected", "Actual"))) {
186
- fs.copyFileSync(fPathName.replace("Expected", "Actual"), fPathName);
187
- console.log('Expected Image Created : /expected/' + browser.pixDiff.browserName + '/' + fileName);
188
- }
189
- browser.saveCheckImage(element, fileName, option, doneFn);
190
- });
191
- }
192
-
193
- browser.saveCheckImage = function (element, fileName, option, doneFn) {
194
- browser.pixDiff.checkRegion(element, '/Expected/' + browser.pixDiff.browserName + '/' + fileName, option).then((result) => {
195
- //
196
- // * - `RESULT_UNKNOWN`: 0
197
- // * - `RESULT_DIFFERENT`: 1
198
- // * - `RESULT_SIMILAR`: 7
199
- // * - `RESULT_IDENTICAL`: 5
200
- console.log(JSON.stringify(result));
201
- expect(result.code).toEqual(browser.pixResult.RESULT_IDENTICAL);
202
- if (typeof doneFn === 'function') {
203
- doneFn();
204
- }
205
- });
206
- }
207
-
208
- browser.waitForEvent = function (id, moduleName, eventName) {
209
- return browser.executeAsyncScript(function (id, moduleName, eventName, callback) {
210
- var instances = document.getElementById(id).ej2_instances;
211
- var instanceObj;
212
- for (var i = 0; instances && i < instances.length; i++) {
213
- if (instances[i].getModuleName() == moduleName) {
214
- instanceObj = instances[i]
215
- }
216
- }
217
- if (instanceObj) {
218
- var handler;
219
- handler = function (e) {
220
- instanceObj.removeEventListener(eventName, handler);
221
- callback();
222
- };
223
- instanceObj.addEventListener(eventName, handler);
224
- } else {
225
- callback();
226
- }
227
- }, id, moduleName, eventName);
228
- }
229
-
230
- browser.injectScript = function (path, callback) {
231
- return browser.executeAsyncScript(function (path) {
232
- var head = document.getElementsByTagName('head')[0];
233
- var script = document.createElement('script');
234
- script.type = 'text/javascript';
235
- script.onload = function () {
236
- callback();
237
- }
238
- script.src = path;
239
- head.appendChild(script);
240
- }, browser.basePath + path);
241
-
242
- }
243
-
244
- browser.injectCss = function (content) {
245
- return browser.wait(browser.executeScript(`
246
- var style = document.createElement('style');
247
- style.id = 'browsercss';
248
- if (style.styleSheet) {style.styleSheet.cssText = '` + content + `';}
249
- else{style.appendChild(document.createTextNode('` + content + `'));}
250
- document.head.appendChild(style);
251
- `));
252
- }
253
-
254
- });
255
- jasmine.getEnv().addReporter(reporter);
256
-
257
- },
258
- afterLaunch: function (exitCode) {
259
- return new Promise(function (resolve) {
260
- reporter.afterLaunch(resolve.bind(this, exitCode));
261
- });
262
- },
263
- };
264
-
265
- //Browser Configuration
266
- if (config.browsers && config.browsers.length) {
267
- for (var i = 0; i < config.browsers.length; i++) {
268
- var browserName = config.browsers[i];
269
- if (browserName === 'chrome' && enableW3c === '{W3cenabled}') {
270
- exports.config.capabilities = {
271
- 'browserName': 'chrome',
272
- 'chromeOptions': {
273
- 'w3c': false,
274
- 'args': [
275
- '--headless', // Run in headless mode
276
- '--disable-gpu'
277
- ]
278
- }
279
- };
280
- } else {
281
- exports.config.capabilities = {
282
- 'browserName': 'chrome',
283
- 'chromeOptions': {
284
- 'args': [
285
- '--headless', // Run in headless mode
286
- '--disable-gpu'
287
- ]
288
- }
289
- };
290
- }
291
- }
292
- } else {
293
- if (os.platform() === 'win32') {
294
- exports.config.multiCapabilities.push({
295
- 'browserName': 'internet explorer'
296
- });
297
- if (Number(os.release().split('.')[0]) >= 10) {
298
- exports.config.multiCapabilities.push({
299
- 'browserName': 'MicrosoftEdge'
300
- });
301
- }
302
- }
303
- exports.config.multiCapabilities.push({
304
- 'browserName': 'firefox'
305
- });
306
- if (enableW3c === '{W3cenabled}') {
307
- exports.config.capabilities = {
308
- 'browserName': 'chrome',
309
- 'chromeOptions': {
310
- 'args': [
311
- '--headless', // Run in headless mode
312
- '--disable-gpu'
313
- ]
314
- }
315
- };
316
- } else {
317
- exports.config.capabilities = {
318
- 'browserName': 'chrome',
319
- 'chromeOptions': {
320
- 'args': [
321
- '--headless', // Run in headless mode
322
- '--disable-gpu'
323
- ]
324
- }
325
- };
326
- }
327
- }
328
- exports.config.seleniumAddress = config.seleniumAddress || 'http://localhost:4444/wd/hub/';
329
-
330
- function createF(path) {
331
- shell.mkdir('-p', path);
332
- }
1
+ var shell = require('shelljs');
2
+ var os = require('os');
3
+ var camelCase = require('pix-diff/lib/camelCase.js');
4
+ var seleniumAddress = 'http://150.107.121.2:4444/wd/hub';
5
+ var request = require('request');
6
+ var config = require('../../../../config.json');
7
+ var RepalceRegex = /"/g;
8
+ var isDashBoardReport = config['dashBoardReport'];
9
+ var timeCal = {};
10
+ var fs = require('fs');
11
+ var enableW3c = '{W3cdisabled}';
12
+ const pixelmatch = require('pixelmatch');
13
+ var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
14
+ var reporter = new HtmlScreenshotReporter({
15
+ dest: 'e2e_report/' + config.browsers[0],
16
+ filename: config.browsers[0] + '.html'
17
+ });
18
+ isDashBoardReport = isDashBoardReport === undefined ? true : isDashBoardReport;
19
+ if (isDashBoardReport) {
20
+ var currentRepo = shell.exec('git config --get remote.origin.url', {
21
+ silent: true
22
+ })
23
+ .stdout.split('essential-studio/')[1].replace('.git', '').replace('/', '').trim();
24
+ var components = JSON.stringify(config.components);
25
+ components = components.replace(RepalceRegex, '').replace('[', '').replace(']', '').trim();
26
+ var branch = JSON.stringify(config.branchName);
27
+ branch = branch.replace(RepalceRegex, '').trim();
28
+ var toMail = config.toMailAddress;
29
+ var ccMail = config.ccMailAddress;
30
+ }
31
+
32
+ exports.config = {
33
+ allScriptsTimeout: 600000,
34
+
35
+ getPageTimeout: 60000,
36
+
37
+ framework: 'jasmine',
38
+
39
+ jasmineNodeOpts: {
40
+ defaultTimeoutInterval: 150000
41
+ },
42
+ multiCapabilities: [],
43
+
44
+ specs: ['../../../../e2e/tests/**/*.spec.js'],
45
+
46
+ onComplete: function () {
47
+ if (isDashBoardReport) {
48
+ var failurecount = 0;
49
+ var resultjson = require('../../../../jasmine-test-results.json');
50
+ var key = Object.keys(resultjson);
51
+ var totalcount = 0;
52
+ for (var i = 0; i < key.length; i++) {
53
+ var Objects = resultjson[key[i]]["specs"];
54
+ totalcount = totalcount + Objects.length;
55
+ for (var j = 0; j < Objects.length; j++) {
56
+ if (Objects[j].status === "failed") {
57
+ failurecount++;
58
+ }
59
+ }
60
+ }
61
+ ccMail.push("ej2core@syncfusion.com");
62
+ var data = {
63
+ RepositoryName: currentRepo,
64
+ ComponentName: components,
65
+ BranchName: branch,
66
+ StartDate: new Date(),
67
+ EndDate: new Date(),
68
+ Type: "Desktop",
69
+ TotalTestCaseCount: totalcount,
70
+ FailureTestCaseCount: failurecount,
71
+ SuccessTestCaseCount: totalcount - failurecount,
72
+ Browser: browser.browserName,
73
+ toMailAddress: toMail,
74
+ ccMailAddress: ccMail
75
+ };
76
+ var status = failurecount.length ? 'Failure' : 'Success';
77
+ var successCount = totalcount - failurecount;
78
+ var notRun = totalcount - (successCount + failurecount);
79
+ if (fs.existsSync('./testreport')) {
80
+ shell.cd('./testreport');
81
+ shell.exec('Syncfusion.UpdateTestResults.exe /Platform:"JavaScript - EJ2" /Control:"' + components +
82
+ '" /TestingTool:"Selenium" /StartTime:"' + new Date().toLocaleTimeString() + '" /EndTime:"' + new Date().toLocaleTimeString() +
83
+ '" /Status:"' + status + '" /TotalTestCase:' + totalcount +
84
+ ' /SuccessCount:' + successCount + ' /FailureCount:' + failurecount + ' /NotRunCount:' + notRun + ' /UpdatedBy:"' + toMail[0] + '"');
85
+ shell.cd('../');
86
+ }
87
+ request({
88
+ url: 'https://ej2services.syncfusion.com/cicentral/api/getE2EReport',
89
+ method: 'POST',
90
+ json: true,
91
+ body: data,
92
+ headers: {
93
+ 'authorization': 'ej2centrailzedstatus',
94
+ 'content-type': 'application/json'
95
+ }
96
+ });
97
+ }
98
+
99
+ browser.driver.quit();
100
+ console.log(browser.browserName + ' driver closed!');
101
+ },
102
+ beforeLaunch: function () {
103
+ return new Promise(function (resolve) {
104
+ reporter.beforeLaunch(resolve);
105
+ });
106
+ },
107
+
108
+ onPrepare: function () {
109
+ const PixDiff = require('pix-diff');
110
+ const fs = require('fs');
111
+ const path = require('path');
112
+ browser.ignoreSynchronization = true;
113
+ browser.waitForAngularEnabled = false;
114
+ browser.isDesktop = true;
115
+ timeCal['startTime'] = new Date().toLocaleTimeString();
116
+ browser.basePath = require('../../../../protractor.browser.json').basePath;
117
+
118
+ browser.driver.manage().window().setSize(1600, 1200);
119
+ var JSONReporter = require('jasmine-json-test-reporter');
120
+ jasmine.getEnv().addReporter(new JSONReporter({
121
+ file: 'jasmine-test-results.json',
122
+ beautify: true,
123
+ indentationLevel: 4 // used if beautify === true
124
+ }));
125
+
126
+ //move to out off user screen
127
+ browser.driver.manage().window().setPosition(2500, 0);
128
+
129
+ browser.load = function (path) {
130
+ browser.get(browser.basePath + path);
131
+ browser.wait(function () {
132
+ return element(By.css('.e-control')).isDisplayed();
133
+ }, 3000);
134
+
135
+ if (browser.css) {
136
+ browser.injectCss(browser.css);
137
+ }
138
+ }
139
+
140
+ browser.loadAsync = function (path) {
141
+ return browser.get(browser.basePath + path);
142
+ }
143
+
144
+ browser.getCapabilities().then(function (cap) {
145
+
146
+ browser.browserName = cap.get('browserName');
147
+
148
+ browser.pixResult = PixDiff;
149
+
150
+ browser.pixDiff = new PixDiff({
151
+ basePath: './e2e',
152
+ diffPath: './e2e',
153
+ formatImageName: '{tag}'
154
+ });
155
+
156
+ //override difference path
157
+ browser.pixDiff.diffPath = path.normalize(camelCase('./e2e/Diff/' + browser.browserName));
158
+ //create folder if not present
159
+ createF(browser.pixDiff.diffPath);
160
+
161
+ browser.compareScreen = function (element, fileName, opt) {
162
+ var folderName = fileName;
163
+ var fArr = fileName.split('/');
164
+ if (fArr.length > 1) {
165
+ fArr.splice(-1, 1);
166
+ folderName = fArr.join('/')
167
+ createF(camelCase('e2e/expected/' + browser.pixDiff.browserName + '/' + folderName));
168
+ createF(camelCase('e2e/actual/' + browser.pixDiff.browserName + '/' + folderName));
169
+ }
170
+
171
+ // thresholdType: 'percent',
172
+ // threshold: 0.009,
173
+ var option = {
174
+ imageAPath: '/expected/' + browser.pixDiff.browserName + '/' + fileName, // Use file-path
175
+ imageBPath: '/actual/' + browser.pixDiff.browserName + '/' + fileName,
176
+ filter: ['grayScale'],
177
+ debug: true,
178
+ hideShift: true
179
+ };
180
+ var doneFn = arguments[arguments.length - 1];
181
+ if (typeof opt === 'object' && Object.keys(opt).length) {
182
+ Object.assign(option, opt);
183
+ }
184
+ browser.pixDiff.saveRegion(element, '/Actual/' + browser.pixDiff.browserName + '/' + fileName, option).then(() => {
185
+ var fPathName = path.resolve(__dirname, '../../../../' + camelCase('e2e/expected/' + browser.pixDiff.browserName + '/' + fileName) + '.png');
186
+ if (!fs.existsSync(fPathName) && fs.existsSync(fPathName.replace("Expected", "Actual"))) {
187
+ fs.copyFileSync(fPathName.replace("Expected", "Actual"), fPathName);
188
+ console.log('Expected Image Created : /expected/' + browser.pixDiff.browserName + '/' + fileName);
189
+ }
190
+ browser.saveCheckImage(element, fileName, option, doneFn);
191
+ });
192
+ }
193
+
194
+ browser.saveCheckImage = function (element, fileName, option, doneFn) {
195
+ browser.pixDiff.checkRegion(element, '/Expected/' + browser.pixDiff.browserName + '/' + fileName, option).then((result) => {
196
+ //
197
+ // * - `RESULT_UNKNOWN`: 0
198
+ // * - `RESULT_DIFFERENT`: 1
199
+ // * - `RESULT_SIMILAR`: 7
200
+ // * - `RESULT_IDENTICAL`: 5
201
+ console.log(JSON.stringify(result));
202
+ expect(result.code).toEqual(browser.pixResult.RESULT_IDENTICAL);
203
+ if (typeof doneFn === 'function') {
204
+ doneFn();
205
+ }
206
+ });
207
+ }
208
+
209
+ browser.compareScreenWithPixelMatch = function (element, fileName, opt) {
210
+ var folderName = fileName;
211
+ var fArr = fileName.split('/');
212
+ if (fArr.length > 1) {
213
+ fArr.splice(-1, 1);
214
+ folderName = fArr.join('/')
215
+ createF(camelCase('e2e/expected/' + browser.pixDiff.browserName + '/' + folderName));
216
+ createF(camelCase('e2e/actual/' + browser.pixDiff.browserName + '/' + folderName));
217
+ }
218
+
219
+ var option = {
220
+ imageAPath: '/expected/' + browser.pixDiff.browserName + '/' + fileName, // Use file-path
221
+ imageBPath: '/actual/' + browser.pixDiff.browserName + '/' + fileName,
222
+ filter: ['grayScale'],
223
+ debug: true,
224
+ hideShift: true,
225
+ thresholdType: 'pixel',
226
+ threshold: 0.3
227
+ };
228
+ var doneFn = arguments[arguments.length - 1];
229
+ if (typeof opt === 'object' && Object.keys(opt).length) {
230
+ Object.assign(option, opt);
231
+ }
232
+ console.log(JSON.stringify(option));
233
+ browser.pixDiff.saveRegion(element, '/Actual/' + browser.pixDiff.browserName + '/' + fileName, option).then(() => {
234
+ var fPathName = path.resolve(__dirname, '../../../../' + camelCase('e2e/expected/' + browser.pixDiff.browserName + '/' + fileName) + '.png');
235
+ if (!fs.existsSync(fPathName) && fs.existsSync(fPathName.replace("Expected", "Actual"))) {
236
+ fs.copyFileSync(fPathName.replace("Expected", "Actual"), fPathName);
237
+ console.log('Expected Image Created : /expected/' + browser.pixDiff.browserName + '/' + fileName);
238
+ }
239
+ browser.saveCheckImagewithPixelMatch(element, fileName, option, doneFn);
240
+ });
241
+ }
242
+
243
+ browser.saveCheckImagewithPixelMatch = function (element, fileName, option, doneFn) {
244
+ var img1 = PNG.sync.read(fs.readFileSync('./e2e'+option.imageBPath+'.png'));
245
+ var img2 = PNG.sync.read(fs.readFileSync('./e2e'+option.imageAPath+'.png'));
246
+ var { width, height } = img1;
247
+ var diff = new PNG({ width, height });
248
+ var result = pixelmatch(img1.data, img2.data, diff.data, width, height, { threshold: option.threshold });
249
+ console.log('result --->\n', result);
250
+ if (result < 75) {
251
+ result = 5
252
+ } else if (result < 150){
253
+ result = 7;
254
+ fs.writeFileSync('./e2e' + option.imageAPath.replace('expected', 'diff') + '.png', PNG.sync.write(diff));
255
+ } else{
256
+ result = 1;
257
+ fs.writeFileSync('./e2e' + option.imageAPath.replace('expected', 'diff') + '.png', PNG.sync.write(diff));
258
+ }
259
+ expect(result).toEqual(5)
260
+ if (typeof doneFn === 'function') {
261
+ doneFn();
262
+ }
263
+ }
264
+
265
+ browser.waitForEvent = function (id, moduleName, eventName) {
266
+ return browser.executeAsyncScript(function (id, moduleName, eventName, callback) {
267
+ var instances = document.getElementById(id).ej2_instances;
268
+ var instanceObj;
269
+ for (var i = 0; instances && i < instances.length; i++) {
270
+ if (instances[i].getModuleName() == moduleName) {
271
+ instanceObj = instances[i]
272
+ }
273
+ }
274
+ if (instanceObj) {
275
+ var handler;
276
+ handler = function (e) {
277
+ instanceObj.removeEventListener(eventName, handler);
278
+ callback();
279
+ };
280
+ instanceObj.addEventListener(eventName, handler);
281
+ } else {
282
+ callback();
283
+ }
284
+ }, id, moduleName, eventName);
285
+ }
286
+
287
+ browser.injectScript = function (path, callback) {
288
+ return browser.executeAsyncScript(function (path) {
289
+ var head = document.getElementsByTagName('head')[0];
290
+ var script = document.createElement('script');
291
+ script.type = 'text/javascript';
292
+ script.onload = function () {
293
+ callback();
294
+ }
295
+ script.src = path;
296
+ head.appendChild(script);
297
+ }, browser.basePath + path);
298
+
299
+ }
300
+
301
+ browser.injectCss = function (content) {
302
+ return browser.wait(browser.executeScript(`
303
+ var style = document.createElement('style');
304
+ style.id = 'browsercss';
305
+ if (style.styleSheet) {style.styleSheet.cssText = '` + content + `';}
306
+ else{style.appendChild(document.createTextNode('` + content + `'));}
307
+ document.head.appendChild(style);
308
+ `));
309
+ }
310
+
311
+ });
312
+ jasmine.getEnv().addReporter(reporter);
313
+
314
+ },
315
+ afterLaunch: function (exitCode) {
316
+ return new Promise(function (resolve) {
317
+ reporter.afterLaunch(resolve.bind(this, exitCode));
318
+ });
319
+ },
320
+ };
321
+
322
+ //Browser Configuration
323
+ if (config.browsers && config.browsers.length) {
324
+ for (var i = 0; i < config.browsers.length; i++) {
325
+ var browserName = config.browsers[i];
326
+ if (browserName === 'chrome' && enableW3c === '{W3cenabled}') {
327
+ exports.config.capabilities = {
328
+ 'browserName': 'chrome',
329
+ 'chromeOptions': {
330
+ 'w3c': false,
331
+ 'args': [
332
+ '--headless', // Run in headless mode
333
+ '--disable-gpu'
334
+ ]
335
+ }
336
+ };
337
+ } else {
338
+ exports.config.capabilities = {
339
+ 'browserName': 'chrome',
340
+ 'chromeOptions': {
341
+ 'args': [
342
+ '--headless', // Run in headless mode
343
+ '--disable-gpu'
344
+ ]
345
+ }
346
+ };
347
+ }
348
+ }
349
+ } else {
350
+ if (os.platform() === 'win32') {
351
+ exports.config.multiCapabilities.push({
352
+ 'browserName': 'internet explorer'
353
+ });
354
+ if (Number(os.release().split('.')[0]) >= 10) {
355
+ exports.config.multiCapabilities.push({
356
+ 'browserName': 'MicrosoftEdge'
357
+ });
358
+ }
359
+ }
360
+ exports.config.multiCapabilities.push({
361
+ 'browserName': 'firefox'
362
+ });
363
+ if (enableW3c === '{W3cenabled}') {
364
+ exports.config.capabilities = {
365
+ 'browserName': 'chrome',
366
+ 'chromeOptions': {
367
+ 'args': [
368
+ '--headless', // Run in headless mode
369
+ '--disable-gpu'
370
+ ]
371
+ }
372
+ };
373
+ } else {
374
+ exports.config.capabilities = {
375
+ 'browserName': 'chrome',
376
+ 'chromeOptions': {
377
+ 'args': [
378
+ '--headless', // Run in headless mode
379
+ '--disable-gpu'
380
+ ]
381
+ }
382
+ };
383
+ }
384
+ }
385
+ exports.config.seleniumAddress = config.seleniumAddress || 'http://localhost:4444/wd/hub/';
386
+
387
+ function createF(path) {
388
+ shell.mkdir('-p', path);
389
+ }