Skip to content

Commit

Permalink
[Backport 2.x] [Chore] Update timeline default expression (#3697)
Browse files Browse the repository at this point in the history
* [Chore] Update timeline default expression (#2720)

* [Chore] Update other timeline `es()` examples and test usage to make sure we continue supporting the old format.
* [Chore] Update BWC data generation to use es(*)
* [Test] Add better programmatic text clearing for monaco editor
* [Test] Wait for loader to finish after clicking update

Update default expression from `.es(*)` to `opensearch(*)`.
Both work, but we'd prefer the latter

Signed-off-by: Josh Romero <[email protected]>

---------

Signed-off-by: Josh Romero <[email protected]>
(cherry picked from commit 7efc231)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

* add changelog

Signed-off-by: Josh Romero <[email protected]>

---------

Signed-off-by: Josh Romero <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Josh Romero <[email protected]>
  • Loading branch information
3 people authored Mar 28, 2023
1 parent 292562d commit 6754c4d
Show file tree
Hide file tree
Showing 17 changed files with 103 additions and 80 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Bump the version of Node.js installed by `nvm` to `14.21.3` ([3463](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3463))
- Allow selecting the Node.js binary using `NODE_HOME` and `OSD_NODE_HOME` ([3508](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3508))
- Bump `styled-components` from 5.3.5 to 5.3.9 ([#3678](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3678))
- [Timeline] Update default expressions from `.es(*)` to `.opensearch(*)`. ([2720](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2720))

### 🪛 Refactoring
- [Multiple DataSource] Refactor dev tool console to use opensearch-js client to send requests ([#3544](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3544))
Expand Down
45 changes: 24 additions & 21 deletions cypress/integration/with-security/check_timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,87 +44,90 @@ describe('check timeline visualization', () => {
.find('[data-test-subj="newItemButton"]')
.click();
cy.get('[data-test-subj="visType-timelion"]').click();
// Because monaco editor doesn't use a contenteditable, input, or textarea, .clear() or .type('{selectall}') won't work. To clear, we just backspace for each character instead.
cy.get('[class="view-line"]')
.invoke('text')
.then((expressionText) => {
cy.get('[class="view-line"]').type('{backspace}'.repeat(expressionText.length));
});
});

it('.es(*, kibana1=true) should report search error', () => {
cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana1=true)');
cy.get('[class="view-line"]').type('.es(*, kibana1=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.contains('Timeline request error: undefined Error: Unknown argument to es: kibana1');
});

it('.es(*, kibana=true) should not report search error', () => {
cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana=true)');
cy.get('[class="view-line"]').type('.es(*, kibana=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.should('not.exist');
});

it('.es(*, opensearchDashboards=true) should not report search error', () => {
cy.get('[class="view-line"]').type('{selectall}{backspace}, opensearchDashboards=true)');
cy.get('[class="view-line"]').type('.es(*, opensearchDashboards=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.should('not.exist');
});

it('.elasticsearch(*, kibana1=true) should report search error', () => {
cy.get('[class="view-line"]').type(
'{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana1=true)'
);
cy.get('[class="view-line"]').type('.elasticsearch(*, kibana1=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.contains('Timeline request error: undefined Error: Unknown argument to es: kibana1');
});

it('.elasticsearch(*, kibana=true) should not report search error', () => {
cy.get('[class="view-line"]').type(
'{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana=true)'
);
cy.get('[class="view-line"]').type('.elasticsearch(*, kibana=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.should('not.exist');
});

it('.elasticsearch(*, opensearchDashboards=true) should not report search error', () => {
cy.get('[class="view-line"]').type(
'{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, opensearchDashboards=true)'
);
cy.get('[class="view-line"]').type('.elasticsearch(*, opensearchDashboards=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.should('not.exist');
});

it('.opensearch(*, kibana1=true) should report search error', () => {
cy.get('[class="view-line"]').type(
'{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana1=true)'
);
cy.get('[class="view-line"]').type('.opensearch(*, kibana1=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.contains('Timeline request error: undefined Error: Unknown argument to es: kibana1');
});

it('.opensearch(*, kibana=true) should not report search error', () => {
cy.get('[class="view-line"]').type(
'{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana=true)'
);
cy.get('[class="view-line"]').type('.opensearch(*, kibana=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.should('not.exist');
});

it('.opensearch(*, opensearchDashboards=true) should not report search error', () => {
cy.get('[class="view-line"]').type(
'{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, opensearchDashboards=true)'
);
cy.get('[class="view-line"]').type('.opensearch(*, opensearchDashboards=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.should('not.exist');
Expand Down
8 changes: 8 additions & 0 deletions cypress/integration/with-security/helpers/generate_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ describe('Generating BWC test data with security', () => {
.find('[data-test-subj="newItemButton"]')
.click();
cy.get('[data-test-subj="visType-timelion"]').click();
// Because monaco editor doesn't use a contenteditable, input, or textarea, .clear() or .type('{selectall}') won't work. To clear, we just backspace for each character instead.
cy.get('[class="view-line"]')
.invoke('text')
.then((expressionText) => {
cy.get('[class="view-line"]').type('{backspace}'.repeat(expressionText.length));
});
// update default expression to use `.es(*)` instead of `.opensearch(*)` for bwc
cy.get('[class="view-line"]').type('.es(*)');
cy.get('[data-test-subj="visualizeSaveButton"]').click();
cy.get('[data-test-subj="savedObjectTitle"]').type('test-timeline');
cy.get('[data-test-subj="confirmSaveSavedObjectButton"]').click();
Expand Down
45 changes: 24 additions & 21 deletions cypress/integration/without-security/check_timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,87 +28,90 @@ describe('check timeline visualization', () => {
.find('[data-test-subj="newItemButton"]')
.click();
cy.get('[data-test-subj="visType-timelion"]').click();
// Because monaco editor doesn't use a contenteditable, input, or textarea, .clear() or .type('{selectall}') won't work. To clear, we just backspace for each character instead.
cy.get('[class="view-line"]')
.invoke('text')
.then((expressionText) => {
cy.get('[class="view-line"]').type('{backspace}'.repeat(expressionText.length));
});
});

it('.es(*, kibana1=true) should report search error', () => {
cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana1=true)');
cy.get('[class="view-line"]').type('.es(*, kibana1=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.contains('Timeline request error: undefined Error: Unknown argument to es: kibana1');
});

it('.es(*, kibana=true) should not report search error', () => {
cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana=true)');
cy.get('[class="view-line"]').type('.es(*, kibana=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.should('not.exist');
});

it('.es(*, opensearchDashboards=true) should not report search error', () => {
cy.get('[class="view-line"]').type('{selectall}{backspace}, opensearchDashboards=true)');
cy.get('[class="view-line"]').type('.es(*, opensearchDashboards=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.should('not.exist');
});

it('.elasticsearch(*, kibana1=true) should report search error', () => {
cy.get('[class="view-line"]').type(
'{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana1=true)'
);
cy.get('[class="view-line"]').type('.elasticsearch(*, kibana1=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.contains('Timeline request error: undefined Error: Unknown argument to es: kibana1');
});

it('.elasticsearch(*, kibana=true) should not report search error', () => {
cy.get('[class="view-line"]').type(
'{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana=true)'
);
cy.get('[class="view-line"]').type('.elasticsearch(*, kibana=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.should('not.exist');
});

it('.elasticsearch(*, opensearchDashboards=true) should not report search error', () => {
cy.get('[class="view-line"]').type(
'{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, opensearchDashboards=true)'
);
cy.get('[class="view-line"]').type('.elasticsearch(*, opensearchDashboards=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.should('not.exist');
});

it('.opensearch(*, kibana1=true) should report search error', () => {
cy.get('[class="view-line"]').type(
'{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana1=true)'
);
cy.get('[class="view-line"]').type('.opensearch(*, kibana1=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.contains('Timeline request error: undefined Error: Unknown argument to es: kibana1');
});

it('.opensearch(*, kibana=true) should not report search error', () => {
cy.get('[class="view-line"]').type(
'{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana=true)'
);
cy.get('[class="view-line"]').type('.opensearch(*, kibana=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.should('not.exist');
});

it('.opensearch(*, opensearchDashboards=true) should not report search error', () => {
cy.get('[class="view-line"]').type(
'{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, opensearchDashboards=true)'
);
cy.get('[class="view-line"]').type('.opensearch(*, opensearchDashboards=true)');
cy.get('[data-test-subj="visualizeEditorRenderButton"]').click();
cy.waitForLoader();
cy.get('[data-test-subj="globalToastList"]')
.find('[data-test-subj="errorToastMessage"]')
.should('not.exist');
Expand Down
8 changes: 8 additions & 0 deletions cypress/integration/without-security/helpers/generate_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ describe('Generating BWC test data without security', () => {
.find('[data-test-subj="newItemButton"]')
.click();
cy.get('[data-test-subj="visType-timelion"]').click();
// Because monaco editor doesn't use a contenteditable, input, or textarea, .clear() or .type('{selectall}') won't work. To clear, we just backspace for each character instead.
cy.get('[class="view-line"]')
.invoke('text')
.then((expressionText) => {
cy.get('[class="view-line"]').type('{backspace}'.repeat(expressionText.length));
});
// update default expression to use `.es(*)` instead of `.opensearch(*)` for bwc
cy.get('[class="view-line"]').type('.es(*)');
cy.get('[data-test-subj="visualizeSaveButton"]').click();
cy.get('[data-test-subj="savedObjectTitle"]').type('test-timeline');
cy.get('[data-test-subj="confirmSaveSavedObjectButton"]').click();
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/timeline/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function initTimelineApp(app, deps) {
const savedVisualizations = deps.plugins.visualizations.savedVisualizationsLoader;
const timezone = getTimezone(deps.core.uiSettings);

const defaultExpression = '.es(*)';
const defaultExpression = '.opensearch(*)';

$scope.topNavMenu = getTopNavMenu();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
For some reasons it doesn't work without it (even though the default role of
the element is textbox anyway). -->
<textarea data-expression-input role="textbox" rows="{{ rows }}" class="timExpressionInput kuiTextArea fullWidth"
placeholder="{{ ::'timeline.expressionInputPlaceholder' | i18n: { defaultMessage: 'Try a query with {opensearchQuery}', values: { opensearchQuery: '.es(*)' } } }}"
placeholder="{{ ::'timeline.expressionInputPlaceholder' | i18n: { defaultMessage: 'Try a query with {opensearchQuery}', values: { opensearchQuery: '.opensearch(*)' } } }}"
ng-model="sheet" ng-focus="onFocusInput()" ng-keydown="onKeyDownInput($event)" ng-keyup="onKeyUpInput($event)"
ng-blur="onBlurInput()" ng-mousedown="onMouseDownInput()" ng-mouseup="onMouseUpInput()"
ng-click="onClickExpression()"
Expand All @@ -16,4 +16,4 @@
suggestions-type="suggestions.type" selected-index="suggestions.index"
on-click-suggestion="onClickSuggestion(suggestionIndex)" should-popover="shouldPopoverSuggestions">
</timeline-expression-suggestions>
</div>
</div>
Loading

0 comments on commit 6754c4d

Please sign in to comment.