powerbi-visuals-tools 5.0.1 → 5.0.2

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.
@@ -1,686 +0,0 @@
1
- /* eslint-disable no-useless-escape */
2
- /*
3
- * Power BI Visual CLI
4
- *
5
- * Copyright (c) Microsoft Corporation
6
- * All rights reserved.
7
- * MIT License
8
- *
9
- * Permission is hereby granted, free of charge, to any person obtaining a copy
10
- * of this software and associated documentation files (the ""Software""), to deal
11
- * in the Software without restriction, including without limitation the rights
12
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
- * copies of the Software, and to permit persons to whom the Software is
14
- * furnished to do so, subject to the following conditions:
15
- *
16
- * The above copyright notice and this permission notice shall be included in
17
- * all copies or substantial portions of the Software.
18
- *
19
- * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
- * THE SOFTWARE.
26
- */
27
-
28
- "use strict";
29
-
30
- import fs from 'fs-extra';
31
- import path from 'path';
32
- import async from 'async';
33
- import JSZip from 'jszip';
34
- import lodashIsEqual from 'lodash.isequal';
35
- import FileSystem from '../helpers/FileSystem.js';
36
- import { writeMetadata } from "./testUtils.js";
37
-
38
- const tempPath = FileSystem.getTempPath();
39
- const startPath = process.cwd();
40
-
41
- describe("E2E - pbiviz package", () => {
42
-
43
- const visualName = 'visualname';
44
- const visualPath = path.join(tempPath, visualName);
45
- let visualPbiviz = {};
46
-
47
- beforeEach(() => {
48
- process.chdir(startPath);
49
- FileSystem.resetTempDirectory();
50
- process.chdir(tempPath);
51
- FileSystem.runPbiviz('new', visualName);
52
- process.chdir(visualPath);
53
- FileSystem.runCMDCommand('npm i', visualPath);
54
-
55
- writeMetadata(visualPath);
56
-
57
- visualPbiviz = JSON.parse(fs.readFileSync(path.join(visualPath, 'pbiviz.json'), { encoding: "utf8" }));
58
- });
59
-
60
- afterAll(() => {
61
- process.chdir(startPath);
62
- FileSystem.deleteTempDirectory();
63
- });
64
-
65
- it("Should throw error if not in the visual root", () => {
66
- let error;
67
- process.chdir(tempPath);
68
-
69
- try {
70
- FileSystem.runPbiviz('package');
71
- } catch (e) {
72
- error = e;
73
- }
74
- expect(error).toBeDefined();
75
- expect(error.status).toBe(1);
76
- expect(error.message).toContain("Error: pbiviz.json not found. You must be in the root of a visual project to run this command");
77
- });
78
-
79
- it("Should throw error if there is nothing to produce", () => {
80
- let error;
81
- process.chdir(tempPath);
82
-
83
- try {
84
- FileSystem.runPbiviz('package', '--no-pbiviz');
85
- } catch (e) {
86
- error = e;
87
- }
88
- expect(error).toBeDefined();
89
- expect(error.status).toBe(1);
90
- expect(error.message).toContain("Nothing to build. Cannot use --no-pbiviz without --resources");
91
- });
92
-
93
- it("Should create a pbiviz file and no resources folder with no flags", () => {
94
- let error;
95
- FileSystem.runPbiviz('package');
96
-
97
- const pbivizPath = path.join(visualPath, 'dist', visualPbiviz.visual.guid + "." + visualPbiviz.visual.version + '.pbiviz');
98
- const resourcesPath = path.join(visualPath, 'dist', 'resources');
99
-
100
- try {
101
- fs.accessSync(resourcesPath);
102
- } catch (e) {
103
- error = e
104
- }
105
- expect(error).toBeDefined();
106
- expect(error.code).toBe('ENOENT');
107
-
108
- expect(fs.statSync(pbivizPath).isFile()).toBe(true);
109
- });
110
-
111
- it("Should create a pbiviz file and resource folder with --resources flag", () => {
112
- FileSystem.runPbiviz('package', undefined, '--resources');
113
-
114
- const pbivizPath = path.join(visualPath, 'dist', visualPbiviz.visual.guid + "." + visualPbiviz.visual.version + '.pbiviz');
115
- const resourcesPath = path.join(visualPath, 'dist', 'resources');
116
-
117
- expect(fs.statSync(pbivizPath).isFile()).toBe(true);
118
- expect(fs.statSync(resourcesPath).isDirectory()).toBe(true);
119
- });
120
-
121
- it("Should not create pbiviz file with --no-pbiviz flag", () => {
122
- let error
123
- FileSystem.runPbiviz('package', undefined, '--no-pbiviz --resources');
124
-
125
- const pbivizPath = path.join(visualPath, 'dist', visualPbiviz.visual.guid + "." + visualPbiviz.visual.version + '.pbiviz');
126
- const resourcesPath = path.join(visualPath, 'dist', 'resources');
127
-
128
- try {
129
- fs.accessSync(pbivizPath);
130
- } catch (e) {
131
- error = e
132
- }
133
- expect(error).toBeDefined();
134
- expect(error.code).toBe('ENOENT');
135
-
136
- expect(fs.statSync(resourcesPath).isDirectory()).toBe(true);
137
- });
138
-
139
- it("Should correctly generate pbiviz file", (done) => {
140
- FileSystem.runPbiviz('package');
141
-
142
- const visualConfig = fs.readJsonSync(path.join(visualPath, 'pbiviz.json')).visual;
143
- const visualCapabilities = fs.readJsonSync(path.join(visualPath, 'capabilities.json'));
144
- const pbivizPath = path.join(visualPath, 'dist', visualPbiviz.visual.guid + "." + visualPbiviz.visual.version + '.pbiviz');
145
- const pbivizResourcePath = `resources/${visualConfig.guid}.pbiviz.json`;
146
-
147
- const zipContents = fs.readFileSync(pbivizPath);
148
- const jszip = new JSZip();
149
- jszip.loadAsync(zipContents)
150
- .then((zip) => {
151
- async.parallel([
152
- //check package.json
153
- (next) => {
154
- zip.file('package.json').async('string')
155
- .then((content) => {
156
- const data = JSON.parse(content);
157
- expect(data.resources.length).toBe(1);
158
- expect(data.resources[0].file).toBe(pbivizResourcePath);
159
- expect(data.visual).toEqual(visualConfig);
160
- next();
161
- })
162
- .catch(next);
163
- },
164
- //check pbiviz
165
- (next) => {
166
- zip.file(pbivizResourcePath).async('string')
167
- .then((content) => {
168
- const data = JSON.parse(content);
169
- expect(data.visual).toEqual(visualConfig);
170
- expect(data.capabilities).toEqual(visualCapabilities);
171
- expect(data.content.js).toBeDefined();
172
- expect(data.content.js.length).toBeGreaterThan(0);
173
- expect(data.content.css).toBeDefined();
174
- expect(data.content.iconBase64).toBeDefined();
175
- expect(data.content.iconBase64.length).toBeGreaterThan(0);
176
- next();
177
- })
178
- .catch(next);
179
- }
180
- ], error => {
181
- if (error) { throw error; }
182
- done();
183
- });
184
-
185
- });
186
- });
187
-
188
- it("Should correctly generate resources folder", () => {
189
- FileSystem.runPbiviz('package', undefined, '--no-pbiviz --resources');
190
-
191
- const visualConfig = fs.readJsonSync(path.join(visualPath, 'pbiviz.json')).visual;
192
- const visualCapabilities = fs.readJsonSync(path.join(visualPath, 'capabilities.json'));
193
- const resourcesPath = path.join(visualPath, 'dist', 'resources');
194
- const pbivizPath = path.join(resourcesPath, visualPbiviz.visual.guid + '.pbiviz.json');
195
-
196
- expect(fs.statSync(resourcesPath).isDirectory()).toBe(true);
197
- expect(fs.statSync(path.join(resourcesPath, 'visual.prod.js')).isFile()).toBe(true);
198
- expect(fs.statSync(path.join(resourcesPath, 'visual.prod.css')).isFile()).toBe(true);
199
- expect(fs.statSync(pbivizPath).isFile()).toBe(true);
200
-
201
- const pbiviz = fs.readJsonSync(pbivizPath);
202
- expect(pbiviz.visual).toEqual(visualConfig);
203
- expect(pbiviz.capabilities).toEqual(visualCapabilities);
204
- expect(pbiviz.content.js).toBeDefined();
205
- expect(pbiviz.content.css).toBeDefined();
206
- expect(pbiviz.content.iconBase64).toBeDefined();
207
- });
208
-
209
- // tets can't check the minification, because in input the plugin gets minified version,
210
- // plugin can't create two version js file for compare
211
- xit("Should minify assets by default", () => {
212
- FileSystem.runPbiviz('package', undefined, '--resources --no-pbiviz');
213
-
214
- const js = fs.statSync(path.join(visualPath, 'dist', 'resources', 'visual.js'));
215
-
216
- const prodJs = fs.statSync(path.join(visualPath, 'dist', 'resources', 'visual.prod.js'));
217
-
218
- expect(js.size).toBeGreaterThan(prodJs.size);
219
- });
220
-
221
- it("Should skip minification with --no-minify flag", () => {
222
- FileSystem.runPbiviz('package', undefined, '--resources --no-pbiviz --no-minify');
223
-
224
- const js = fs.statSync(path.join(visualPath, 'dist', 'resources', 'visual.js'));
225
-
226
- const prodJs = fs.statSync(path.join(visualPath, 'dist', 'resources', 'visual.prod.js'));
227
-
228
- expect(js.size).toBe(prodJs.size);
229
- });
230
-
231
- it("Should set all versions in metadata equal", (done) => {
232
- const visualVersion = "1.2.3.4";
233
-
234
- const pbivizJsonPath = path.join(visualPath, 'pbiviz.json');
235
- const pbiviz = fs.readJsonSync(pbivizJsonPath);
236
- pbiviz.visual.version = visualVersion;
237
- fs.writeFileSync(pbivizJsonPath, JSON.stringify(pbiviz));
238
- FileSystem.runCMDCommand('npm i', visualPath);
239
- FileSystem.runPbiviz('package');
240
-
241
- const visualConfig = fs.readJsonSync(path.join(visualPath, 'pbiviz.json')).visual;
242
- const pbivizPath = path.join(visualPath, 'dist', visualPbiviz.visual.guid + "." + pbiviz.visual.version + '.pbiviz');
243
- const pbivizResourcePath = `resources/${visualConfig.guid}.pbiviz.json`;
244
-
245
- const zipContents = fs.readFileSync(pbivizPath);
246
- const jszip = new JSZip();
247
- jszip.loadAsync(zipContents)
248
- .then((zip) => {
249
- async.parallel([
250
- //check package.json
251
- next => {
252
- zip.file('package.json').async('string')
253
- .then((content) => {
254
- const data = JSON.parse(content);
255
- expect(data.visual.version).toEqual(visualVersion);
256
- expect(data.version).toEqual(visualVersion);
257
- next();
258
- })
259
- .catch(next);
260
- },
261
- //check pbiviz
262
- next => {
263
- zip.file(pbivizResourcePath).async('string')
264
- .then((content) => {
265
- const data = JSON.parse(content);
266
- expect(data.visual.version).toEqual(visualVersion);
267
- next();
268
- })
269
- .catch(next);
270
- }
271
- ], error => {
272
- if (error) { throw error; }
273
- done();
274
- });
275
-
276
- });
277
- });
278
-
279
- it("Should correctly generate pbiviz file with stringResources localization", (done) => {
280
- const resourceStringLocalization =
281
- {
282
- "locale": "ru-RU",
283
- "values": {
284
- "formattingGeneral": "Общие настройки",
285
- "formattingGeneralOrientation": "Ориентация",
286
- "formattingGeneralOrientationVertical": "Вертикальная"
287
- }
288
- };
289
- const validStringResources =
290
- {
291
- "ru-RU": {
292
- "formattingGeneral": "Общие настройки",
293
- "formattingGeneralOrientation": "Ориентация",
294
- "formattingGeneralOrientationVertical": "Вертикальная"
295
- }
296
- };
297
-
298
- mkDirPromise('stringResources')
299
- .then(() => writeJsonPromise('stringResources/ru-RU.json', resourceStringLocalization))
300
- .then(() =>
301
- readJsonPromise('pbiviz.json')
302
- )
303
- .then((pbivizJson) => {
304
- pbivizJson.stringResources = ["stringResources/ru-RU.json"];
305
- return writeJsonPromise('pbiviz.json', pbivizJson);
306
- })
307
- .then(() =>
308
- FileSystem.runPbiviz('package', undefined, '--no-pbiviz --no-minify --resources')
309
- )
310
- .then(() =>
311
- readJsonPromise(path.join(visualPath, 'dist', 'resources', visualPbiviz.visual.guid + '.pbiviz.json'))
312
- )
313
- .then((pbivizJson) => {
314
- expect(lodashIsEqual(pbivizJson.stringResources, validStringResources)).toBeTruthy();
315
- done();
316
- })
317
- .catch((err) => {
318
- expect(err).toBe(null);
319
- done();
320
- });
321
- });
322
-
323
- it("Should correctly generate pbiviz file with RESJSON localization", (done) => {
324
- const ResJsonEngLocalization =
325
- {
326
- "formattingGeneral": "General",
327
- "formattingGeneralOrientation": "Orientation",
328
- "formattingGeneralOrientationVertical": "Vertical"
329
- };
330
- const ResJsonRuLocalization =
331
- {
332
- "formattingGeneral": "Общие настройки",
333
- "formattingGeneralOrientation": "Ориентация",
334
- "formattingGeneralOrientationVertical": "Вертикальная"
335
- };
336
-
337
- const validStringResources =
338
- {
339
- "en-US": {
340
- "formattingGeneral": "General",
341
- "formattingGeneralOrientation": "Orientation",
342
- "formattingGeneralOrientationVertical": "Vertical"
343
- },
344
- "ru-RU": {
345
- "formattingGeneral": "Общие настройки",
346
- "formattingGeneralOrientation": "Ориентация",
347
- "formattingGeneralOrientationVertical": "Вертикальная"
348
- }
349
- };
350
- mkDirPromise('stringResources')
351
- .then(() =>
352
- Promise.all([
353
- mkDirPromise('stringResources/en-US')
354
- .then(() => writeJsonPromise('stringResources/en-US/resources.resjson', ResJsonEngLocalization)),
355
- mkDirPromise('stringResources/ru-RU')
356
- .then(() => writeJsonPromise('stringResources/ru-RU/resources.resjson', ResJsonRuLocalization))
357
- ]))
358
- .then(() =>
359
- FileSystem.runPbiviz('package', undefined, '--no-pbiviz --no-minify --resources')
360
- )
361
- .then(() =>
362
- readJsonPromise(path.join(visualPath, 'dist', 'resources', visualPbiviz.visual.guid + '.pbiviz.json'))
363
- )
364
- .then((pbivizJson) => {
365
- expect(lodashIsEqual(pbivizJson.stringResources, validStringResources)).toBeTruthy();
366
- done();
367
- })
368
- .catch((err) => {
369
- expect(err).toBe(null);
370
- done();
371
- });
372
- });
373
-
374
- it("Should correctly generate pbiviz file with RESJSON and stringResources localizations", (done) => {
375
- const resourceStringRuLocalization =
376
- {
377
- "locale": "ru-RU",
378
- "values": {
379
- "formattingGeneral": "Главные настройки",
380
- "formattingGeneralOrientation": "Ориентация",
381
- "formattingHeaderFontColor": "Цвет шрифта",
382
- "formattingHeaderBackground": "Цвет фона"
383
- }
384
- };
385
-
386
- const ResJsonEngLocalization =
387
- {
388
- "formattingGeneral": "General",
389
- "formattingGeneralOrientation": "Orientation",
390
- "formattingGeneralOrientationVertical": "Vertical"
391
- };
392
- const ResJsonRuLocalization =
393
- {
394
- "formattingGeneral": "Общие настройки",
395
- "formattingGeneralOrientation": "Ориентация",
396
- "formattingGeneralOrientationVertical": "Вертикальная"
397
- };
398
-
399
- const validStringResources =
400
- {
401
- "en-US": {
402
- "formattingGeneral": "General",
403
- "formattingGeneralOrientation": "Orientation",
404
- "formattingGeneralOrientationVertical": "Vertical"
405
- },
406
- "ru-RU": {
407
- "formattingGeneral": "Общие настройки",
408
- "formattingGeneralOrientation": "Ориентация",
409
- "formattingHeaderFontColor": "Цвет шрифта",
410
- "formattingHeaderBackground": "Цвет фона",
411
- "formattingGeneralOrientationVertical": "Вертикальная"
412
- }
413
- };
414
-
415
- mkDirPromise('stringResources')
416
- .then(() =>
417
- Promise.all([
418
- mkDirPromise('stringResources/en-US')
419
- .then(() => writeJsonPromise('stringResources/en-US/resources.resjson', ResJsonEngLocalization)),
420
- mkDirPromise('stringResources/ru-RU')
421
- .then(() => writeJsonPromise('stringResources/ru-RU/resources.resjson', ResJsonRuLocalization)),
422
- writeJsonPromise('stringResources/ru-RU.json', resourceStringRuLocalization)
423
- ]))
424
- .then(() => readJsonPromise('pbiviz.json'))
425
- .then((pbivizJson) => {
426
- pbivizJson.stringResources = ["stringResources/ru-RU.json"];
427
- return writeJsonPromise('pbiviz.json', pbivizJson);
428
- })
429
- .then(() =>
430
- FileSystem.runPbiviz('package', undefined, '--no-pbiviz --no-minify --resources')
431
- )
432
- .then(() => readJsonPromise(path.join(visualPath, 'dist', 'resources', visualPbiviz.visual.guid + '.pbiviz.json')))
433
- .then((pbivizJson) => {
434
- expect(lodashIsEqual(pbivizJson.stringResources, validStringResources)).toBeTruthy();
435
- done();
436
- })
437
- .catch((err) => {
438
- expect(err).toBe(null);
439
- done();
440
- });
441
- });
442
-
443
- it("Should generate statistic files without flags", () => {
444
- FileSystem.runPbiviz('package');
445
- const statisticFilePath = path.join(visualPath, 'webpack.statistics.prod.html');
446
- try {
447
- expect(fs.statSync(statisticFilePath).isFile()).toBe(true);
448
- } catch (error) {
449
- expect(error).toBeNull();
450
- }
451
- });
452
-
453
- it("Shouldn't generate statistic files with --no-stats flag", () => {
454
- FileSystem.runPbiviz('package', '--no-stats');
455
- const statisticFilePath = path.join(visualPath, 'webpack.statistics.prod.html');
456
- try {
457
- expect(fs.statSync(statisticFilePath).isFile()).toBe(false);
458
- } catch (error) {
459
- expect(error).not.toBeNull();
460
- }
461
- });
462
- });
463
-
464
- function mkDirPromise(path) {
465
- return new Promise((resolve, reject) => fs.mkdir(path, (err) => {
466
- if (err) {
467
- reject(err);
468
- } else {
469
- resolve();
470
- }
471
- }));
472
- }
473
-
474
- function readJsonPromise(path) {
475
- return new Promise((resolve, reject) => fs.readJSON(path, (err, jsonObject) => {
476
- if (err) {
477
- reject(err);
478
- } else {
479
- resolve(jsonObject);
480
- }
481
- }));
482
- }
483
-
484
- function writeJsonPromise(path, jsonObject) {
485
- return new Promise((resolve, reject) => fs.writeJSON(path, jsonObject, (err) => {
486
- if (err) {
487
- reject(err);
488
- } else {
489
- resolve();
490
- }
491
- }));
492
- }
493
-
494
- function testMissingScript(fname) {
495
- let error;
496
- fs.unlinkSync(fname);
497
-
498
- try {
499
- FileSystem.runPbiviz('package');
500
- } catch (e) {
501
- error = e
502
- }
503
- expect(error).toBeDefined();
504
- expect(error.status).toBe(1);
505
- expect(error.message).toContain("Failed updating visual capabilities");
506
- }
507
-
508
- function testErrorInDependencies() {
509
- let error;
510
- const invalidDependencies = [
511
- {
512
- invalidPropertyName: "ddd"
513
- }
514
- ];
515
-
516
- fs.writeFileSync('dependencies.json', JSON.stringify(invalidDependencies));
517
-
518
- try {
519
- FileSystem.runPbiviz('package');
520
- } catch (e) {
521
- error = e;
522
- }
523
- expect(error).toBeDefined();
524
- expect(error.status).toBe(1);
525
- expect(error.message).toContain("JSON dependencies.json : instance is not of a type(s) object");
526
- }
527
-
528
- function testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, removeDependencies) {
529
- if (removeDependencies) {
530
- fs.unlinkSync('dependencies.json');
531
- }
532
-
533
- FileSystem.runPbiviz('package');
534
-
535
- const visualConfig = fs.readJsonSync(path.join(visualPath, 'pbiviz.json')).visual;
536
- const visualCapabilities = fs.readJsonSync(path.join(visualPath, 'capabilities.json'));
537
- const pbivizPath = path.join(visualPath, 'dist', visualName + '.pbiviz');
538
- const pbivizResourcePath = `resources/${visualConfig.guid}.pbiviz.json`;
539
-
540
- visualCapabilities.dataViewMappings[0].scriptResult.script.scriptSourceDefault = scriptSourceDefault;
541
-
542
- let dependencies = '';
543
- if (!removeDependencies) {
544
- dependencies = fs.readJsonSync(path.join(visualPath, 'dependencies.json'));
545
- }
546
-
547
- const zipContents = fs.readFileSync(pbivizPath);
548
- const jszip = new JSZip();
549
- jszip.loadAsync(zipContents)
550
- .then((zip) => {
551
- async.parallel([
552
- //check package.json
553
- (next) => {
554
- zip.file('package.json').async('string')
555
- .then((content) => {
556
- const data = JSON.parse(content);
557
- expect(data.resources.length).toBe(1);
558
- expect(data.resources[0].file).toBe(pbivizResourcePath);
559
- expect(data.visual).toEqual(visualConfig);
560
- next();
561
- })
562
- .catch(next);
563
- },
564
- //check pbiviz
565
- (next) => {
566
- zip.file(pbivizResourcePath).async('string')
567
- .then((content) => {
568
- const data = JSON.parse(content);
569
- expect(data.visual).toEqual(visualConfig);
570
- expect(data.capabilities).toEqual(visualCapabilities);
571
- expect(data.content.js).toBeDefined();
572
- expect(data.content.css).toBeDefined();
573
- expect(data.content.iconBase64).toBeDefined();
574
- if (!removeDependencies) {
575
- expect(data.dependencies).toEqual(dependencies);
576
- }
577
- next();
578
- })
579
- .catch(next);
580
- }
581
- ], error => {
582
- if (error) { throw error; }
583
- done();
584
- });
585
-
586
- });
587
- }
588
-
589
- // new tools doesn't support R visuals build. coming soon
590
- xdescribe("E2E - pbiviz package for R Visual template", () => {
591
-
592
- const visualName = 'visualname';
593
- const visualPath = path.join(tempPath, visualName);
594
-
595
- beforeEach(() => {
596
- FileSystem.resetTempDirectory();
597
- process.chdir(tempPath);
598
- FileSystem.runPbiviz('new', visualName, '--template rvisual');
599
- process.chdir(visualPath);
600
- FileSystem.runCMDCommand('npm i', visualPath);
601
- });
602
-
603
- afterEach(() => {
604
- process.chdir(startPath);
605
- });
606
-
607
- afterAll(() => {
608
- process.chdir(startPath);
609
- FileSystem.deleteTempDirectory();
610
- });
611
-
612
- it("Should throw error if script.r file is missing", () => {
613
- testMissingScript('script.r');
614
- });
615
-
616
- it("Should throw error if dependencies file is not valid", () => {
617
- testErrorInDependencies();
618
- });
619
-
620
- it("Should correctly generate pbiviz file for R Visual template - no dependencies file", (done) => {
621
- const scriptSourceDefault = fs.readFileSync(path.join(visualPath, 'script.r')).toString();
622
- const removeDependencies = true;
623
- testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, removeDependencies);
624
- });
625
-
626
- it("Should correctly generate pbiviz file for R Visual template", (done) => {
627
- const scriptSourceDefault = fs.readFileSync(path.join(visualPath, 'script.r')).toString();
628
- const removeDependencies = false;
629
- testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, removeDependencies);
630
- });
631
- });
632
-
633
- // new tools doesn't support R visuals build. coming soon
634
- xdescribe("E2E - pbiviz package for R HTML template", () => {
635
-
636
- const visualName = 'visualname';
637
- const visualPath = path.join(tempPath, visualName);
638
-
639
- function getScriptSourceDefault() {
640
- const FlattenScriptContent = fs.readFileSync(path.join(visualPath, 'r_files/flatten_HTML.r')).toString();
641
- const scriptContent = fs.readFileSync(path.join(visualPath, 'script.r')).toString();
642
- const pattern = "source('./r_files/flatten_HTML.r')";
643
- return scriptContent.replace(pattern, FlattenScriptContent);
644
- }
645
-
646
- beforeEach(() => {
647
- FileSystem.resetTempDirectory();
648
- process.chdir(tempPath);
649
- FileSystem.runPbiviz('new', visualName, '--template rhtml');
650
- process.chdir(visualPath);
651
- FileSystem.runCMDCommand('npm i', visualPath);
652
- });
653
-
654
- afterEach(() => {
655
- process.chdir(startPath);
656
- });
657
-
658
- afterAll(() => {
659
- process.chdir(startPath);
660
- FileSystem.deleteTempDirectory();
661
- });
662
-
663
- it("Should throw error if script.r file is missing", () => {
664
- testMissingScript('script.r');
665
- });
666
-
667
- it("Should throw error if flatten_HTML.r file is missing", () => {
668
- testMissingScript('r_files/flatten_HTML.r');
669
- });
670
-
671
- it("Should throw error if dependencies file is not valid", () => {
672
- testErrorInDependencies();
673
- });
674
-
675
- it("Should correctly generate pbiviz file for R HTML template - no dependencies file", (done) => {
676
- const scriptSourceDefault = getScriptSourceDefault();
677
- const removeDependencies = true;
678
- testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, removeDependencies);
679
- });
680
-
681
- it("Should correctly generate pbiviz file for R HTML template", (done) => {
682
- const scriptSourceDefault = getScriptSourceDefault();
683
- const removeDependencies = false;
684
- testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, removeDependencies);
685
- });
686
- });