From 6f1db160c19031ae4cdad6bf6834db3be0f36975 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Tue, 29 Sep 2026 21:25:29 +0200 Subject: [PATCH] Fix redaction of values of ETF holdings --- apps/api/src/helper/object.helper.spec.ts | 98 +++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/apps/api/src/helper/object.helper.spec.ts b/apps/api/src/helper/object.helper.spec.ts index c4c9da375d..ca487ed8f7 100644 --- a/apps/api/src/helper/object.helper.spec.ts +++ b/apps/api/src/helper/object.helper.spec.ts @@ -1,4 +1,5 @@ import { DEFAULT_REDACTED_PATHS } from '@ghostfolio/common/config'; +import { PortfolioDetails } from '@ghostfolio/common/interfaces'; import { query, redactPaths } from './object.helper'; @@ -3249,4 +3250,101 @@ describe('redactAttributes', () => { ] }); }); + + // The type makes sure that the object keeps the shape of the response, in + // which the holdings of an ETF are part of its asset profile + it('should redact the values of the holdings of an ETF', () => { + expect( + redactPaths({ + object: { + holdings: [ + { + activitiesCount: 5, + allocationInPercentage: 0.057358979326040366, + assetProfile: { + assetClass: 'EQUITY', + assetSubClass: 'ETF', + countries: [], + currency: 'USD', + dataSource: 'YAHOO', + holdings: [ + { + allocationInPercentage: 0.06099941636982121, + name: 'APPLE INC', + valueInBaseCurrency: 860.2442693554036 + }, + { + allocationInPercentage: 0.05862464529372787, + name: 'MICROSOFT CORP', + valueInBaseCurrency: 826.7540602547973 + } + ], + name: 'Vanguard Total Stock Market Index Fund ETF Shares', + sectors: [], + symbol: 'VTI' + }, + dateOfFirstActivity: new Date('2019-02-28T23:00:00.000Z'), + dividend: 0, + grossPerformance: 5856.3, + grossPerformancePercent: 0.8832083851170418, + grossPerformancePercentWithCurrencyEffect: 0.8832083851170418, + grossPerformanceWithCurrencyEffect: 5856.3, + investment: 8246.2, + marketPrice: 282.05, + netPerformance: 5756.8, + netPerformancePercent: 0.8682024540139314, + netPerformancePercentWithCurrencyEffect: 0.8328704068843998, + netPerformanceWithCurrencyEffect: 5756.8, + quantity: 50, + valueInBaseCurrency: 14102.5 + } + ] + } satisfies Pick, + paths: DEFAULT_REDACTED_PATHS + }) + ).toStrictEqual({ + holdings: [ + { + activitiesCount: 5, + allocationInPercentage: 0.057358979326040366, + assetProfile: { + assetClass: 'EQUITY', + assetSubClass: 'ETF', + countries: [], + currency: 'USD', + dataSource: 'YAHOO', + holdings: [ + { + allocationInPercentage: 0.06099941636982121, + name: 'APPLE INC', + valueInBaseCurrency: null + }, + { + allocationInPercentage: 0.05862464529372787, + name: 'MICROSOFT CORP', + valueInBaseCurrency: null + } + ], + name: 'Vanguard Total Stock Market Index Fund ETF Shares', + sectors: [], + symbol: 'VTI' + }, + dateOfFirstActivity: '2019-02-28T23:00:00.000Z', + dividend: null, + grossPerformance: null, + grossPerformancePercent: 0.8832083851170418, + grossPerformancePercentWithCurrencyEffect: 0.8832083851170418, + grossPerformanceWithCurrencyEffect: null, + investment: null, + marketPrice: 282.05, + netPerformance: null, + netPerformancePercent: 0.8682024540139314, + netPerformancePercentWithCurrencyEffect: 0.8328704068843998, + netPerformanceWithCurrencyEffect: null, + quantity: null, + valueInBaseCurrency: null + } + ] + }); + }); });