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

Update notebooks snapshots and cypress #1367

Merged
merged 7 commits into from
Jan 19, 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
431 changes: 214 additions & 217 deletions .cypress/integration/notebooks_test/notebooks.spec.js
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does FTR also need these changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, the data-test-subjare re-used for FTR linked in there PR 1001 there.

Large diffs are not rendered by default.

70 changes: 39 additions & 31 deletions .cypress/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

export const delay = 1500;
export const COMMAND_TIMEOUT_LONG = 10000;

//BASE Constants
export const BACKEND_BASE_PATH = Cypress.env('opensearch');
export const FONTEND_BASE_PATH = Cypress.env('opensearchDashboards');
Expand All @@ -14,7 +11,7 @@
export const DATASOURCES_API_PREFIX = '/app/datasources';
export const DATASOURCES_PATH = {
DATASOURCES_CREATION_BASE: `${DATASOURCES_API_PREFIX}#/new`,
DATASOURCES_CONFIG_BASE: `${DATASOURCES_API_PREFIX}#/configure`
DATASOURCES_CONFIG_BASE: `${DATASOURCES_API_PREFIX}#/configure`,
};

// trace analytics
Expand All @@ -26,34 +23,44 @@

export const testDataSet = [
{
mapping_url: 'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/otel-v1-apm-service-map-mappings.json',
data_url: 'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/otel-v1-apm-service-map.json',
mapping_url:
'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/otel-v1-apm-service-map-mappings.json',
data_url:
'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/otel-v1-apm-service-map.json',
index: 'otel-v1-apm-service-map',
},
{
mapping_url: 'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/otel-v1-apm-span-000001-mappings.json',
data_url: 'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/otel-v1-apm-span-000001.json',
mapping_url:
'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/otel-v1-apm-span-000001-mappings.json',
data_url:
'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/otel-v1-apm-span-000001.json',
index: 'otel-v1-apm-span-000001',
},
{
mapping_url: 'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/otel-v1-apm-span-000001-mappings.json',
data_url: 'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/otel-v1-apm-span-000002.json',
mapping_url:
'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/otel-v1-apm-span-000001-mappings.json',
data_url:
'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/otel-v1-apm-span-000002.json',
index: 'otel-v1-apm-span-000002',
},
]
];

export const jaegerTestDataSet = [
{
mapping_url: 'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/jaeger-service-2023-01-24-mappings.json',
data_url: 'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/jaeger-service-2023-01-24.json',
mapping_url:
'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/jaeger-service-2023-01-24-mappings.json',
data_url:
'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/jaeger-service-2023-01-24.json',
index: 'jaeger-service-2023-01-24',
},
{
mapping_url: 'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/jaeger-span-2023-01-24-mappings.json',
data_url: 'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/jaeger-span-2023-01-24.json',
mapping_url:
'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/jaeger-span-2023-01-24-mappings.json',
data_url:
'https://raw.githubusercontent.com/opensearch-project/dashboards-observability/main/.cypress/utils/jaeger-span-2023-01-24.json',
index: 'jaeger-span-2023-01-24',
},
]
];

export const setTimeFilter = (setEndTime = false, refresh = true) => {
const startTime = 'Mar 25, 2021 @ 10:00:00.000';
Expand All @@ -65,7 +72,7 @@
'button.euiDatePopoverButton--start[data-test-subj="superDatePickerstartDatePopoverButton"]'
).click();
cy.get('.euiTab__content').contains('Absolute').click();
cy.get('input[data-test-subj="superDatePickerAbsoluteDateInput"]')

Check warning on line 75 in .cypress/utils/constants.js

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
.focus()
.type('{selectall}' + startTime, { force: true });
if (setEndTime) {
Expand All @@ -73,20 +80,21 @@
'button.euiDatePopoverButton--end[data-test-subj="superDatePickerendDatePopoverButton"]'
).click();
cy.get('.euiTab__content').contains('Absolute').click();
cy.get('input[data-test-subj="superDatePickerAbsoluteDateInput"]')

Check warning on line 83 in .cypress/utils/constants.js

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
.focus()
.type('{selectall}' + endTime, { force: true });
}
if (refresh) cy.get('.euiButton__text').contains('Refresh').click();
cy.get('.euiTableRow').should('have.length.greaterThan', 3);//Replaces Wait
cy.get('.euiTableRow').should('have.length.greaterThan', 3); //Replaces Wait
};

// notebooks
export const TEST_NOTEBOOK = 'Test Notebook';
export const TEST_INTEGRATION_INSTANCE = 'nginx-test';
export const TEST_SAMPLE_INSTANCE = 'nginx-sample';
export const SAMPLE_URL = 'https://github.com/opensearch-project/sql/tree/main/sql-jdbc';
export const NOTEBOOK_TEXT = 'Use Notebooks to interactively and collaboratively develop rich reports backed by live data. Common use cases for notebooks includes creating postmortem reports, designing run books, building live infrastructure reports, or even documentation.';
export const NOTEBOOK_TEXT =
'Use Notebooks to interactively and collaboratively develop rich reports backed by live data. Common use cases for notebooks includes creating postmortem reports, designing run books, building live infrastructure reports, or even documentation.';
export const OPENSEARCH_URL = 'https://opensearch.org/docs/latest/observability-plugin/notebooks/';
export const MARKDOWN_TEXT = `%md
# Heading 1
Expand All @@ -112,15 +120,15 @@
|----|----|----|----|
| a2 | b2 | c2 | d2 |
| a3 | b3 | c3 | d3 |
`
`;

export const SQL_QUERY_TEXT = `%sql
select * from opensearch_dashboards_sample_data_flights limit 20
`
export const SQL_QUERY_TEXT = `%sql
select * from opensearch_dashboards_sample_data_flights limit 20 {enter}
`;

export const PPL_QUERY_TEXT = `%ppl
source=opensearch_dashboards_sample_data_flights
`
source=opensearch_dashboards_sample_data_flights {enter}
`;

export const suppressResizeObserverIssue = () => {
// exception is thrown on loading EuiDataGrid in cypress only, ignore for now
Expand All @@ -137,28 +145,28 @@
cy.get('.euiDataGridHeaderCell__content').contains('Start time').should('exist');
cy.get('.euiDataGridHeaderCell__content').contains('End time').should('exist');
cy.get('.euiDataGridHeaderCell__content').contains('Errors').should('exist');
}
};

export const count_table_row = (expected_row_count) => {
cy.get('.euiDataGridHeader [role="columnheader"]').then($el => {
cy.get('.euiDataGridHeader [role="columnheader"]').then(($el) => {
let colmun_header_count = Cypress.$($el).length;
let table_grid_cell_count = Cypress.$('[data-test-subj="dataGridRowCell"]').length;
const total_row_count = table_grid_cell_count / colmun_header_count;
expect(total_row_count).to.equal(expected_row_count)
expect(total_row_count).to.equal(expected_row_count);
});
}
};

Cypress.on('uncaught:exception', (err, runnable, promise) => {
// when the exception originated from an unhandled promise
// rejection, the promise is provided as a third argument
// you can turn off failing the test in this case
if (promise) {
return false
return false;
}
// we still want to ensure there are no other unexpected
// errors, so we let them fail the test
})
});

Cypress.on('uncaught:exception', (err, runnable) => {
if (err.message.includes('ResizeObserver loop')) return false;
})
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ exports[`<NoteTable /> spec renders the component 1`] = `
>
<h3
class="euiTitle euiTitle--small"
data-test-subj="notebookTableTitle"
>
Notebooks
<span
Expand All @@ -51,6 +52,7 @@ exports[`<NoteTable /> spec renders the component 1`] = `
/>
<div
class="euiText euiText--small"
data-test-subj="notebookTableDescription"
>
<div
class="euiTextColor euiTextColor--subdued"
Expand Down Expand Up @@ -99,6 +101,7 @@ exports[`<NoteTable /> spec renders the component 1`] = `
>
<button
class="euiButton euiButton--primary"
data-test-subj="notebookTableActionBtn"
type="button"
>
<span
Expand Down Expand Up @@ -134,6 +137,7 @@ exports[`<NoteTable /> spec renders the component 1`] = `
>
<a
class="euiButton euiButton--primary euiButton--fill"
data-test-subj="createNotebookPrimaryBtn"
href="#/create"
rel="noreferrer"
>
Expand Down Expand Up @@ -951,6 +955,7 @@ exports[`<NoteTable /> spec renders the empty component 1`] = `
>
<h3
class="euiTitle euiTitle--small"
data-test-subj="notebookTableTitle"
>
Notebooks
<span
Expand All @@ -966,6 +971,7 @@ exports[`<NoteTable /> spec renders the empty component 1`] = `
/>
<div
class="euiText euiText--small"
data-test-subj="notebookTableDescription"
>
<div
class="euiTextColor euiTextColor--subdued"
Expand Down Expand Up @@ -1015,6 +1021,7 @@ exports[`<NoteTable /> spec renders the empty component 1`] = `
>
<button
class="euiButton euiButton--primary"
data-test-subj="notebookTableActionBtn"
type="button"
>
<span
Expand Down Expand Up @@ -1049,6 +1056,7 @@ exports[`<NoteTable /> spec renders the empty component 1`] = `
>
<a
class="euiButton euiButton--primary euiButton--fill"
data-test-subj="createNotebookPrimaryBtn"
href="#/create"
rel="noreferrer"
>
Expand All @@ -1074,6 +1082,7 @@ exports[`<NoteTable /> spec renders the empty component 1`] = `
/>
<div
class="euiText euiText--medium"
data-test-subj="notebookEmptyTableText"
>
<div
class="euiTextAlign euiTextAlign--center"
Expand Down Expand Up @@ -1108,7 +1117,7 @@ exports[`<NoteTable /> spec renders the empty component 1`] = `
>
<a
class="euiButton euiButton--primary"
data-test-subj="note-table-empty-state-create-notebook-button"
data-test-subj="notebookEmptyTableCreateBtn"
href="#/create"
rel="noreferrer"
>
Expand All @@ -1128,6 +1137,7 @@ exports[`<NoteTable /> spec renders the empty component 1`] = `
>
<button
class="euiButton euiButton--primary"
data-test-subj="notebookEmptyTableAddSamplesBtn"
type="button"
>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ exports[`<Notebook /> spec Renders the empty component 1`] = `
/>
<h1
class="euiTitle euiTitle--large"
data-test-subj="notebookTitle"
>
sample-notebook-1
</h1>
Expand Down Expand Up @@ -261,6 +262,7 @@ exports[`<Notebook /> spec Renders the empty component 1`] = `
>
<button
class="euiButton euiButton--primary"
data-test-subj="emptyNotebookAddCodeBlockBtn"
style="margin-bottom: 17px;"
type="button"
>
Expand Down Expand Up @@ -469,6 +471,7 @@ exports[`<Notebook /> spec Renders the visualization component 1`] = `
/>
<h1
class="euiTitle euiTitle--large"
data-test-subj="notebookTitle"
/>
<div
class="euiSpacer euiSpacer--m"
Expand Down Expand Up @@ -574,6 +577,7 @@ exports[`<Notebook /> spec Renders the visualization component 1`] = `
>
<button
class="euiButton euiButton--primary"
data-test-subj="emptyNotebookAddCodeBlockBtn"
style="margin-bottom: 17px;"
type="button"
>
Expand Down Expand Up @@ -823,6 +827,7 @@ exports[`<Notebook /> spec test reporting action button 1`] = `
/>
<h1
class="euiTitle euiTitle--large"
data-test-subj="notebookTitle"
>
sample-notebook-1
</h1>
Expand Down Expand Up @@ -930,6 +935,7 @@ exports[`<Notebook /> spec test reporting action button 1`] = `
>
<button
class="euiButton euiButton--primary"
data-test-subj="emptyNotebookAddCodeBlockBtn"
style="margin-bottom: 17px;"
type="button"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,20 @@ describe('<NoteTable /> spec', () => {

it('closes the action panel', async () => {
const { getByText, queryByTestId } = renderNoteTable({ notebooks: [] });
expect(queryByTestId('rename-notebook-btn')).not.toBeInTheDocument();
expect(queryByTestId('renameNotebookBtn')).not.toBeInTheDocument();

// Open Actions dropdown
fireEvent.click(getByText('Actions'));

// Ensure the action panel is open
expect(queryByTestId('rename-notebook-btn')).toBeInTheDocument();
expect(queryByTestId('renameNotebookBtn')).toBeInTheDocument();

await act(async () => {
fireEvent.click(getByText('Actions'));
});

// Ensure the action panel is closed
expect(queryByTestId('rename-notebook-btn')).not.toBeInTheDocument();
expect(queryByTestId('renameNotebookBtn')).not.toBeInTheDocument();
});

it('closes the delete modal', () => {
Expand Down
Loading
Loading