Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
d98a73c
fixed the test cases with oclif/test v4
cs-raj Aug 16, 2024
e82757a
fixed entries test cases
cs-raj Aug 20, 2024
0421e19
fixed other test cases
cs-raj Aug 20, 2024
d2b0d16
version bump
cs-raj Aug 21, 2024
d02d788
Merge branch 'development' into fix/DX-1121
cs-raj Aug 21, 2024
b2e5c59
lockfile fix
cs-raj Aug 21, 2024
b7d4073
removed spy
cs-raj Aug 21, 2024
09d0229
audit version bump to minor version
cs-raj Aug 21, 2024
d8317b7
Merge branch 'development' into fix/DX-1121
cs-raj Aug 21, 2024
2cf2973
PR comment
cs-raj Aug 21, 2024
f57b271
minor var name change
cs-raj Aug 21, 2024
ec696b9
Merge pull request #1524 from contentstack/fix/DX-1121
cs-raj Aug 21, 2024
c261a67
Merge branch 'development' into fix-oclif-test-cases
cs-raj Sep 16, 2024
a290186
commits
cs-raj Sep 18, 2024
759a752
fixed the print in test cases
cs-raj Sep 18, 2024
c487ec0
Merge branch 'development' into fix-oclif-test-cases
cs-raj Sep 20, 2024
3fc1054
fix lock
cs-raj Sep 20, 2024
886fd42
fixed the test cases for marketplace sdk and helpers
cs-raj Sep 20, 2024
77c56dd
version bump
cs-raj Sep 20, 2024
cc71116
Merge pull request #1575 from contentstack/fix/DX-1351
cs-raj Sep 20, 2024
af2ebba
Merge branch 'development' into fix-oclif-test-cases
cs-raj Sep 30, 2024
eaa1f07
lock-file update
cs-raj Sep 30, 2024
1e8ae36
version bumps
cs-raj Sep 30, 2024
eaeebbc
fixed auth Test cases
cs-raj Oct 1, 2024
952ef02
Merge pull request #1599 from contentstack/fix/DX-1338
cs-raj Oct 1, 2024
bcdf1b3
updated test cases
harshithad0703 Oct 7, 2024
15c0676
improve code coverage for region-handler utils
harshithad0703 Oct 7, 2024
06ce6ab
improve code coverage for interactive prompts handlers
harshithad0703 Oct 7, 2024
ef182ef
updated test cases
harshithad0703 Oct 7, 2024
5dabdcb
setting ea header before getting
harshithad0703 Oct 7, 2024
fdcddc2
Merge pull request #1607 from contentstack/test/dx-1343-config-plugin…
harshithad0703 Oct 7, 2024
ea1850d
updated 5 test cases
harshithad0703 Oct 8, 2024
9117162
Testing teams support in CLI export-to-csv
harshithad0703 Oct 10, 2024
200e026
Testing utils function support in CLI export-to-csv
harshithad0703 Oct 10, 2024
6ac536d
export-to-csv with action users
harshithad0703 Oct 10, 2024
9968532
updated test cases which uses prompting
harshithad0703 Oct 10, 2024
4c91645
updated packgae.json to run test for test/util folder
harshithad0703 Oct 10, 2024
b9d366a
updated package-lock
harshithad0703 Oct 10, 2024
0991194
Merge pull request #1623 from contentstack/test/dx-1183-export-to-csv
harshithad0703 Oct 10, 2024
f66a83e
Migrated testcases from v2 to v4 (#1630)
sunil-lakshman Oct 21, 2024
cbbcb2d
Merge branch 'development' into fix-oclif-test-cases
cs-raj Oct 28, 2024
025246d
merged latest development changes
cs-raj Oct 28, 2024
b53b07a
fixed the test cases for oclif v4
cs-raj Oct 30, 2024
034e345
Test migration to v4
cs-raj Oct 30, 2024
1478d02
Merge pull request #1650 from contentstack/fix/DX-1356-test-fix
cs-raj Oct 30, 2024
13e3660
Merge branch 'fix-oclif-test-cases' into fix/DX-1358
cs-raj Oct 30, 2024
8c684f5
Merge pull request #1653 from contentstack/fix/DX-1358
cs-raj Oct 30, 2024
8ce5546
fixed failing test cases
cs-raj Oct 30, 2024
c27b0dc
Merge pull request #1654 from contentstack/fix/test-cases
cs-raj Oct 31, 2024
d526773
fix breaking test cases
cs-raj Oct 31, 2024
e4bac61
Merge pull request #1655 from contentstack/fix/migration-test-cases
cs-raj Oct 31, 2024
f87d5f2
Merged latest development code
cs-raj Nov 7, 2024
20a104e
lock-file update
cs-raj Nov 7, 2024
6d7235e
Merge pull request #1665 from contentstack/fix/branhc
harshithad0703 Nov 8, 2024
618d934
Merge branch 'development' into fix-oclif-test-cases
cs-raj Nov 11, 2024
74feac4
lock-file update
cs-raj Nov 11, 2024
6e06d62
Merge pull request #1672 from contentstack/fix/branch
cs-raj Nov 11, 2024
0f98531
Merge branch 'fix-oclif-test-cases' into fix/DX-1269
cs-raj Nov 11, 2024
bdd645d
fixed the test case
cs-raj Nov 11, 2024
ff6b40a
Merge branch 'fix-oclif-test-cases' into fix/DX-1269
cs-raj Nov 11, 2024
0a63510
Merge pull request #1570 from contentstack/fix/DX-1269
cs-raj Nov 11, 2024
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
2,275 changes: 916 additions & 1,359 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@contentstack/cli-dev-dependencies": "^1.2.4",
"@oclif/test": "^2.5.6",
"@oclif/test": "^4.1.0",
"@types/chai": "^4.3.20",
"@types/fs-extra": "^11.0.4",
"@types/mocha": "^10.0.9",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import fs from 'fs';
import winston from 'winston';
import sinon from 'sinon';
import { resolve } from 'path';
import { fancy } from 'fancy-test';
import { PassThrough } from 'stream';
import { expect } from '@oclif/test';
import { expect } from 'chai';
import { ux, cliux } from '@contentstack/cli-utilities';

import { AuditBaseCommand } from '../../src/audit-base-command';
import { ContentType, Entries, GlobalField, Extensions, Workflows } from '../../src/modules';
import { FileTransportInstance } from 'winston/lib/winston/transports';
import { $t, auditMsg } from '../../src/messages';

describe('AuditBaseCommand class', () => {

class AuditCMD extends AuditBaseCommand {
async run() {
console.warn('warn Reports ready. Please find the reports at');
await this.start('cm:stacks:audit');
}
}
Expand All @@ -28,6 +30,14 @@ describe('AuditBaseCommand class', () => {
filename!: string;
} as FileTransportInstance;

let consoleWarnSpy: sinon.SinonSpy;
beforeEach(() => {
consoleWarnSpy = sinon.spy(console, 'warn');
});
afterEach(() => {
consoleWarnSpy.restore();
sinon.restore(); // Restore all stubs and mocks
});
describe('Audit command flow', () => {
fancy
.stdout({ print: process.env.PRINT === 'true' || false })
Expand All @@ -44,9 +54,13 @@ describe('AuditBaseCommand class', () => {
.stub(Extensions.prototype, 'run', () => ({ ext_1: {} }))
.stub(AuditBaseCommand.prototype, 'showOutputOnScreenWorkflowsAndExtension', () => {})
.stub(fs, 'createWriteStream', () => new PassThrough())
.it('should show audit report path', async (ctx) => {
.it('should show audit report path', async () => {
await AuditCMD.run(['--data-dir', resolve(__dirname, 'mock', 'contents')]);
expect(ctx.stdout).to.includes('warn Reports ready. Please find the reports at');
const warnOutput = consoleWarnSpy
.getCalls()
.map((call) => call.args[0])
.join('');
expect(warnOutput).to.includes('warn Reports ready. Please find the reports at');
});

fancy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import winston from 'winston';
import { resolve } from 'path';
import { fancy } from 'fancy-test';
import { expect } from '@oclif/test';
import { expect } from 'chai';
import { FileTransportInstance } from 'winston/lib/winston/transports';

import { BaseCommand } from '../../src/base-command';
Expand Down
31 changes: 15 additions & 16 deletions packages/contentstack-audit/test/unit/commands/fix.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import fs from 'fs';
import winston from 'winston';
import { expect } from '@oclif/test';
import { fancy } from '@contentstack/cli-dev-dependencies';
import { expect } from 'chai';
import { runCommand } from '@oclif/test';
import * as sinon from 'sinon';
import { FileTransportInstance } from 'winston/lib/winston/transports';

import { AuditBaseCommand } from '../../../src/audit-base-command';
Expand All @@ -11,20 +12,18 @@ describe('AuditFix command', () => {
filename!: string;
} as FileTransportInstance;

// Check this test case later
describe('AuditFix run method', () => {
const test = fancy.loadConfig({ root: process.cwd() });
test
.stdout({ print: process.env.PRINT === 'true' || false })
.stub(fs, 'rmSync', () => {})
.stub(winston.transports, 'File', () => fsTransport)
.stub(winston, 'createLogger', () => ({ log: () => {}, error: () => {} }))
.stub(AuditBaseCommand.prototype, 'start', () => {})
.spy(AuditBaseCommand.prototype, 'start')
.command(['cm:stacks:audit:fix'])
.it('should trigger AuditBaseCommand start method', ({ stdout, spy }) => {
expect(stdout).to.be.empty.string;
expect(spy.start.callCount).to.be.equals(1);
expect(spy.start.args).deep.equal([['cm:stacks:audit:fix']]);
});
sinon.stub(fs, 'rmSync').callsFake(() => {});
sinon.stub(winston.transports, 'File').callsFake(() => fsTransport);
sinon.stub(winston, 'createLogger').call(() => ({ log: () => {}, error: () => {} }));
const startSpy = sinon.stub(AuditBaseCommand.prototype, 'start').callsFake(() => {
return Promise.resolve(true);
});

it('should trigger AuditBaseCommand start method', async () => {
await runCommand(['cm:stacks:audit:fix','-d','data-dir'], { root: process.cwd() });
expect(startSpy.args).to.be.eql([['cm:stacks:audit']]);
});
});
});
28 changes: 14 additions & 14 deletions packages/contentstack-audit/test/unit/commands/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import winston from 'winston';
import { expect, test as fancy } from '@oclif/test';
import { expect } from 'chai';
import { runCommand } from '@oclif/test';
import fancy from 'fancy-test';
import { FileTransportInstance } from 'winston/lib/winston/transports';

import { AuditBaseCommand } from '../../../src/audit-base-command';

describe('Audit command', () => {
const fsTransport = class FsTransport {
filename!: string;
} as FileTransportInstance;

describe('Audit run method', () => {
const test = fancy.loadConfig({ root: process.cwd() });
test
fancy
.stdout({ print: process.env.PRINT === 'true' || false })
.stub(winston.transports, 'File', () => fsTransport)
.stub(winston, 'createLogger', () => ({ log: () => {}, error: () => {} }))
.stub(AuditBaseCommand.prototype, 'start', () => {})
.command(['cm:stacks:audit'])
.it('should trigger AuditBaseCommand start method', ({ stdout }) => {
.it('should trigger AuditBaseCommand start method', async () => {
const { stdout } = await runCommand(['cm:stacks:audit'], { root: process.cwd() });
expect(stdout).to.be.string;
});

test
fancy
.stderr({ print: false })
.stdout({ print: process.env.PRINT === 'true' || false })
.stub(winston.transports, 'File', () => fsTransport)
.stub(winston, 'createLogger', () => ({ log: console.log, error: console.error }))
.stub(AuditBaseCommand.prototype, 'start', () => Promise.reject('process failed'))
.command(['cm:stacks:audit'])
.exit(1)
.it('should log any error and exit with status code 1');
.it('should log any error and exit with status code 1', async () => {
await runCommand(['cm:stacks:audit'], { root: process.cwd() });
});

test
fancy
.stderr({ print: false })
.stdout({ print: process.env.PRINT === 'true' || false })
.stub(winston.transports, 'File', () => fsTransport)
.stub(winston, 'createLogger', () => ({ log: console.log, error: console.error }))
.stub(AuditBaseCommand.prototype, 'start', () => {
throw Error('process failed');
})
.command(['cm:stacks:audit'])
.exit(1)
.it('should log the error objet message and exit with status code 1');
.it('should log the error objet message and exit with status code 1', async () => {
await runCommand(['cm:stacks:audit'], { root: process.cwd() });
});
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fancy } from 'fancy-test';
import { expect } from '@oclif/test';
import { expect } from 'chai';

import { $t, auditMsg } from '../../../src/messages';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs';
import sinon from 'sinon';
import { resolve } from 'path';
import { fancy } from 'fancy-test';
import { expect } from '@oclif/test';
import { expect } from 'chai';
import cloneDeep from 'lodash/cloneDeep';
import { ux } from '@contentstack/cli-utilities';

Expand Down
Loading
Loading