From 2288f33e38d6719ffe1c065e9b75ae96a1f0d0b1 Mon Sep 17 00:00:00 2001 From: Luiz Aoqui Date: Thu, 4 Nov 2021 18:48:40 -0400 Subject: [PATCH] ui: fix tests broken by d3-format upgrade --- ui/app/utils/units.js | 6 ++++++ ui/tests/acceptance/optimize-test.js | 10 +++++----- .../components/das/recommendation-card-test.js | 4 ++-- .../components/das/recommendation-chart-test.js | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ui/app/utils/units.js b/ui/app/utils/units.js index d5c6284fc..ccc27a58f 100644 --- a/ui/app/utils/units.js +++ b/ui/app/utils/units.js @@ -66,3 +66,9 @@ export function formatScheduledHertz(hertz, startingUnitSize) { const [number, unit] = reduceHertz(hertz, 'MHz', startingUnitSize); return `${roundFormatter.format(number)} ${unit}`; } + +// Replaces the minus sign (−) with a hyphen (-). +// https://github.com/d3/d3-format/releases/tag/v2.0.0 +export function replaceMinus(input) { + return input.replace('−', '-'); +} diff --git a/ui/tests/acceptance/optimize-test.js b/ui/tests/acceptance/optimize-test.js index 1826e33c6..0f459b8a7 100644 --- a/ui/tests/acceptance/optimize-test.js +++ b/ui/tests/acceptance/optimize-test.js @@ -5,7 +5,7 @@ import { setupMirage } from 'ember-cli-mirage/test-support'; import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit'; import Response from 'ember-cli-mirage/response'; import moment from 'moment'; -import { formatBytes, formatHertz } from 'nomad-ui/utils/units'; +import { formatBytes, formatHertz, replaceMinus } from 'nomad-ui/utils/units'; import Optimize from 'nomad-ui/tests/pages/optimize'; import Layout from 'nomad-ui/tests/pages/layout'; @@ -153,23 +153,23 @@ module('Acceptance | optimize', function(hooks) { const memDiffPercent = Math.round((100 * memDiff) / currMem); assert.equal( - summary.cpu, + replaceMinus(summary.cpu), cpuDiff ? `${cpuSign}${formatHertz(cpuDiff, 'MHz')} ${cpuSign}${cpuDiffPercent}%` : '' ); assert.equal( - summary.memory, + replaceMinus(summary.memory), memDiff ? `${memSign}${formattedMemDiff(memDiff)} ${memSign}${memDiffPercent}%` : '' ); assert.equal( - summary.aggregateCpu, + replaceMinus(summary.aggregateCpu), cpuDiff ? `${cpuSign}${formatHertz(cpuDiff * currentTaskGroupAllocations.length, 'MHz')}` : '' ); assert.equal( - summary.aggregateMemory, + replaceMinus(summary.aggregateMemory), memDiff ? `${memSign}${formattedMemDiff(memDiff * currentTaskGroupAllocations.length)}` : '' ); }); diff --git a/ui/tests/integration/components/das/recommendation-card-test.js b/ui/tests/integration/components/das/recommendation-card-test.js index 4145e616a..331d01b97 100644 --- a/ui/tests/integration/components/das/recommendation-card-test.js +++ b/ui/tests/integration/components/das/recommendation-card-test.js @@ -113,10 +113,10 @@ module('Integration | Component | das/recommendation-card', function(hooks) { assert.ok(RecommendedMemory.isIncrease); }); - assert.equal(RecommendationCard.totalsTable.unitDiff.cpu, '-75 MHz'); + assert.equal(RecommendationCard.totalsTable.unitDiff.cpu, '−75 MHz'); assert.equal(RecommendationCard.totalsTable.unitDiff.memory, '+128 MiB'); - assert.equal(RecommendationCard.totalsTable.percentDiff.cpu, '-27%'); + assert.equal(RecommendationCard.totalsTable.percentDiff.cpu, '−27%'); assert.equal(RecommendationCard.totalsTable.percentDiff.memory, '+33%'); assert.equal(RecommendationCard.copyButton.text, 'job-name / group-name'); diff --git a/ui/tests/integration/components/das/recommendation-chart-test.js b/ui/tests/integration/components/das/recommendation-chart-test.js index a48c9856e..3df2cb6fc 100644 --- a/ui/tests/integration/components/das/recommendation-chart-test.js +++ b/ui/tests/integration/components/das/recommendation-chart-test.js @@ -47,7 +47,7 @@ module('Integration | Component | das/recommendation-chart', function(hooks) { assert.dom('.recommendation-chart.decrease').exists(); assert.dom('.recommendation-chart .resource').hasText('Mem'); assert.dom('.recommendation-chart .icon-is-arrow-down').exists(); - assert.dom('text.percent').hasText('-32%'); + assert.dom('text.percent').hasText('−32%'); await componentA11yAudit(this.element, assert); });