Skip to content
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

[Logs UI] Make column configurations reorderable #41035

Merged
merged 12 commits into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,18 @@ export class WebElementWrapper {
});
}

/**
* Focuses this element.
*
* @return {Promise<void>}
*/
public async focus() {
await this.retryCall(async function focus(wrapper) {
await wrapper.scrollIntoViewIfNecessary();
await wrapper.driver.executeScript(`arguments[0].focus()`, wrapper._webElement);
});
}

/**
* Clear the value of this element. This command has no effect if the underlying DOM element
* is neither a text INPUT element nor a TEXTAREA element.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const FieldLogColumnConfigurationPanel: React.FunctionComponent<{
<EuiPanel data-test-subj={`logColumnPanel fieldLogColumnPanel fieldLogColumnPanel:${field}`}>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<div {...dragHandleProps}>
<div data-test-subj="moveLogColumnHandle" {...dragHandleProps}>
<EuiIcon type="grab" />
</div>
</EuiFlexItem>
Expand Down Expand Up @@ -202,7 +202,7 @@ const ExplainedLogColumnConfigurationPanel: React.FunctionComponent<{
>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<div {...dragHandleProps}>
<div data-test-subj="moveLogColumnHandle" {...dragHandleProps}>
<EuiIcon type="grab" />
</div>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ export default ({ getPageObjects, getService }: KibanaFunctionalTestDefaultProvi
await infraSourceConfigurationFlyout.addTimestampLogColumn();
await infraSourceConfigurationFlyout.addFieldLogColumn('host.name');

await infraSourceConfigurationFlyout.moveLogColumn(0, 1);

await infraSourceConfigurationFlyout.saveConfiguration();
await infraSourceConfigurationFlyout.closeFlyout();
});

it('renders the changed log columns with their headers', async () => {
const columnHeaderLabels = await infraLogStream.getColumnHeaderLabels();

expect(columnHeaderLabels).to.eql(['Timestamp', 'host.name', '']);
expect(columnHeaderLabels).to.eql(['host.name', 'Timestamp', '']);

const logStreamEntries = await infraLogStream.getStreamEntries();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { Key } from 'selenium-webdriver';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to not break the abstraction introduced by the testing framework we should probably avoid importing from selenium-webdriver directly.

How about we access the Key object via the browser service at the top of the provider function below?

  const browser = getService('browser');

import { KibanaFunctionalTestDefaultProviders } from '../../types/providers';
import { WebElementWrapper } from '../../../../test/functional/services/lib/web_element_wrapper';

Expand Down Expand Up @@ -81,6 +82,25 @@ export function InfraSourceConfigurationFlyoutProvider({
await this.removeLogColumn(0);
}
},
async moveLogColumn(sourceIndex: number, destinationIndex: number) {
const logColumnPanel = (await this.getLogColumnPanels())[sourceIndex];
const moveLogColumnHandle = await testSubjects.findDescendant(
'moveLogColumnHandle',
logColumnPanel
);
await moveLogColumnHandle.focus();
const movementDifference = destinationIndex - sourceIndex;
await moveLogColumnHandle.pressKeys(Key.SPACE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming we access the keys via the browser as suggested above, this could be

Suggested change
await moveLogColumnHandle.pressKeys(Key.SPACE);
await moveLogColumnHandle.pressKeys(browser.keys.SPACE);

for (let i = 0; i < Math.abs(movementDifference); i++) {
await new Promise(res => setTimeout(res, 100));
if (movementDifference > 0) {
await moveLogColumnHandle.pressKeys(Key.ARROW_DOWN);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming we access the keys via the browser as suggested above, this could be

Suggested change
await moveLogColumnHandle.pressKeys(Key.ARROW_DOWN);
await moveLogColumnHandle.pressKeys(browser.keys.ARROW_DOWN);

} else {
await moveLogColumnHandle.pressKeys(Key.ARROW_UP);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await moveLogColumnHandle.pressKeys(Key.ARROW_UP);
await moveLogColumnHandle.pressKeys(browser.keys.ARROW_UP);

}
}
await moveLogColumnHandle.pressKeys(Key.SPACE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await moveLogColumnHandle.pressKeys(Key.SPACE);
await moveLogColumnHandle.pressKeys(browser.keys.SPACE);

},

/**
* Form and flyout
Expand Down