Skip to content

Commit

Permalink
notebooks add index refresh, remove SQL check in paragraph (#1065) (#…
Browse files Browse the repository at this point in the history
…1067)

Signed-off-by: Shenoy Pratik <[email protected]>
(cherry picked from commit f45cdf7)

Co-authored-by: Shenoy Pratik <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and ps48 authored Feb 7, 2024
1 parent 607560d commit 2eec70b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
/// <reference types="cypress" />

import {
SAMPLE_SQL_QUERY,
TEST_NOTEBOOK,
SAMPLE_URL,
BASE_PATH,
delayTime,
MARKDOWN_TEXT,
OBSERVABILITY_INDEX_NAME,
} from '../../../utils/constants';

import { skipOn } from '@cypress/skip-test';

let loadedOnce = 0;

const moveToNotebookHome = () => {
cy.visit(`${BASE_PATH}/app/observability-notebooks#/`);
};
Expand All @@ -25,8 +27,25 @@ const moveToTestNotebook = () => {
timeout: delayTime * 3,
});

// Reload page to load notebooks if they are not flushed in OpenSearch index yet.
cy.reload();
// Force refresh the observablity index and reload page to load notebooks.
if (loadedOnce === 0) {
cy.request({
method: 'POST',
failOnStatusCode: false,
form: false,
url: 'api/console/proxy',
headers: {
'content-type': 'application/json;charset=UTF-8',
'osd-xsrf': true,
},
qs: {
path: `${OBSERVABILITY_INDEX_NAME}/_refresh`,
method: 'POST',
},
});
cy.reload();
loadedOnce = 1;
}

cy.get('.euiTableCellContent')
.contains(TEST_NOTEBOOK, {
Expand Down Expand Up @@ -77,23 +96,6 @@ describe('Testing notebook actions', () => {
cy.get('code').contains('POST').should('exist');
cy.get('td').contains('b2').should('exist');
});

it('Adds a SQL query paragraph', () => {
cy.get('button[data-test-subj="AddParagraphButton"]').click();
cy.get('button[data-test-subj="AddCodeBlockBtn"]').click();

cy.get('textarea[data-test-subj="editorArea-1"]').clear();
cy.get('textarea[data-test-subj="editorArea-1"]').focus();
cy.get('textarea[data-test-subj="editorArea-1"]').type(SAMPLE_SQL_QUERY);
cy.get('button[data-test-subj="runRefreshBtn-1"]').click();

cy.get('textarea[data-test-subj="editorArea-1"]').should('not.exist');
cy.get('div[data-test-subj="queryOutputText"]')
.contains('select 1')
.should('exist');

cy.get('.euiDataGrid__overflow').should('exist');
});
});

describe('Test reporting integration if plugin installed', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
import { BASE_PATH } from '../../base_constants';

export const OBSERVABILITY_INDEX_NAME = '.opensearch-observability';
export const delayTime = 1500;

//Datasources API Constants
Expand Down

0 comments on commit 2eec70b

Please sign in to comment.