Skip to content

Commit

Permalink
[Chore] Update timeline default expression (opensearch-project#2720)
Browse files Browse the repository at this point in the history
* [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]>
  • Loading branch information
joshuarrrr authored Mar 27, 2023
1 parent 276fae9 commit 7efc231
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 @@ -144,6 +144,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### 🛠 Maintenance

- Adding @zhongnansu as maintainer. ([#2590](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2590))
- [Timeline] Update default expressions from `.es(*)` to `.opensearch(*)`. ([2720](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2720))
- Removes `minimatch` manual resolution ([#3019](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3019))
- Remove `github-checks-reporter`, an unused dependency ([#3126](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3126))
- Upgrade `vega-lite` dependency to ^5.6.0 ([#3076](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3076))
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 7efc231

Please sign in to comment.