Skip to content

Commit

Permalink
Update tests; Remove faulty "other" category
Browse files Browse the repository at this point in the history
  • Loading branch information
futa-ikeda committed Oct 22, 2024
1 parent e8bcfdd commit 30b1286
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ module('Integration | institutions | dashboard | -components | kpi-chart-wrapper
numberOfUsers: 37,
},
],
institution: {
iris: ['bleh'],
},
});

this.set('model', model);
Expand Down Expand Up @@ -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();
});

Expand All @@ -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"]`)
Expand All @@ -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`
<Institutions::Dashboard::-Components::ChartKpiWrapper
@model={{this.model}}
/>
`);
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"]`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,21 +228,10 @@ export default class ChartKpiWrapperComponent extends Component<TotalCountChartW
});
const resultPage = valueSearch.searchResultPage.toArray();

let runningTotal = 0;
const chartData = resultPage.map((result: SearchResultModel) => {
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),
Expand Down

0 comments on commit 30b1286

Please sign in to comment.