Skip to content

Commit a4c4b03

Browse files
@W-21100984: Adding slimmer EOL precision for a sandbox when under 24 hours in list view
1 parent 03b2b84 commit a4c4b03

3 files changed

Lines changed: 57 additions & 6 deletions

File tree

docs/cli/sandbox.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ b2c sandbox list --json
119119
### Output
120120

121121
```
122-
Realm Instance State Profile Created EOL
122+
Realm Instance State Profile Created EOL
123123
──────────────────────────────────────────────────────────────────────────
124-
abcd 001 started medium 12/20/2024, 10:00 AM 12/21/2024, 10:00 AM
125-
abcd 002 stopped large 12/19/2024, 2:30 PM 12/20/2024, 2:30 PM
124+
abcd 001 started medium 2024-12-20 2024-12-21
125+
abcd 002 stopped large 2024-12-19 2024-12-20 09:30
126126
```
127127

128+
The `EOL` column displays `YYYY-MM-DD` normally. When a sandbox expires within 24 hours (or is already expired), the time is also shown as `YYYY-MM-DD HH:mm` (UTC).
129+
128130
---
129131

130132
## b2c sandbox create

packages/b2c-cli/src/commands/sandbox/list.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface OdsListResponse {
1818
data: SandboxModel[];
1919
}
2020

21-
const COLUMNS: Record<string, ColumnDef<SandboxModel>> = {
21+
export const COLUMNS: Record<string, ColumnDef<SandboxModel>> = {
2222
realm: {
2323
header: 'Realm',
2424
get: (s) => s.realm || '-',
@@ -41,7 +41,18 @@ const COLUMNS: Record<string, ColumnDef<SandboxModel>> = {
4141
},
4242
eol: {
4343
header: 'EOL',
44-
get: (s) => (s.eol ? new Date(s.eol).toISOString().slice(0, 10) : '-'),
44+
get(s) {
45+
if (!s.eol) return '-';
46+
const d = new Date(s.eol);
47+
const date = d.toISOString().slice(0, 10);
48+
const msUntilEol = d.getTime() - Date.now();
49+
if (msUntilEol <= 24 * 60 * 60 * 1000) {
50+
const hh = String(d.getUTCHours()).padStart(2, '0');
51+
const mm = String(d.getUTCMinutes()).padStart(2, '0');
52+
return `${date} ${hh}:${mm}`;
53+
}
54+
return date;
55+
},
4556
},
4657
id: {
4758
header: 'ID',

packages/b2c-cli/test/commands/sandbox/list.test.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import {expect} from 'chai';
88
import sinon from 'sinon';
9-
import SandboxList from '../../../src/commands/sandbox/list.js';
9+
import SandboxList, {COLUMNS} from '../../../src/commands/sandbox/list.js';
1010
import {isolateConfig, restoreConfig} from '@salesforce/b2c-tooling-sdk/test-utils';
1111
import {runSilent} from '../../helpers/test-setup.js';
1212

@@ -97,6 +97,44 @@ describe('sandbox list', () => {
9797
});
9898
});
9999

100+
describe('eol column formatting', () => {
101+
const getEol = COLUMNS.eol.get;
102+
103+
it('returns "-" when eol is missing', () => {
104+
expect(getEol({} as any)).to.equal('-');
105+
});
106+
107+
it('returns YYYY-MM-DD when EOL is more than 24 hours away', () => {
108+
const future = new Date(Date.now() + 48 * 60 * 60 * 1000).toISOString();
109+
const result = getEol({eol: future} as any);
110+
expect(result).to.match(/^\d{4}-\d{2}-\d{2}$/);
111+
});
112+
113+
it('returns YYYY-MM-DD HH:mm when EOL is within 24 hours', () => {
114+
const soon = new Date(Date.now() + 2 * 60 * 60 * 1000).toISOString();
115+
const result = getEol({eol: soon} as any);
116+
expect(result).to.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/);
117+
});
118+
119+
it('returns YYYY-MM-DD HH:mm for an already-expired EOL', () => {
120+
const past = new Date(Date.now() - 60 * 60 * 1000).toISOString();
121+
const result = getEol({eol: past} as any);
122+
expect(result).to.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/);
123+
});
124+
125+
it('returns correct UTC time in YYYY-MM-DD HH:mm format', () => {
126+
// Fixed timestamp: 2026-02-20T09:30:00Z — within 24h from now in the test
127+
const eolTime = new Date(Date.now() + 30 * 60 * 1000).toISOString(); // 30 minutes away
128+
const d = new Date(eolTime);
129+
const expectedDate = d.toISOString().slice(0, 10);
130+
const expectedHH = String(d.getUTCHours()).padStart(2, '0');
131+
const expectedMM = String(d.getUTCMinutes()).padStart(2, '0');
132+
133+
const result = getEol({eol: eolTime} as any);
134+
expect(result).to.equal(`${expectedDate} ${expectedHH}:${expectedMM}`);
135+
});
136+
});
137+
100138
describe('filter parameter building', () => {
101139
it('should build filter params from realm flag', () => {
102140
const command = new SandboxList([], {} as any);

0 commit comments

Comments
 (0)