Skip to content

Commit c27b0dc

Browse files
authored
Merge pull request #1654 from contentstack/fix/test-cases
fixed failing test cases
2 parents 8c684f5 + 8ce5546 commit c27b0dc

File tree

1 file changed

+39
-40
lines changed

1 file changed

+39
-40
lines changed

packages/contentstack-migrate-rte/test/commands/json-migration.test.js

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('Migration Config validation', () => {
3636
expect(error.message).to.contain();
3737
})
3838
.it('deny config confirmation', async () => {
39-
const { stderr } = await runCommand(
39+
const { error } = await runCommand(
4040
[
4141
'cm:entries:migrate-html-rte',
4242
'--alias',
@@ -52,36 +52,35 @@ describe('Migration Config validation', () => {
5252
],
5353
{ root: process.cwd() },
5454
);
55-
56-
expect(stderr.message).to.contain('User aborted the command.');
55+
expect(error.message).to.contain('User aborted the command.');
5756
});
5857

5958
fancy
6059
.stub(cliux, 'confirm', () => true)
6160
.stub(command, 'getToken', getTokenCallback)
6261
.it('throw error on Empty paths', async () => {
63-
const {stderr} = await runCommand(
62+
const {error} = await runCommand(
6463
['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/configWithEmptyPath.json', '--yes'],
6564
{ root: process.cwd() },
6665
);
67-
expect(stderr.message).to.contain('No value provided for the "paths" property in config.');
66+
expect(error.message).to.contain('No value provided for the "paths" property in config.');
6867
});
6968

7069
fancy
7170
.stub(cliux, 'confirm', () => true)
7271
.stub(command, 'getToken', getTokenCallback)
7372
.it('throw error on invalid config type', async () => {
74-
const {stderr} = await runCommand(
73+
const {error} = await runCommand(
7574
['cm:entries:migrate-html-rte', '--config-path', '../test/dummy/config/invalidConfig.json', '--yes'],
7675
{ root: process.cwd() },
7776
);
78-
expect(stderr.message).to.contain('Invalid key type. alias must be of string type(s).');
77+
expect(error.message).to.contain('Invalid key type. alias must be of string type(s).');
7978
});
8079

8180
fancy
8281
.stub(cliux, 'confirm', () => true)
8382
.it('throw error on config without alias property', async () => {
84-
const { stderr } = await runCommand(
83+
const { error } = await runCommand(
8584
[
8685
'cm:entries:migrate-html-rte',
8786
'--content-type',
@@ -95,14 +94,14 @@ describe('Migration Config validation', () => {
9594
],
9695
{ root: process.cwd() },
9796
);
98-
expect(stderr.message).to.contain('alias is mandatory while defining config.');
97+
expect(error.message).to.contain('alias is mandatory while defining config.');
9998
});
10099

101100
fancy
102101
.stub(cliux, 'confirm', () => true)
103102
.stub(command, 'getToken', getTokenCallback)
104103
.it('throw error on invalidAlias', async () => {
105-
const { stderr } = await runCommand(
104+
const { error } = await runCommand(
106105
[
107106
'cm:entries:migrate-html-rte',
108107
'--alias',
@@ -118,18 +117,18 @@ describe('Migration Config validation', () => {
118117
],
119118
{ root: process.cwd() },
120119
);
121-
expect(stderr.message).to.contain('Invalid alias provided for the management token.');
120+
expect(error.message).to.contain('Invalid alias provided for the management token.');
122121
});
123122

124123
fancy
125124
.stub(cliux, 'confirm', () => true)
126125
.stub(command, 'getToken', getTokenCallback)
127126
.it('throw error on invalid config file', async () => {
128-
const { stderr } = await runCommand(
127+
const { error } = await runCommand(
129128
['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/configWithInvalidPath.json', '--yes'],
130129
{ root: process.cwd() },
131130
);
132-
expect(stderr.message).to.contain('The specified path to config file does not exist.');
131+
expect(error.message).to.contain('The specified path to config file does not exist.');
133132
});
134133
});
135134
describe('Content Type with Single RTE Field of Single Type', function () {
@@ -291,7 +290,7 @@ describe('Content Type with Single RTE Field of Single Type', function () {
291290
.stub(command, 'getToken', getTokenCallback)
292291
.it('execute using config file w/ locale', async () => {
293292
const { stdout } = await runCommand(
294-
['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/config_locale.json', '--yes'],
293+
['cm:entries:migrate-html-rte', '--config-path', '/Users/raj.pandey/Documents/cli13/cli/packages/contentstack-migrate-rte/test/dummy/config/config_locale.json', '--yes'],
295294
{ root: process.cwd() },
296295
);
297296
expect(stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)');
@@ -358,7 +357,7 @@ describe('Content Type with Single RTE Field of Single Type', function () {
358357
.stub(cliux, 'confirm', () => 'yes')
359358
.stub(command, 'getToken', getTokenCallback)
360359
.it('throw error on invalid html rte path', async () => {
361-
const { stderr } = await runCommand([
360+
const { error } = await runCommand([
362361
'cm:entries:migrate-html-rte',
363362
'--alias',
364363
'test1',
@@ -372,14 +371,14 @@ describe('Content Type with Single RTE Field of Single Type', function () {
372371
'--delay',
373372
'50',
374373
],{ root: process.cwd() });
375-
expect(stderr.message).to.contain('The specified path to invalidPath HTML RTE does not exist.');
374+
expect(error.message).to.contain('The specified path to invalidPath HTML RTE does not exist.');
376375
});
377376

378377
fancy
379378
.stub(cliux, 'confirm', () => 'yes')
380379
.stub(command, 'getToken', getTokenCallback)
381380
.it('throw error on invalid html rte field schema', async () => {
382-
const { stderr } = await runCommand(
381+
const { error } = await runCommand(
383382
[
384383
'cm:entries:migrate-html-rte',
385384
'--alias',
@@ -396,14 +395,14 @@ describe('Content Type with Single RTE Field of Single Type', function () {
396395
],
397396
{ root: process.cwd() },
398397
);
399-
expect(stderr.message).to.contain('The specified path to rich_text_editor HTML RTE does not exist.');
398+
expect(error.message).to.contain('The specified path to rich_text_editor HTML RTE does not exist.');
400399
});
401400

402401
fancy
403402
.stub(cliux, 'confirm', () => 'yes')
404403
.stub(command, 'getToken', getTokenCallback)
405404
.it('throw error on invalid json rte field schema', async () => {
406-
const { stderr } = await runCommand(
405+
const { error } = await runCommand(
407406
[
408407
'cm:entries:migrate-html-rte',
409408
'--alias',
@@ -420,13 +419,13 @@ describe('Content Type with Single RTE Field of Single Type', function () {
420419
],
421420
{ root: process.cwd() },
422421
);
423-
expect(stderr.message).to.contain('The specified path to supercharged_rte JSON RTE does not exist.');
422+
expect(error.message).to.contain('The specified path to supercharged_rte JSON RTE does not exist.');
424423
});
425424
fancy
426425
.stub(cliux, 'confirm', () => 'yes')
427426
.stub(command, 'getToken', getTokenCallback)
428427
.it('throw error on invalid json rte path', async () => {
429-
const { stderr } = await runCommand(
428+
const { error } = await runCommand(
430429
[
431430
'cm:entries:migrate-html-rte',
432431
'--alias',
@@ -443,14 +442,14 @@ describe('Content Type with Single RTE Field of Single Type', function () {
443442
],
444443
{ root: process.cwd() },
445444
);
446-
expect(stderr.message).to.contain('The specified path to invalidPath JSON RTE does not exist.');
445+
expect(error.message).to.contain('The specified path to invalidPath JSON RTE does not exist.');
447446
});
448447

449448
fancy
450449
.stub(cliux, 'confirm', () => 'yes')
451450
.stub(command, 'getToken', getTokenCallback)
452451
.it('throw error on migration of Mutiple Html rte with single Json rte', async () => {
453-
const { stderr } = await runCommand(
452+
const { error } = await runCommand(
454453
[
455454
'cm:entries:migrate-html-rte',
456455
'--config-path',
@@ -459,14 +458,14 @@ describe('Content Type with Single RTE Field of Single Type', function () {
459458
],
460459
{ root: process.cwd() },
461460
);
462-
expect(stderr.message).to.contain('Cannot convert "Multiple" type HTML RTE to "Single" type JSON RTE.');
461+
expect(error.message).to.contain('Cannot convert "Multiple" type HTML RTE to "Single" type JSON RTE.');
463462
});
464463

465464
fancy
466465
.stub(cliux, 'confirm', () => 'yes')
467466
.stub(command, 'getToken', getTokenCallback)
468467
.it('throw error on content type with empty schema', async () => {
469-
const { stderr } = await runCommand(
468+
const { error } = await runCommand(
470469
[
471470
'cm:entries:migrate-html-rte',
472471
'--alias',
@@ -483,14 +482,14 @@ describe('Content Type with Single RTE Field of Single Type', function () {
483482
],
484483
{ root: process.cwd() },
485484
);
486-
expect(stderr.message).to.contain('The contenttypewithemptyschema content type contains an empty schema.');
485+
expect(error.message).to.contain('The contenttypewithemptyschema content type contains an empty schema.');
487486
});
488487

489488
fancy
490489
.stub(cliux, 'confirm', () => 'yes')
491490
.stub(command, 'getToken', getTokenCallback)
492491
.it('throw error on different level rte migration', async () => {
493-
const { stderr } = await runCommand(
492+
const { error } = await runCommand(
494493
[
495494
'cm:entries:migrate-html-rte',
496495
'--alias',
@@ -507,7 +506,7 @@ describe('Content Type with Single RTE Field of Single Type', function () {
507506
],
508507
{ root: process.cwd() },
509508
);
510-
expect(stderr.message).to.contain(
509+
expect(error.message).to.contain(
511510
'To complete migration, HTML RTE and JSON RTE should be present at the same field depth level.',
512511
);
513512
});
@@ -516,7 +515,7 @@ describe('Content Type with Single RTE Field of Single Type', function () {
516515
.stub(cliux, 'confirm', () => true)
517516
.stub(command, 'getToken', getTokenCallback)
518517
.it('throw error on invalid contenttype', async () => {
519-
const { stderr } = await runCommand(
518+
const { error } = await runCommand(
520519
[
521520
'cm:entries:migrate-html-rte',
522521
'--alias',
@@ -532,7 +531,7 @@ describe('Content Type with Single RTE Field of Single Type', function () {
532531
],
533532
{ root: process.cwd() },
534533
);
535-
expect(stderr.message).to.contain("The Content Type 'invalidContentType' was not found. Please try again.");
534+
expect(error.message).to.contain("The Content Type 'invalidContentType' was not found. Please try again.");
536535
});
537536

538537
fancy
@@ -613,7 +612,7 @@ describe('Global Field Migration', () => {
613612
.stub(cliux, 'confirm', () => 'yes')
614613
.stub(command, 'getToken', getTokenCallback)
615614
.it('throw error on global field with empty referred content_types', async () => {
616-
const { stderr } = await runCommand(
615+
const { error } = await runCommand(
617616
[
618617
'cm:entries:migrate-html-rte',
619618
'--alias',
@@ -631,14 +630,14 @@ describe('Global Field Migration', () => {
631630
],
632631
{ root: process.cwd() },
633632
);
634-
expect(stderr.message).to.contain('globalfieldformigration Global field is not referred in any content type.');
633+
expect(error.message).to.contain('globalfieldformigration Global field is not referred in any content type.');
635634
});
636635

637636
fancy
638637
.stub(cliux, 'confirm', () => 'yes')
639638
.stub(command, 'getToken', getTokenCallback)
640639
.it('throw error on global field with invalid content_type', async () => {
641-
const { stderr } = await runCommand(
640+
const { error } = await runCommand(
642641
[
643642
'cm:entries:migrate-html-rte',
644643
'--alias',
@@ -656,7 +655,7 @@ describe('Global Field Migration', () => {
656655
],
657656
{ root: process.cwd() },
658657
);
659-
expect(stderr.message).to.contain(
658+
expect(error.message).to.contain(
660659
'The contenttypewithemptyschema content type referred in globalfieldformigration contains an empty schema.',
661660
);
662661
});
@@ -665,7 +664,7 @@ describe('Global Field Migration', () => {
665664
.stub(cliux, 'confirm', () => 'yes')
666665
.stub(command, 'getToken', getTokenCallback)
667666
.it('throw error on global field with empty schema', async () => {
668-
const { stderr } = await runCommand(
667+
const { error } = await runCommand(
669668
[
670669
'cm:entries:migrate-html-rte',
671670
'--alias',
@@ -683,14 +682,14 @@ describe('Global Field Migration', () => {
683682
],
684683
{ root: process.cwd() },
685684
);
686-
expect(stderr.message).to.contain('The globalfieldwithemptyschema Global field contains an empty schema.');
685+
expect(error.message).to.contain('The globalfieldwithemptyschema Global field contains an empty schema.');
687686
});
688687

689688
fancy
690689
.stub(cliux, 'confirm', () => 'yes')
691690
.stub(command, 'getToken', getTokenCallback)
692691
.it('throw error on global field with empty schema content_type', async () => {
693-
const { stderr } = await runCommand(
692+
const { error } = await runCommand(
694693
[
695694
'cm:entries:migrate-html-rte',
696695
'--alias',
@@ -708,7 +707,7 @@ describe('Global Field Migration', () => {
708707
],
709708
{ root: process.cwd() },
710709
);
711-
expect(stderr.message).to.contain(
710+
expect(error.message).to.contain(
712711
'The contenttypewithemptyschema content type referred in globalfieldwithemptyschemacontenttype contains an empty schema.',
713712
);
714713
});
@@ -717,7 +716,7 @@ describe('Global Field Migration', () => {
717716
.stub(cliux, 'confirm', () => 'yes')
718717
.stub(command, 'getToken', getTokenCallback)
719718
.it('throw error on invalid global_field uid', async () => {
720-
const { stderr } = await runCommand(
719+
const { error } = await runCommand(
721720
[
722721
'cm:entries:migrate-html-rte',
723722
'--alias',
@@ -735,7 +734,7 @@ describe('Global Field Migration', () => {
735734
],
736735
{ root: process.cwd() },
737736
);
738-
expect(stderr.message).to.contain("The Global Field 'invalidUidGlobalfield' was not found. Please try again.");
737+
expect(error.message).to.contain("The Global Field 'invalidUidGlobalfield' was not found. Please try again.");
739738
});
740739
});
741740

0 commit comments

Comments
 (0)