Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f973439
feat: add session file in session based logger
Dec 4, 2025
7ecdfac
updated import test cases
Dec 4, 2025
2ed881e
Merge branch 'development' into feat/DX-3763
Dec 8, 2025
c863bd7
resolved comments
Dec 8, 2025
ada8f3f
fix test cases
Dec 8, 2025
d26e9e9
fix: resolve stack-clone auth failure for non-NA regions
harshithad0703 Dec 15, 2025
8f4a9c0
Merge branch 'main' into fix/dx-3808-clone-session-timeout
harshithad0703 Dec 15, 2025
14c5973
Merge pull request #2282 from contentstack/main
harshithad0703 Dec 15, 2025
c36229e
Merge branch 'development' into feat/DX-3763
Dec 16, 2025
5861034
Merge pull request #2261 from contentstack/feat/DX-3763
naman-contentstack Dec 16, 2025
b9c7b81
added missing import in clone
Dec 19, 2025
e79f9af
Merge branch 'development' into feat/DX-3763
naman-contentstack Dec 19, 2025
7455a69
Merge pull request #2287 from contentstack/feat/DX-3763
AniketDev7 Dec 19, 2025
00414c5
chore: license update
cs-raj Jan 2, 2026
84d98d4
Merge branch 'development' into fix/dx-3808-clone-session-timeout
harshithad0703 Jan 7, 2026
a35b910
Merge pull request #2291 from contentstack/fix/licenseupdate
cs-raj Jan 7, 2026
7304dbb
Update version for contentstack-clone to 1.18.2
harshithad0703 Jan 8, 2026
471d168
update package lock
harshithad0703 Jan 8, 2026
fa39b0a
Merge branch 'development' into fix/dx-3808-clone-session-timeout
harshithad0703 Jan 8, 2026
904f265
update changeLog
harshithad0703 Jan 8, 2026
4b8d913
Merge pull request #2281 from contentstack/fix/dx-3808-clone-session-…
harshithad0703 Jan 8, 2026
39333c4
bump version of contentstack-clone to 1.18.1 in package.json and upda…
harshithad0703 Jan 9, 2026
6eace75
Merge pull request #2300 from contentstack/fix/version-bump-clone
harshithad0703 Jan 9, 2026
1878253
version bump to 1.54.0
harshithad0703 Jan 9, 2026
3e03980
Merge pull request #2302 from contentstack/fix/version-bump
aman19K Jan 9, 2026
46a2f18
Merge pull request #2298 from contentstack/development
harshithad0703 Jan 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated import test cases
  • Loading branch information
naman-contentstack committed Dec 4, 2025
commit 7ecdfac2ec96a3e24b4b44506c16d7dd6f54abce
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fileignoreconfig:
- filename: packages/contentstack-audit/src/modules/content-types.ts
checksum: ddf7b08e6a80af09c6a7019a637c26089fb76572c7c3d079a8af244b02985f16
- filename: packages/contentstack-import/test/unit/commands/cm/stacks/import.test.ts
checksum: b11e57f1b824d405f86438e9e7c59183f8c59b66b42d8d16dbeaf76195a30548
checksum: ead3c34bad34f912d8663599273d26a95bb48220e16d9e9e3d33f5c064a487a5
- filename: packages/contentstack-import/test/unit/utils/asset-helper.test.ts
checksum: 8e83200ac8028f9289ff1bd3a50d191b35c8e28f1854141c90fa1b0134d6bf8a
- filename: packages/contentstack-import/test/unit/import/modules/marketplace-apps.test.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { fancy } from 'fancy-test';
import sinon from 'sinon';
import { managementSDKClient, configHandler, log, handleAndLogError, getLogPath } from '@contentstack/cli-utilities';
import { managementSDKClient, configHandler, log, handleAndLogError, getLogPath, createLogContext } from '@contentstack/cli-utilities';
import ImportCommand from '../../../../../src/commands/cm/stacks/import';
import { ModuleImporter } from '../../../../../src/import';
import { ImportConfig } from '../../../../../src/types';
Expand Down Expand Up @@ -201,18 +201,27 @@ describe('ImportCommand', () => {
});
});

describe('createImportContext', () => {
describe('createLogContext', () => {
let configHandlerStub: sinon.SinonStub;
let configHandlerSetStub: sinon.SinonStub;

beforeEach(() => {
configHandlerStub = sinon.stub(configHandler, 'get');
configHandlerStub.withArgs('userUid').returns('user-123');
configHandlerSetStub = sinon.stub(configHandler, 'set');
configHandlerStub.withArgs('clientId').returns('user-123');
configHandlerStub.withArgs('email').returns('[email protected]');
configHandlerStub.withArgs('sessionId').returns('test-session-123');
configHandlerStub.withArgs('oauthOrgUid').returns('org-123');
configHandlerStub.withArgs('authorisationType').returns('BASIC');
});

afterEach(() => {
configHandlerStub.restore();
configHandlerSetStub.restore();
});

it('should create context with all required properties', () => {
const context = command['createImportContext']('test', 'Basic Auth');
const context = createLogContext('cm:stacks:import', 'test', 'Basic Auth');

expect(context).to.have.property('command', 'cm:stacks:import');
expect(context).to.have.property('module', '');
Expand All @@ -222,10 +231,11 @@ describe('ImportCommand', () => {
expect(context).to.have.property('apiKey', 'test');
expect(context).to.have.property('orgId', 'org-123');
expect(context).to.have.property('authenticationMethod', 'Basic Auth');
expect(configHandlerSetStub.calledWith('apiKey', 'test')).to.be.true;
});

it('should use default authentication method when not provided', () => {
const context = command['createImportContext']('test');
const context = createLogContext('cm:stacks:import', 'test');

expect(context.authenticationMethod).to.equal('Basic Auth');
});
Expand All @@ -234,22 +244,22 @@ describe('ImportCommand', () => {
configHandlerStub.reset();
configHandlerStub.returns(undefined);

const context = command['createImportContext']('test', 'Management Token');
const context = createLogContext('cm:stacks:import', 'test', 'Management Token');

expect(context.userId).to.equal('');
expect(context.email).to.equal('');
expect(context.orgId).to.equal('');
expect(context.authenticationMethod).to.equal('Management Token');
});

it('should use context command when available', () => {
const context = command['createImportContext']('test');
it('should use provided command', () => {
const context = createLogContext('cm:stacks:import', 'test');

expect(context.command).to.equal('cm:stacks:import');
});

it('should handle empty apiKey', () => {
const context = command['createImportContext']('');
const context = createLogContext('cm:stacks:import', '');

expect(context.apiKey).to.equal('');
});
Expand Down Expand Up @@ -503,35 +513,43 @@ describe('ImportCommand', () => {
configHandlerStub = sinon.stub(configHandler, 'get');
});

it('should handle undefined context', () => {
(command as any).context = undefined;
afterEach(() => {
configHandlerStub.restore();
});

it('should handle command string directly', () => {
configHandlerStub.returns(undefined);

const context = command['createImportContext']('test');
const context = createLogContext('cm:stacks:import', 'test');

expect(context.command).to.equal('cm:stacks:import');
});

it('should handle context without info', () => {
(command as any).context = { sessionId: 'test-session' };
it('should use command string when provided', () => {
configHandlerStub.withArgs('clientId').returns('user-123');
configHandlerStub.withArgs('email').returns('[email protected]');
configHandlerStub.withArgs('sessionId').returns('test-session');
configHandlerStub.withArgs('oauthOrgUid').returns('org-123');
configHandlerStub.withArgs('authorisationType').returns('BASIC');

const context = command['createImportContext']('test');
const context = createLogContext('cm:stacks:import', 'test');

expect(context.command).to.equal('cm:stacks:import');
expect(context.sessionId).to.equal('test-session');
});

it('should handle context without sessionId', () => {
(command as any).context = { info: { command: 'test' } };
it('should handle missing sessionId from configHandler', () => {
configHandlerStub.returns(undefined);

const context = command['createImportContext']('test');
const context = createLogContext('cm:stacks:import', 'test');

expect(context.sessionId).to.be.undefined;
expect(context.sessionId).to.equal('');
});

it('should handle configHandler throwing errors', () => {
configHandlerStub.reset();
it('should handle configHandler returning undefined values', () => {
configHandlerStub.returns(undefined);

const context = command['createImportContext']('test');
const context = createLogContext('cm:stacks:import', 'test');

expect(context.userId).to.equal('');
expect(context.email).to.equal('');
Expand Down
Loading