diff --git a/frontend/src/__tests__/recommendations.test.ts b/frontend/src/__tests__/recommendations.test.ts
index 3ecae87f1..8a507ef15 100644
--- a/frontend/src/__tests__/recommendations.test.ts
+++ b/frontend/src/__tests__/recommendations.test.ts
@@ -7351,6 +7351,91 @@ describe('renderUsageSparkline (issue #239)', () => {
});
});
+// ============================================================================
+// Issue #1417: sparkline integration — SVG renders inside the table
+// ============================================================================
+// The unit tests above verify renderUsageSparkline in isolation. This block
+// confirms the SVG actually appears inside the recommendations table HTML when
+// a recommendation carries non-empty usage_history data.
+describe('Issue #1417: usage-history sparkline renders in recommendations table', () => {
+ beforeEach(() => {
+ document.body.innerHTML = `
+
+
+
+
+
+
+
+
+ `;
+ jest.clearAllMocks();
+ jest.useFakeTimers();
+ (state.getHiddenColumns as jest.Mock).mockReturnValue(new Set());
+ (state.getRecommendationsSort as jest.Mock).mockReturnValue({ column: 'savings', direction: 'desc' });
+ (state.getRecommendationsColumnFilters as jest.Mock).mockReturnValue({});
+ (state.getCurrentUser as jest.Mock).mockReturnValue({ id: 'u-admin', email: 'admin@example.com', groups: ['00000000-0000-5000-8000-000000000001'] });
+ (recsApi.getRecommendationsFreshness as jest.Mock).mockResolvedValue({
+ last_collected_at: new Date(Date.now() - 60 * 60 * 1000).toISOString(),
+ last_collection_error: null,
+ });
+ (recsApi.refreshRecommendations as jest.Mock).mockResolvedValue({});
+ });
+ afterEach(() => {
+ jest.useRealTimers();
+ });
+
+ test('SVG polyline appears in table row when rec has 7-day usage_history', async () => {
+ (api.getRecommendations as jest.Mock).mockResolvedValue({
+ summary: { total_count: 1, total_monthly_savings: 100, total_upfront_cost: 500, avg_payback_months: 5 },
+ recommendations: [{
+ id: 'rec-sparkline', provider: 'aws', cloud_account_id: 'acct-1',
+ service: 'ec2', resource_type: 't3.medium', region: 'us-east-1',
+ count: 1, term: 1, payment: 'all-upfront', savings: 100, upfront_cost: 500,
+ usage_history: [80, 85, 90, 70, 95, 100, 60],
+ }],
+ regions: [],
+ });
+
+ await loadRecommendations();
+
+ const list = document.getElementById('recommendations-list');
+ const html = list?.innerHTML ?? '';
+ // The sparkline SVG must be present in the rendered table.
+ expect(html).toContain('class="usage-sparkline"');
+ // It must contain a polyline (7 points -> polyline, not circle).
+ expect(html).toContain('