-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Lens]Test color syncing #86906
Merged
Merged
[Lens]Test color syncing #86906
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2197202
add cahrt data test
flash1293 beec4a1
:white_check_mark: Add multi-axis testing with the new debugState API
dej611 7489291
:mute: Skip tests for unsupported charts
dej611 69c5dfc
:lipstick: Add testing identifiers
dej611 a1ff774
:white_check_mark: Add more axis tests + value labels
dej611 011d1cb
:camera: Update snapshots with new debug option
dej611 ea276aa
Merge remote-tracking branch 'upstream/master' into test/lens/chart-d…
dej611 f4e407f
start working on sync color test
flash1293 d6f81b4
Merge remote-tracking branch 'upstream/master' into test/color-syncing
flash1293 101cd77
add functional tests for color sync
flash1293 3665a25
Merge branch 'master' into test/color-syncing
kibanamachine 492e330
Merge remote-tracking branch 'upstream/master' into test/color-syncing
flash1293 cbdd9c2
remove unnecessary time range sets
flash1293 5cda9c1
make sure debug flag is set correctly
flash1293 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { DebugState } from '@elastic/charts'; | ||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ getService, getPageObjects }: FtrProviderContext) { | ||
const esArchiver = getService('esArchiver'); | ||
const PageObjects = getPageObjects([ | ||
'common', | ||
'dashboard', | ||
'spaceSelector', | ||
'header', | ||
'lens', | ||
'timePicker', | ||
]); | ||
const dashboardAddPanel = getService('dashboardAddPanel'); | ||
const filterBar = getService('filterBar'); | ||
const elasticChart = getService('elasticChart'); | ||
|
||
function getColorMapping(debugState: DebugState | null) { | ||
if (!debugState) return {}; | ||
const colorMapping: Record<string, string> = {}; | ||
debugState.bars?.forEach(({ name, color }) => { | ||
colorMapping[name] = color; | ||
}); | ||
|
||
return colorMapping; | ||
} | ||
|
||
describe('sync colors', function () { | ||
before(async function () { | ||
await esArchiver.loadIfNeeded('logstash_functional'); | ||
await esArchiver.loadIfNeeded('lens/basic'); | ||
}); | ||
|
||
after(async function () { | ||
await esArchiver.unload('logstash_functional'); | ||
await esArchiver.unload('lens/basic'); | ||
}); | ||
|
||
it('should sync colors on dashboard by default', async function () { | ||
await PageObjects.common.navigateToApp('dashboard'); | ||
await PageObjects.dashboard.clickCreateDashboardPrompt(); | ||
await dashboardAddPanel.clickCreateNewLink(); | ||
await dashboardAddPanel.clickVisType('lens'); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
await PageObjects.lens.goToTimeRange(); | ||
|
||
await PageObjects.lens.configureDimension({ | ||
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', | ||
operation: 'count', | ||
field: 'Records', | ||
}); | ||
|
||
await PageObjects.lens.configureDimension({ | ||
dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', | ||
operation: 'terms', | ||
field: 'geo.src', | ||
}); | ||
|
||
await PageObjects.lens.save('vis1', true, true); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
await dashboardAddPanel.clickCreateNewLink(); | ||
await dashboardAddPanel.clickVisType('lens'); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
await PageObjects.lens.goToTimeRange(); | ||
|
||
await PageObjects.lens.configureDimension({ | ||
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', | ||
operation: 'count', | ||
field: 'Records', | ||
}); | ||
|
||
await PageObjects.lens.configureDimension({ | ||
dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', | ||
operation: 'terms', | ||
field: 'geo.src', | ||
}); | ||
|
||
await filterBar.addFilter('geo.src', 'is not', 'CN'); | ||
|
||
await PageObjects.lens.save('vis2', true, true); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
await elasticChart.setNewChartUiDebugFlag(true); | ||
await PageObjects.lens.goToTimeRange(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here |
||
const colorMapping1 = getColorMapping(await PageObjects.dashboard.getPanelChartDebugState(0)); | ||
const colorMapping2 = getColorMapping(await PageObjects.dashboard.getPanelChartDebugState(1)); | ||
expect(Object.keys(colorMapping1)).to.have.length(6); | ||
expect(Object.keys(colorMapping1)).to.have.length(6); | ||
const panel1Keys = ['CN']; | ||
const panel2Keys = ['PK']; | ||
const sharedKeys = ['IN', 'US', 'ID', 'BR', 'Other']; | ||
// colors for keys exclusive to panel 1 should not occur in panel 2 | ||
panel1Keys.forEach((panel1Key) => { | ||
const assignedColor = colorMapping1[panel1Key]; | ||
expect(Object.values(colorMapping2)).not.to.contain(assignedColor); | ||
}); | ||
// colors for keys exclusive to panel 2 should not occur in panel 1 | ||
panel2Keys.forEach((panel2Key) => { | ||
const assignedColor = colorMapping2[panel2Key]; | ||
expect(Object.values(colorMapping1)).not.to.contain(assignedColor); | ||
}); | ||
// colors for keys used in both panels should be synced | ||
sharedKeys.forEach((sharedKey) => { | ||
expect(colorMapping1[sharedKey]).to.eql(colorMapping2[sharedKey]); | ||
}); | ||
}); | ||
|
||
it('should be possible to disable color sync', async () => { | ||
await PageObjects.dashboard.useColorSync(false); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
const colorMapping1 = getColorMapping(await PageObjects.dashboard.getPanelChartDebugState(0)); | ||
const colorMapping2 = getColorMapping(await PageObjects.dashboard.getPanelChartDebugState(1)); | ||
const colorsByOrder1 = Object.values(colorMapping1); | ||
const colorsByOrder2 = Object.values(colorMapping2); | ||
// colors by order of occurence have to be the same | ||
expect(colorsByOrder1).to.eql(colorsByOrder2); | ||
}); | ||
}); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the time range cleared in between the previous page load and this one? I would have expected it to persist.