Skip to content

Commit 0ecb10f

Browse files
committed
test: fix test failing due to change in single value behaviour
1 parent 2c18ff3 commit 0ecb10f

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

cypress/elements/optionsModal/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export {
7676
changeDisplayStyleToText,
7777
expectLegendDisplayStyleToBeText,
7878
expectLegendDisplayStyleToBeFill,
79-
expectSingleValueToNotBeColor,
79+
expectSingleValueToHaveBackgroundColor,
80+
expectSingleValueToNotHaveBackgroundColor,
8081
expectSingleValueToBeColor,
8182
toggleLegendKeyOption,
8283
expectLegendKeyOptionToBeEnabled,

cypress/elements/optionsModal/legend.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const legendKeyOptionEl = 'option-legend-key'
33
const legendKeyEl = 'visualization-legend-key'
44
const legendKeyContainerEl = 'legend-key-container'
55
const legendKeyItemEl = 'legend-key-item'
6+
const visualizationContainerEl = 'visualization-container'
67
const singleValueOutputEl = 'visualization-primary-value'
78
const legendDisplayStrategyByDataItemEl = 'legend-display-strategy-BY_DATA_ITEM'
89
const legendDisplayStrategyFixedEl = 'legend-display-strategy-FIXED'
@@ -64,11 +65,17 @@ export const changeFixedLegendSet = (legendSetName) => {
6465
export const expectFixedLegendSetToBe = (legendSetName) =>
6566
cy.getBySel(fixedLegendSetSelectEl).should('contain', legendSetName)
6667

67-
export const expectSingleValueToNotBeColor = (color) =>
68+
export const expectSingleValueToHaveBackgroundColor = (color) =>
6869
cy
69-
.getBySel(singleValueOutputEl)
70-
.invoke('attr', 'fill')
71-
.should('not.eq', color)
70+
.getBySel(visualizationContainerEl)
71+
.parent()
72+
.should('have.css', 'background-color', color)
73+
74+
export const expectSingleValueToNotHaveBackgroundColor = (color) =>
75+
cy
76+
.getBySel(visualizationContainerEl)
77+
.parent()
78+
.should('not.have.css', 'background-color', color)
7279

7380
export const expectSingleValueToBeColor = (color) =>
7481
cy.getBySel(singleValueOutputEl).invoke('attr', 'fill').should('eq', color)

cypress/integration/options/legend.cy.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ import {
4646
expectLegendDisplayStyleToBeText,
4747
expectLegendToBeEnabled,
4848
expectSingleValueToBeColor,
49-
expectSingleValueToNotBeColor,
49+
expectSingleValueToHaveBackgroundColor,
50+
expectSingleValueToNotHaveBackgroundColor,
5051
OPTIONS_TAB_LEGEND,
5152
toggleLegendKeyOption,
5253
expectLegendKeyOptionToBeEnabled,
@@ -152,6 +153,7 @@ describe('Options - Legend', () => {
152153
describe('Applying a legend: Single value', () => {
153154
const TEST_ITEM = TEST_ITEMS[0]
154155
const EXPECTED_STANDARD_TEXT_COLOR = '#212934'
156+
const EXPECTED_LEGEND_BACKGROUND_COLOR = 'rgb(255, 255, 178)'
155157
it('navigates to the start page and adds data items', () => {
156158
goToStartPage()
157159
changeVisType(visTypeDisplayNames[VIS_TYPE_SINGLE_VALUE])
@@ -160,6 +162,9 @@ describe('Options - Legend', () => {
160162
clickDimensionModalUpdateButton()
161163
expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE)
162164
expectSingleValueToBeColor(EXPECTED_STANDARD_TEXT_COLOR)
165+
expectSingleValueToNotHaveBackgroundColor(
166+
EXPECTED_LEGEND_BACKGROUND_COLOR
167+
)
163168
})
164169
it('enables legend', () => {
165170
clickMenuBarOptionsButton()
@@ -171,7 +176,9 @@ describe('Options - Legend', () => {
171176
expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE)
172177
})
173178
it('legend is applied', () => {
174-
expectSingleValueToNotBeColor(EXPECTED_STANDARD_TEXT_COLOR)
179+
expectSingleValueToHaveBackgroundColor(
180+
EXPECTED_LEGEND_BACKGROUND_COLOR
181+
)
175182
})
176183
it('legend key is hidden', () => {
177184
expectLegendKeyToBeHidden()
@@ -460,6 +467,7 @@ describe('Options - Legend', () => {
460467
})
461468
describe('Transferring a legend: Column -> Single value', () => {
462469
const EXPECTED_STANDARD_TEXT_COLOR = '#212934'
470+
const EXPECTED_LEGEND_BACKGROUND_COLOR = 'rgb(255, 255, 178)'
463471
it('navigates to the start page and adds data items', () => {
464472
goToStartPage()
465473
openDimension(DIMENSION_ID_DATA)
@@ -490,7 +498,9 @@ describe('Options - Legend', () => {
490498
expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE)
491499
})
492500
it('legend is applied to Single value', () => {
493-
expectSingleValueToNotBeColor(EXPECTED_STANDARD_TEXT_COLOR)
501+
expectSingleValueToHaveBackgroundColor(
502+
EXPECTED_LEGEND_BACKGROUND_COLOR
503+
)
494504
})
495505
it('verifies that options are persisted', () => {
496506
clickMenuBarOptionsButton()

0 commit comments

Comments
 (0)