From 30b128673c8fa1590bc7789a8abca68ff4683b3c Mon Sep 17 00:00:00 2001 From: Futa Ikeda Date: Tue, 22 Oct 2024 16:28:18 -0400 Subject: [PATCH] Update tests; Remove faulty "other" category --- .../chart-kpi-wrapper/component-test.ts | 67 +++++-------------- .../chart-kpi-wrapper/component.ts | 19 ++---- 2 files changed, 20 insertions(+), 66 deletions(-) diff --git a/app/institutions/dashboard/-components/chart-kpi-wrapper/component-test.ts b/app/institutions/dashboard/-components/chart-kpi-wrapper/component-test.ts index 5603074b0f..034ba148a7 100644 --- a/app/institutions/dashboard/-components/chart-kpi-wrapper/component-test.ts +++ b/app/institutions/dashboard/-components/chart-kpi-wrapper/component-test.ts @@ -32,6 +32,9 @@ module('Integration | institutions | dashboard | -components | kpi-chart-wrapper numberOfUsers: 37, }, ], + institution: { + iris: ['bleh'], + }, }); this.set('model', model); @@ -225,22 +228,21 @@ module('Integration | institutions | dashboard | -components | kpi-chart-wrapper // And the expanded data position 0 name is verified assert.dom(`${parentDom} [data-test-expanded-name="0"]`) - .hasText('Math'); + .exists(); // And the expanded data position 0 total is verified assert.dom(`${parentDom} [data-test-expanded-total="0"]`) - .hasText('25'); + .hasText('3'); // And the expanded data position 1 name is verified assert.dom(`${parentDom} [data-test-expanded-name="1"]`) - .hasText('Science'); + .exists(); // And the expanded data position 1 total is verified assert.dom(`${parentDom} [data-test-expanded-total="1"]`) - .hasText('37'); + .hasText('2'); - // Finally there are only 2 expanded data points - assert.dom(`${parentDom} [data-test-expanded-name="2"]`) + assert.dom(`${parentDom} [data-test-expanded-total="2"]`) .doesNotExist(); }); @@ -261,19 +263,19 @@ module('Integration | institutions | dashboard | -components | kpi-chart-wrapper // And the expanded data position 0 name is verified assert.dom(`${parentDom} [data-test-expanded-name="0"]`) - .hasText('Math'); + .exists(); // And the expanded data position 0 total is verified assert.dom(`${parentDom} [data-test-expanded-total="0"]`) - .hasText('25'); + .hasText('3'); // And the expanded data position 1 name is verified assert.dom(`${parentDom} [data-test-expanded-name="1"]`) - .hasText('Science'); + .exists(); // And the expanded data position 1 total is verified assert.dom(`${parentDom} [data-test-expanded-total="1"]`) - .hasText('37'); + .hasText('2'); // Finally there are only 2 expanded data points assert.dom(`${parentDom} [data-test-expanded-name="2"]`) @@ -297,56 +299,19 @@ module('Integration | institutions | dashboard | -components | kpi-chart-wrapper // And the expanded data position 0 name is verified assert.dom(`${parentDom} [data-test-expanded-name="0"]`) - .hasText('Math'); - - // And the expanded data position 0 total is verified - assert.dom(`${parentDom} [data-test-expanded-total="0"]`) - .hasText('25'); - - // And the expanded data position 1 name is verified - assert.dom(`${parentDom} [data-test-expanded-name="1"]`) - .hasText('Science'); - - // And the expanded data position 1 total is verified - assert.dom(`${parentDom} [data-test-expanded-total="1"]`) - .hasText('37'); - - // Finally there are only 2 expanded data points - assert.dom(`${parentDom} [data-test-expanded-name="2"]`) - .doesNotExist(); - }); - - test('it calculates the Public vs Private Data Storage data correctly', async function(assert) { - // Given the component is rendered - await render(hbs` - -`); - const parentDom = '[data-test-kpi-chart="7"]'; - - // When I click the expanded icon - await click(`${parentDom} [data-test-expand-additional-data]`); - - // And the title is verified - assert.dom(`${parentDom} [data-test-chart-title]`) - .hasText('Public vs Private Data Storage'); - - // And the expanded data position 0 name is verified - assert.dom(`${parentDom} [data-test-expanded-name="0"]`) - .hasText('Public Data Storage'); + .exists(); // And the expanded data position 0 total is verified assert.dom(`${parentDom} [data-test-expanded-total="0"]`) - .hasText('2000'); + .hasText('3'); // And the expanded data position 1 name is verified assert.dom(`${parentDom} [data-test-expanded-name="1"]`) - .hasText('Private Data Storage'); + .exists(); // And the expanded data position 1 total is verified assert.dom(`${parentDom} [data-test-expanded-total="1"]`) - .hasText('2100'); + .hasText('2'); // Finally there are only 2 expanded data points assert.dom(`${parentDom} [data-test-expanded-name="2"]`) diff --git a/app/institutions/dashboard/-components/chart-kpi-wrapper/component.ts b/app/institutions/dashboard/-components/chart-kpi-wrapper/component.ts index de73f43d4c..a2dde84051 100644 --- a/app/institutions/dashboard/-components/chart-kpi-wrapper/component.ts +++ b/app/institutions/dashboard/-components/chart-kpi-wrapper/component.ts @@ -228,21 +228,10 @@ export default class ChartKpiWrapperComponent extends Component { - runningTotal += result.cardSearchResultCount; - return { - label: result.indexCard.get('label'), - total: result.cardSearchResultCount, - }; - }); - - if (runningTotal < valueSearch.totalResultCount) { - chartData.push({ - label: this.intl.t('general.other'), - total: valueSearch.totalResultCount - runningTotal, - }); - } + const chartData = resultPage.map((result: SearchResultModel) => ({ + total: result.cardSearchResultCount, + label: result.indexCard.get('label'), + })); const kpiChartObject = { title: this.intl.t('institutions.dashboard.kpi-chart.' + translationKey),