Skip to content

Commit 42e5799

Browse files
mbondyrakibanamachinenickofthyme
authored
[Lens] fix drag and drop failing test (#215439)
## Summary Fixes #213324 For some reason this PR #213928 didn't catch that the changes make the test fail. This PR fixes it. After this, we'll be able to backport the original PR. (The pattern of using `data-attr-field` is already used in Discover so I think it's a good opportunity to align) --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Nick Partridge <[email protected]>
1 parent d52c5ed commit 42e5799

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

x-pack/platform/plugins/shared/lens/public/datasources/common/field_item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export function InnerFieldItem(props: FieldItemProps) {
244244
}, [dataViewField, filters, hideDetails, indexPattern, query, services]);
245245

246246
return (
247-
<li>
247+
<li data-attr-field={field.name}>
248248
<FieldPopover
249249
isOpen={infoIsOpen}
250250
closePopover={closePopover}

x-pack/test/functional/apps/lens/group5/drag_and_drop.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
1414
const listingTable = getService('listingTable');
1515
const xyChartContainer = 'xyVisChart';
1616

17-
// Failing: See https://github.com/elastic/kibana/issues/213324
18-
describe.skip('lens drag and drop tests', () => {
17+
describe('lens drag and drop tests', () => {
1918
describe('basic drag and drop', () => {
2019
it('should construct a bar chart when dropping a field to create top values chart', async () => {
2120
await visualize.navigateToNewVisualization();
@@ -260,7 +259,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
260259
await lens.assertFocusedField('clientip');
261260
});
262261
it('should duplicate an element in a group', async () => {
263-
await lens.dimensionKeyboardDragDrop('lnsXY_yDimensionPanel', 0, 2);
262+
await lens.dimensionKeyboardDragDrop('lnsXY_yDimensionPanel', 0, 1);
264263
expect(await lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([
265264
'Count of records',
266265
'Median of bytes',

x-pack/test/functional/page_objects/lens_page.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
398398
metaKey?: 'shift' | 'alt' | 'ctrl'
399399
) {
400400
const field = await find.byCssSelector(
401-
`[data-test-subj="lnsFieldListPanelField-${fieldName}"] [data-test-subj="lnsDragDrop-keyboardHandler"]`
401+
`[data-attr-field="${fieldName}"] [data-test-subj="lnsDragDrop-keyboardHandler"]`
402402
);
403403
await field.focus();
404404
await retry.try(async () => {
@@ -433,17 +433,21 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
433433
metaKey?: 'shift' | 'alt' | 'ctrl'
434434
) {
435435
const elements = await find.allByCssSelector(
436-
`[data-test-subj="${group}"] [data-test-subj="lnsDragDrop-keyboardHandler"]`
436+
`[data-test-subj="${group}"] [data-test-subj="lnsDragDrop-keyboardHandler"]`
437437
);
438438
const el = elements[index];
439439
await el.focus();
440440
await browser.pressKeys(browser.keys.ENTER);
441441
for (let i = 0; i < steps; i++) {
442+
// This needs to be slowed down to avoid flakiness
443+
await common.sleep(200);
442444
await browser.pressKeys(reverse ? browser.keys.LEFT : browser.keys.RIGHT);
443445
}
444446
if (metaKey) {
445447
await this.pressMetaKey(metaKey);
446448
}
449+
450+
await common.sleep(200);
447451
await browser.pressKeys(browser.keys.ENTER);
448452

449453
await this.waitForLensDragDropToFinish();
@@ -465,8 +469,12 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
465469
await el.focus();
466470
await browser.pressKeys(browser.keys.ENTER);
467471
for (let i = 0; i < steps; i++) {
472+
// This needs to be slowed down to avoid flakiness
473+
await common.sleep(200);
468474
await browser.pressKeys(reverse ? browser.keys.ARROW_UP : browser.keys.ARROW_DOWN);
469475
}
476+
477+
await common.sleep(200);
470478
await browser.pressKeys(browser.keys.ENTER);
471479

472480
await this.waitForLensDragDropToFinish();
@@ -1539,10 +1547,10 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
15391547
*/
15401548
async assertFocusedField(name: string) {
15411549
const input = await find.activeElement();
1542-
const fieldAncestor = await input.findByXpath('./../..');
1543-
const focusedElementText = await fieldAncestor.getVisibleText();
1544-
const dataTestSubj = await fieldAncestor.getAttribute('data-test-subj');
1550+
const fieldPopover = await input.findByXpath('./..');
1551+
const focusedElementText = await fieldPopover.getVisibleText();
15451552
expect(focusedElementText).to.eql(name);
1553+
const dataTestSubj = await fieldPopover.getAttribute('data-test-subj');
15461554
expect(dataTestSubj).to.eql('lnsFieldListPanelField');
15471555
},
15481556

@@ -1553,7 +1561,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
15531561
*/
15541562
async assertFocusedDimension(name: string) {
15551563
const input = await find.activeElement();
1556-
const fieldAncestor = await input.findByXpath('./../../..');
1564+
const fieldAncestor = await input.findByXpath('./../..');
15571565
const focusedElementText = await fieldAncestor.getVisibleText();
15581566
expect(focusedElementText).to.eql(name);
15591567
},

0 commit comments

Comments
 (0)