Skip to content

Commit

Permalink
Merge pull request #1649 from contentstack/fix/DX-1358-fix-development
Browse files Browse the repository at this point in the history
fixed existing test cases for running
  • Loading branch information
cs-raj authored Oct 28, 2024
2 parents 0bab278 + 87b5650 commit e49bdfd
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 216 deletions.
315 changes: 180 additions & 135 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions packages/contentstack-migration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"async": "^3.2.6",
"callsites": "^3.1.0",
"cardinal": "^2.1.1",
"chalk": "^4.1.0",
"chalk": "^4.1.2",
"concat-stream": "^2.0.0",
"dot-object": "^2.1.5",
"dotenv": "^16.4.5",
"listr": "^0.14.3",
Expand All @@ -18,15 +19,15 @@
"devDependencies": {
"@oclif/test": "^2.5.6",
"chai": "^4.5.0",
"eslint": "^8.18.0",
"eslint": "^8.57.1",
"globby": "^10.0.2",
"husky": "^8.0.3",
"jsdoc": "^4.0.3",
"jsdoc": "^4.0.4",
"jsdoc-to-markdown": "^8.0.3",
"mkdirp": "^1.0.4",
"nock": "^13.5.5",
"nyc": "^15.1.0",
"oclif": "^3.11.3"
"oclif": "^3.17.2"
},
"engines": {
"node": ">=8.3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('Create content type from migration script', () => {
describe('Create content type with passing options as arguments', () => {
nockBack('create-content-type.json', (nockDone) => {
test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
'cm:migration',
Expand All @@ -27,6 +28,7 @@ describe('Create content type from migration script', () => {
});

test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
'cm:migration',
Expand All @@ -42,6 +44,7 @@ describe('Create content type from migration script', () => {
});

test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
'cm:migration',
Expand All @@ -60,6 +63,7 @@ describe('Create content type from migration script', () => {

describe('should show error for misspelled properties', () => {
test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
'cm:migration',
Expand All @@ -74,6 +78,7 @@ describe('Create content type from migration script', () => {
});

test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
'cm:migration',
Expand All @@ -89,6 +94,7 @@ describe('Create content type from migration script', () => {

nockBack('missing-required-field.json', (nockDone) => {
test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
'cm:migration',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('Delete field test from migration script', () => {

describe('prepare for field test', () => {
test
.loadConfig({ root: process.cwd() })
.command([
'cm:migration',
'-n',
Expand All @@ -27,6 +28,7 @@ describe('Delete field test from migration script', () => {
describe('Delete field', () => {
nockBack('delete-field.json', (nockDone) => {
test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
'cm:migration',
Expand All @@ -42,6 +44,7 @@ describe('Delete field test from migration script', () => {
});

test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
'cm:migration',
Expand All @@ -60,6 +63,7 @@ describe('Delete field test from migration script', () => {

describe('wind up field test', () => {
test
.loadConfig({ root: process.cwd() })
.command([
'cm:migration',
'-n',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('Edit content type from migration script', () => {
nockBack.setMode('record');
describe('prepare for edit field test', () => {
test
.loadConfig({ root: process.cwd() })
.command([
'cm:migration',
'-n',
Expand All @@ -25,6 +26,7 @@ describe('Edit content type from migration script', () => {
describe('Allow editing existing content type', () => {
nockBack('edit-content-type.json', (nockDone) => {
test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
'cm:migration',
Expand All @@ -40,6 +42,7 @@ describe('Edit content type from migration script', () => {
});

test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
'cm:migration',
Expand All @@ -63,6 +66,7 @@ describe('Edit content type from migration script', () => {
// })

test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
'cm:migration',
Expand All @@ -80,6 +84,7 @@ describe('Edit content type from migration script', () => {
});
describe('wind up field test', () => {
test
.loadConfig({ root: process.cwd() })
.command([
'cm:migration',
'-n',
Expand Down
84 changes: 42 additions & 42 deletions packages/contentstack-migration/test/commands/edit-field.test.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
"use strict";
'use strict';

const { constants } = require("../setup");
const { constants } = require('../setup');
const { migrationPath } = constants;
const path = require("path");
const nockBack = require("nock").back;
const { expect, test } = require("@oclif/test");
const path = require('path');
const nockBack = require('nock').back;
const { expect, test } = require('@oclif/test');

describe("Edit field test", () => {
nockBack.fixtures = path.join(__dirname, "__nock-fixtures__");
nockBack.setMode("record");
describe("prepare for edit field test", () => {
describe('Edit field test', () => {
nockBack.fixtures = path.join(__dirname, '__nock-fixtures__');
nockBack.setMode('record');
describe('prepare for edit field test', () => {
test
.loadConfig({ root: process.cwd() })
.command([
"cm:migration",
"-n",
'cm:migration',
'-n',
`${migrationPath}/create-ct/create-ct-opts.js`,
"-A",
"-k",
"bltmock9e992a923aafdmock521adc4b5b3",
'-A',
'-k',
'bltmock9e992a923aafdmock521adc4b5b3',
])
.it("Should create content type", () => {});
.it('Should create content type', () => {});
});
describe("prepare for edit field test", () => {
nockBack("edit-field.json", (nockDone) => {
describe('prepare for edit field test', () => {
nockBack('edit-field.json', (nockDone) => {
test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
"cm:migration",
"-n",
'cm:migration',
'-n',
`${migrationPath}/edit-field/edit-field.js`,
"-A",
"-k",
"bltmock9e992a923aafdmock521adc4b5b3",
'-A',
'-k',
'bltmock9e992a923aafdmock521adc4b5b3',
])
.it("Should edit the field successfully for content type", (ctx) => {
expect(ctx.stdout).to.contains(
"Successfully updated content type: foo3"
);
.it('Should edit the field successfully for content type', (ctx) => {
expect(ctx.stdout).to.contains('Successfully updated content type: foo3');
nockDone();
});

Expand All @@ -49,33 +49,33 @@ describe("Edit field test", () => {
// })

test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
"cm:migration",
"-n",
'cm:migration',
'-n',
`${migrationPath}/edit-field/edit-invalid-method.js`,
"-A",
"-k",
"bltmock9e992a923aafdmock521adc4b5b3",
'-A',
'-k',
'bltmock9e992a923aafdmock521adc4b5b3',
])
.it("Should show error message invalid method access", (ctx) => {
expect(ctx.stdout).to.contains(
" display_nam is not a valid function"
);
.it('Should show error message invalid method access', (ctx) => {
expect(ctx.stdout).to.contains(' display_nam is not a valid function');
nockDone();
});
});
});
describe("wind up field test", () => {
describe('wind up field test', () => {
test
.loadConfig({ root: process.cwd() })
.command([
"cm:migration",
"-n",
'cm:migration',
'-n',
`${migrationPath}/edit-ct/delete-ct.js`,
"-A",
"-k",
"bltmock9e992a923aafdmock521adc4b5b3",
'-A',
'-k',
'bltmock9e992a923aafdmock521adc4b5b3',
])
.it("Should delete content type", () => {});
.it('Should delete content type', () => {});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe("Move field test from migration script", () => {
nockBack.setMode("record");
describe("prepare for edit field test", () => {
test
.loadConfig({ root: process.cwd() })
.command([
"cm:migration",
"-n",
Expand All @@ -24,6 +25,7 @@ describe("Move field test from migration script", () => {
describe("Move field", () => {
nockBack("move-field.json", (nockDone) => {
test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
"cm:migration",
Expand All @@ -41,6 +43,7 @@ describe("Move field test from migration script", () => {
});

test
.loadConfig({ root: process.cwd() })
.stdout()
.command([
"cm:migration",
Expand All @@ -58,6 +61,7 @@ describe("Move field test from migration script", () => {
});
describe("wind up field test", () => {
test
.loadConfig({ root: process.cwd() })
.command([
"cm:migration",
"-n",
Expand Down
Loading

0 comments on commit e49bdfd

Please sign in to comment.