news screen enhancement - 1

This commit is contained in:
saikiranvella
2026-06-09 20:11:10 -04:00
parent 662a717916
commit bac00ab5d5
13 changed files with 250 additions and 35 deletions
+22 -20
View File
@@ -12,13 +12,13 @@ class MockMarketCallRepository {
quarter: 'Q2 2024',
thesis: 'Strong iPhone sales cycle',
tickers: ['AAPL'],
date: new Date('2024-05-01'),
snapshots: [{ ticker: 'AAPL', price: 180, date: new Date('2024-05-01') }],
date: '2024-05-01',
snapshot: {},
},
];
async list(): Promise<(MarketCall & { id: string })[]> {
return this.calls.sort((a, b) => b.date.getTime() - a.date.getTime());
return this.calls.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
}
async get(id: string): Promise<(MarketCall & { id: string }) | null> {
@@ -27,7 +27,7 @@ class MockMarketCallRepository {
async create(call: MarketCall): Promise<MarketCall & { id: string }> {
const id = String(this.calls.length + 1);
const newCall = { id, ...call };
const newCall = { ...call, id };
this.calls.push(newCall);
return newCall;
}
@@ -152,7 +152,7 @@ test('CallsController', async (t) => {
const calls = await repository.list();
assert.ok(Array.isArray(calls));
assert.equal(calls.length, 1);
assert.equal(calls[0].ticker || calls[0].title, 'AAPL Post-Earnings' || 'AAPL');
assert.equal(calls[0].title, 'AAPL Post-Earnings');
});
await t.test('returns calls sorted by date (newest first)', async () => {
@@ -164,8 +164,8 @@ test('CallsController', async (t) => {
quarter: 'Q1 2024',
thesis: 'Old thesis',
tickers: ['AAPL'],
date: new Date('2024-01-01'),
snapshots: [],
date: '2024-01-01',
snapshot: {},
},
{
id: '2',
@@ -173,13 +173,13 @@ test('CallsController', async (t) => {
quarter: 'Q2 2024',
thesis: 'New thesis',
tickers: ['MSFT'],
date: new Date('2024-05-01'),
snapshots: [],
date: '2024-05-01',
snapshot: {},
},
];
async list() {
return this.calls.sort((a, b) => b.date.getTime() - a.date.getTime());
return this.calls.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
}
async get(id: string) {
@@ -205,14 +205,14 @@ test('CallsController', async (t) => {
await t.test('creates new market call', async () => {
const repository = new MockMarketCallRepository() as any;
const newCall: MarketCall = {
const newCall = {
title: 'MSFT Q3 2024',
quarter: 'Q3 2024',
thesis: 'Cloud growth acceleration',
tickers: ['MSFT'],
date: new Date('2024-07-01'),
snapshots: [],
};
date: '2024-07-01',
snapshot: {},
} as MarketCall;
const created = await repository.create(newCall);
assert.ok(created.id);
@@ -261,14 +261,14 @@ test('CallsController', async (t) => {
const repository = new MockMarketCallRepository() as any;
const engine = new MockScreenerEngine() as any;
const newCall: MarketCall = {
const newCall = {
title: 'Tech Quartet',
quarter: 'Q3 2024',
thesis: 'All tech leaders',
tickers: ['AAPL', 'MSFT', 'NVDA', 'GOOG'],
date: new Date('2024-07-01'),
snapshots: [],
};
date: '2024-07-01',
snapshot: {},
} as MarketCall;
const created = await repository.create(newCall);
const results = await engine.screenTickers(created.tickers);
@@ -290,11 +290,13 @@ test('CallsController', async (t) => {
}
});
await t.test('call includes snapshots of entry prices', async () => {
await t.test('call includes a snapshot of entry prices', async () => {
const repository = new MockMarketCallRepository() as any;
const call = await repository.get('1');
assert.ok(call);
assert.ok(Array.isArray(call.snapshots));
// MarketCall.snapshot is Record<ticker, TickerSnapshot>, not an array
assert.equal(typeof call.snapshot, 'object');
assert.ok(!Array.isArray(call.snapshot));
});
});