From 51834337f209f9bf0ebd9cc18f4d0292285c77dd Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 9 May 2022 07:10:34 +0200 Subject: [PATCH] Fix botcomparison summary rendering --- src/components/ftbot/BotComparisonList.vue | 4 ++-- src/components/general/ProfitPill.spec.ts | 15 +++++++++++++++ src/components/general/ProfitPill.vue | 2 ++ src/types/botComparison.ts | 4 ++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/components/ftbot/BotComparisonList.vue b/src/components/ftbot/BotComparisonList.vue index ab7a1272..2532ceb4 100644 --- a/src/components/ftbot/BotComparisonList.vue +++ b/src/components/ftbot/BotComparisonList.vue @@ -81,9 +81,9 @@ export default defineComponent({ botId: undefined, botName: 'Summary', profitClosed: 0, - profitClosedRatio: 0, + profitClosedRatio: undefined, profitOpen: 0, - profitOpenRatio: 0, + profitOpenRatio: undefined, stakeCurrency: 'USDT', wins: 0, losses: 0, diff --git a/src/components/general/ProfitPill.spec.ts b/src/components/general/ProfitPill.spec.ts index eb894d6d..f9bd8e77 100644 --- a/src/components/general/ProfitPill.spec.ts +++ b/src/components/general/ProfitPill.spec.ts @@ -47,4 +47,19 @@ describe('ProfitPill.vue', () => { cy.get('div').should('contain', '(0)'); cy.get('span').should('have.attr', 'title', 'BTC'); }); + it('Shows a pill without relative profits.', async () => { + mount(ProfitPill, { + propsData: { + profitRatio: undefined, + profitAbs: 223, + profitDesc: '', + stakeCurrency: 'USDT', + }, + }); + + cy.get('div').should('have.class', 'profit-pill').should('be.visible'); + // cy.get('div').should('not.contain', '%'); + cy.get('div').should('contain', '223'); + cy.get('span').should('have.attr', 'title', 'USDT'); + }); }); diff --git a/src/components/general/ProfitPill.vue b/src/components/general/ProfitPill.vue index 741dfb76..1e0faf19 100644 --- a/src/components/general/ProfitPill.vue +++ b/src/components/general/ProfitPill.vue @@ -46,6 +46,8 @@ export default defineComponent({ const profitString = computed((): string => { if (props.profitRatio !== undefined && props.profitAbs !== undefined) { return `(${formatPrice(props.profitAbs, 3)})`; + } else if (props.profitAbs !== undefined) { + return `${formatPrice(props.profitAbs, 3)}`; } return ''; }); diff --git a/src/types/botComparison.ts b/src/types/botComparison.ts index 4c1a49a3..e9e63ea8 100644 --- a/src/types/botComparison.ts +++ b/src/types/botComparison.ts @@ -3,9 +3,9 @@ export interface ComparisonTableItems { botName: string; trades?: string; profitClosed: number; - profitClosedRatio: number; + profitClosedRatio?: number; profitOpen: number; - profitOpenRatio: number; + profitOpenRatio?: number; stakeCurrency: string; wins: number; losses: number;