Skip to content

Commit

Permalink
fix: update tables
Browse files Browse the repository at this point in the history
  • Loading branch information
soridalac committed Oct 31, 2024
1 parent d3afbdb commit 84cf92b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/commands/org/delete/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ export class OrgShapeDeleteCommand extends SfCommand<OrgShapeDeleteResult | unde
this.styledHeader('Partial Success');
this.logSuccess(messages.getMessage('humanSuccess', [orgId]));
this.log('');
this.styledHeader('Failures');
this.table({
data: deleteRes.failures,
columns: [
{ key: 'shapeId', name: 'Shape ID' },
{ key: 'message', name: 'Error Message' },
],
title: 'Failures',
});
} else if (deleteRes.failures.length === deleteRes.shapeIds.length) {
setExitCode(1);
Expand Down
11 changes: 2 additions & 9 deletions src/commands/org/list/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,11 @@ export class OrgShapeListCommand extends SfCommand<OrgShapeListResult[]> {
this.info(messages.getMessage('noOrgShapes'));
return orgShapes;
}

this.styledHeader('Org Shapes');
this.table({
data: orgShapes.map((shape) => ({
'ORG ID': shape.orgId,
USERNAME: shape.username,
ALIAS: shape.alias ?? '',
'Shape ID': shape.shapeId,
'Shape Status': shape.status === 'Active' ? StandardColors.success(shape.status) : shape.status,
'CREATED BY': shape.createdBy,
'CREATED DATE': shape.createdDate,
...(shape.status === 'Active' ? { ...shape, status: StandardColors.success(shape.status) } : shape),
})),
title: 'Org Shapes',
});
return orgShapes;
}
Expand Down
8 changes: 4 additions & 4 deletions src/shared/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ export const printSingleRecordTable = (snapshotRecord: OrgSnapshot): void => {
.map(([key, value]: [string, string]) => ({
Name: capitalCase(key),
// format the datetime values
Value: ['LastModifiedDate', 'CreatedDate'].includes(key) ? dateTimeFormatter(value) : value ?? '',
})),
// null/undefined becomes empty string
// .map((row) => (row.Value ? row : { ...row, Value: '' })),
Value: ['LastModifiedDate', 'CreatedDate'].includes(key) ? dateTimeFormatter(value) : value,
}))
// null/undefined becomes empty string
.map((row) => (row.Value ? row : { ...row, Value: '' })),
columns: ['Name', 'Value'],
});
};
Expand Down
10 changes: 6 additions & 4 deletions test/shape/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ describe('org:shape:delete', () => {
expect(uxLogStub.getCalls().some((c) => c.args[0] === 'Successfully deleted org shape for 00D000000000000004.'));
expect(uxLogStub.getCalls().some((c) => c.args[0] === ''));
expect(uxStyledHeaderStub.secondCall.args[0]).to.equal('Failures');
expect(uxTableStub.firstCall.args[0]).to.deep.equal([{ shapeId: '3SR000000000124', message: 'MALFORMED ID' }]);
expect(uxTableStub.firstCall.args[1]).to.deep.equal({
shapeId: { header: 'Shape ID' },
message: { header: 'Error Message' },
expect(uxTableStub.firstCall.args[0]).to.deep.equal({
data: [{ shapeId: '3SR000000000124', message: 'MALFORMED ID' }],
columns: [
{ key: 'shapeId', name: 'Shape ID' },
{ key: 'message', name: 'Error Message' },
],
});
});

Expand Down
12 changes: 6 additions & 6 deletions test/shape/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ describe('org:shape:list', () => {
await command.run();
expect(uxLogStub.notCalled).to.be.true;
expect(uxStyledHeaderStub.firstCall.args[0]).to.equal('Org Shapes');
expect((uxTableStub.firstCall.args[0] as OrgShapeListResult[]).length).to.equal(2);
expect(uxTableStub.firstCall.args[0]).to.deep.equal(
shapes.map((shape) =>
shape.status === 'Active' ? { ...shape, status: StandardColors.success(shape.status) } : shape
)
);
expect((uxTableStub.firstCall.args[0] as { data: OrgShapeListResult[] }).data.length).to.equal(2);
expect(uxTableStub.firstCall.args[0]).to.deep.equal({
data: shapes.map((shape) => ({
...(shape.status === 'Active' ? { ...shape, status: StandardColors.success(shape.status) } : shape),
})),
});
});

it('no devhub org', async () => {
Expand Down

0 comments on commit 84cf92b

Please sign in to comment.