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

[Backport main] Notebooks add index refresh, remove SQL check in paragraph #1067

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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
Loading