Skip to content

Commit

Permalink
Merge branch 'main' into gantt-charts-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sejli authored Mar 28, 2024
2 parents 5a36a3c + e1e0716 commit 17deb74
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,17 @@ name: Bundle Snapshot based E2E Cypress tests workflow for core Dashboards (Wind
on:
pull_request:
branches: [ '**' ]
paths:
- 'cypress/**/core-opensearch-dashboards/**'
- 'cypress/utils/dashboards/**'
push:
branches: [ '**' ]
paths:
- 'cypress/**/core-opensearch-dashboards/**'
- 'cypress/utils/dashboards/**'

jobs:
changes:
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.filter.outputs.tests }}
steps:
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
tests:
- 'cypress/**/core-opensearch-dashboards/**'
- 'cypress/utils/dashboards/**'
tests-with-security:
needs: changes
if: ${{ needs.changes.outputs.tests == 'true' }}
uses: ./.github/workflows/release-e2e-workflow-template-windows.yml
with:
test-name: Core Dashboards using Bundle Snapshot
Expand All @@ -30,8 +21,6 @@ jobs:
#osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true

tests-without-security:
needs: changes
if: ${{ needs.changes.outputs.tests == 'true' }}
uses: ./.github/workflows/release-e2e-workflow-template-windows.yml
with:
test-name: Core Dashboards using Bundle Snapshot
Expand Down
23 changes: 6 additions & 17 deletions .github/workflows/cypress-workflow-bundle-snapshot-based.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,24 @@ name: Bundle Snapshot based E2E Cypress tests workflow for core Dashboards
on:
pull_request:
branches: [ '**' ]
paths:
- 'cypress/**/core-opensearch-dashboards/**'
- 'cypress/utils/dashboards/**'
push:
branches: [ '**' ]
paths:
- 'cypress/**/core-opensearch-dashboards/**'
- 'cypress/utils/dashboards/**'

jobs:
changes:
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.filter.outputs.tests }}
steps:
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
tests:
- 'cypress/**/core-opensearch-dashboards/**'
- 'cypress/utils/dashboards/**'
tests-with-security:
needs: changes
if: ${{ needs.changes.outputs.tests == 'true' }}
uses: ./.github/workflows/release-e2e-workflow-template.yml
with:
test-name: Core Dashboards using Bundle Snapshot
test-command: env CYPRESS_NO_COMMAND_LOG=1 CYPRESS_ML_COMMONS_DASHBOARDS_ENABLED=true CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true

tests-without-security:
needs: changes
if: ${{ needs.changes.outputs.tests == 'true' }}
uses: ./.github/workflows/release-e2e-workflow-template.yml
with:
test-name: Core Dashboards using Bundle Snapshot
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security-release-e2e-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
uses: ./.github/workflows/release-e2e-workflow-template.yml
with:
test-name: Security
test-command: env CYPRESS_NO_COMMAND_LOG=1 yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/plugins/security/*'
test-command: env CYPRESS_NO_COMMAND_LOG=1 yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/plugins/security/*,cypress/integration/plugins/security-dashboards-plugin/*'
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ describe('test large strings', () => {
});
});

beforeEach(() => {
cy.window().then((win) =>
win.localStorage.setItem('discover:newExpereince', true)
);
});

it('verify the large string book present', function () {
// Go to the Discover page
miscUtils.visitPage('app/data-explorer/discover#/');
cy.waitForLoader();
cy.switchDiscoverTable('new');

const ExpectedDoc = 'Project Gutenberg EBook of Hamlet';

Expand All @@ -67,7 +72,6 @@ describe('test large strings', () => {

it('search Newsletter should show the correct hit count in datagrid table', function () {
cy.log('test Newsletter keyword is searched');
cy.switchDiscoverTable('new');
const expectedHitCount = '1';
const query = 'Newsletter';
cy.setTopNavQuery(query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ describe('AcknowledgeAlertsModal', () => {
});

beforeEach(() => {
const getMonitorsUrl = new RegExp('.*api/alerting/monitors/_search.*');
cy.intercept(getMonitorsUrl).as('searchMonitors');

// Reloading the page to close any modals that were not closed by other tests that had failures.
cy.visit(`${BASE_PATH}/app/${ALERTING_PLUGIN_NAME}#/dashboard`);

// Wait for the monitor search call to finish before checking for the monitors below
cy.wait('@searchMonitors');

// Confirm dashboard is displaying rows for the test monitors.
cy.contains(BUCKET_MONITOR, { timeout: TWENTY_SECONDS });
cy.contains(QUERY_MONITOR, { timeout: TWENTY_SECONDS });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/// <reference types="cypress" />

import {
TEST_NOTEBOOK,
SAMPLE_URL,
BASE_PATH,
delayTime,
Expand All @@ -16,81 +15,119 @@ import {

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

let loadedOnce = 0;
const testNotebookName = () => {
let code = (Math.random() + 1).toString(36).substring(7);
return `Test Notebook ${code}`;
};

const moveToNotebookHome = () => {
cy.visit(`${BASE_PATH}/app/observability-notebooks#/`);
};

const moveToTestNotebook = () => {
const moveToTestNotebook = (notebookName) => {
cy.visit(`${BASE_PATH}/app/observability-notebooks#/`, {
timeout: delayTime * 3,
});

// Force refresh the observablity index and reload page to load notebooks.
if (loadedOnce === 0) {
cy.request({
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',
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.reload();

cy.get('.euiTableCellContent')
.contains(TEST_NOTEBOOK, {
.contains(notebookName, {
timeout: delayTime * 3,
})
.click();
};

const makeTestNotebook = () => {
let notebookName = testNotebookName();

moveToNotebookHome();
cy.get('a[data-test-subj="createNotebookPrimaryBtn"]').click();
cy.get('input[data-test-subj="custom-input-modal-input"]').focus();
cy.get('input[data-test-subj="custom-input-modal-input"]').type(notebookName);
cy.get('button[data-test-subj="custom-input-modal-confirm-button"]').click();
cy.get('h1[data-test-subj="notebookTitle"]')
.contains(notebookName)
.should('exist');

return notebookName;
};

const makeParagraph = () => {
cy.get('button[data-test-subj="emptyNotebookAddCodeBlockBtn"]').click();
cy.get('textarea[data-test-subj="editorArea-0"]').should('exist');
};

const makePopulatedParagraph = () => {
makeParagraph();
cy.get('textarea[data-test-subj="editorArea-0"]').clear();
cy.get('textarea[data-test-subj="editorArea-0"]').focus();
cy.get('textarea[data-test-subj="editorArea-0"]').type(MARKDOWN_TEXT);
cy.get('button[data-test-subj="runRefreshBtn-0"]').click();
};

const deleteNotebook = (notebookName) => {
moveToNotebookHome();

cy.contains('.euiTableRow', notebookName)
.find('input[type="checkbox"]')
.check();

cy.get('button[data-test-subj="notebookTableActionBtn"]').click();
cy.get('button[data-test-subj="deleteNotebookBtn"]').click();

cy.get('input[data-test-subj="delete-notebook-modal-input"]').focus();
cy.get('input[data-test-subj="delete-notebook-modal-input"]').type('delete');
cy.get('button[data-test-subj="delete-notebook-modal-delete-button"]').should(
'not.be.disabled'
);
cy.get(
'button[data-test-subj="delete-notebook-modal-delete-button"]'
).click();
moveToNotebookHome();

cy.contains('.euiTableRow', notebookName).should('not.exist');
};

describe('Testing notebook actions', () => {
before(() => {
moveToNotebookHome();
cy.get('a[data-test-subj="createNotebookPrimaryBtn"]').click();
cy.get('input[data-test-subj="custom-input-modal-input"]').focus();
cy.get('input[data-test-subj="custom-input-modal-input"]').type(
TEST_NOTEBOOK
);
cy.get(
'button[data-test-subj="custom-input-modal-confirm-button"]'
).click();
cy.get('h1[data-test-subj="notebookTitle"]')
.contains(TEST_NOTEBOOK)
.should('exist');
beforeEach(() => {
let notebookName = makeTestNotebook();
moveToTestNotebook(notebookName);
cy.wrap({ name: notebookName }).as('notebook');
});

beforeEach(() => {
moveToTestNotebook();
afterEach(() => {
cy.get('@notebook').then((notebook) => {
deleteNotebook(notebook.name);
});
});

it('Creates a code paragraph', () => {
cy.get('button[data-test-subj="emptyNotebookAddCodeBlockBtn"]').click();
cy.get('textarea[data-test-subj="editorArea-0"]').should('exist');
makeParagraph();

cy.get('button[data-test-subj="runRefreshBtn-0"]').contains('Run').click();
cy.get('div[data-test-subj="paragraphInputErrorText"]')
.contains('Input is required.')
.should('exist');
});

it('Renders markdown', () => {
cy.get('button[data-test-subj="paragraphToggleInputBtn"]').click();
cy.get('.euiCodeBlock').click();
cy.get('textarea[data-test-subj="editorArea-0"]').clear();
cy.get('textarea[data-test-subj="editorArea-0"]').focus();
cy.get('textarea[data-test-subj="editorArea-0"]').type(MARKDOWN_TEXT);

cy.get('button[data-test-subj="runRefreshBtn-0"]').click();
makePopulatedParagraph();
cy.get('textarea[data-test-subj="editorArea-0"]').should('not.exist');
cy.get(`a[href="${SAMPLE_URL}"]`).should('exist');
cy.get('code').contains('POST').should('exist');
Expand All @@ -100,14 +137,18 @@ describe('Testing notebook actions', () => {

describe('Test reporting integration if plugin installed', () => {
beforeEach(() => {
moveToNotebookHome();
cy.get('.euiTableCellContent').contains(TEST_NOTEBOOK).click();
cy.get('h1[data-test-subj="notebookTitle"]')
.contains(TEST_NOTEBOOK)
.should('exist');
let notebookName = makeTestNotebook();
cy.get('body').then(($body) => {
skipOn($body.find('#reportingActionsButton').length <= 0);
});
makePopulatedParagraph();
cy.wrap({ name: notebookName }).as('notebook');
});

afterEach(() => {
cy.get('@notebook').then((notebook) => {
deleteNotebook(notebook.name);
});
});

it('Create in-context PDF report from notebook', () => {
Expand Down Expand Up @@ -150,28 +191,3 @@ describe('Test reporting integration if plugin installed', () => {
);
});
});

describe('clean up all test data', () => {
it('Cleans up test notebooks', () => {
moveToNotebookHome();
cy.get('input[data-test-subj="checkboxSelectAll"]').click();
cy.get('button[data-test-subj="notebookTableActionBtn"]').click();
cy.get('button[data-test-subj="deleteNotebookBtn"]').click();
cy.get(
'button[data-test-subj="delete-notebook-modal-delete-button"]'
).should('be.disabled');

cy.get('input[data-test-subj="delete-notebook-modal-input"]').focus();
cy.get('input[data-test-subj="delete-notebook-modal-input"]').type(
'delete'
);
cy.get(
'button[data-test-subj="delete-notebook-modal-delete-button"]'
).should('not.be.disabled');
cy.get(
'button[data-test-subj="delete-notebook-modal-delete-button"]'
).click();
moveToNotebookHome();
cy.get('div[data-test-subj="notebookEmptyTableText"]').should('exist');
});
});
Loading

0 comments on commit 17deb74

Please sign in to comment.