Skip to content

Commit

Permalink
Migrate reporting frontend plugin to OpenSearch Dashboards 1.15 (open…
Browse files Browse the repository at this point in the history
…search-project#4)

* Migrate to Opensearch

* Rename Kibana in html and md files

* WIP rename strings and variables

* Rename kibana index

* revert kibana_recipients temporarily

* Change kbn to osd

* Update jest snapshots

* Migrate cypress

* Change opendistro_kibana_reports to opendistro-reports-opensearch-dashboards

* fixup! Migrate to Opensearch

* Typo fixes and more renaming

* Rename variables in delivery params

* Rename kibana user to opensearch dashboards user

* Rename Es in variables

* Migrate github workflow for dashboards-reports

* Move kibana-reports dir to dashboards-reports

* Migrate readme

* Rename es to opensearch

* Remove opendistro in dashboards reports

* Update documents for repo

* Address comments
  • Loading branch information
joshuali925 committed Apr 16, 2021
1 parent bc357ee commit 72658e7
Show file tree
Hide file tree
Showing 194 changed files with 42,133 additions and 51 deletions.
18 changes: 18 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": { "node": "10" }
}
],
"@babel/preset-react",
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-transform-modules-commonjs",
["@babel/plugin-transform-runtime", { "regenerator": true }],
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread"
]
}
78 changes: 78 additions & 0 deletions .cypress/integration/01-create.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

describe('Cypress', () => {
it('Visits Reporting homepage', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
'/reports-dashboards'
);
});

it('Visit Create page', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
'/reports-dashboards'
);
cy.wait(12500); // wait for the page to load
cy.get('#createReportHomepageButton').click({ force: true });
});

it('Create a new on-demand report definition', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
'/reports-dashboards'
);
cy.wait(12500);
cy.get('#createReportHomepageButton').click();

// enter a report name
cy.get('#reportSettingsName').type('Create cypress test on-demand report');

// enter a report description
cy.get('#reportSettingsDescription').type('Description for cypress test');

// select a report source
cy.get('.euiComboBox').click({ force: true });

// create an on-demand report definition
cy.get('#createNewReportDefinition').click({ force: true });
});

it('Create a new scheduled report definition', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
'/reports-dashboards'
);
cy.wait(12500);
cy.get('#createReportHomepageButton').click();

// enter a report name
cy.get('#reportSettingsName').type('Create cypress test scheduled report');

// enter a report description
cy.get('#reportSettingsDescription').type('Description for cypress test');

// set report trigger to Schedule option
cy.get('[type="radio"]').check({ force: true });

// create scheduled report definition
cy.get('#createNewReportDefinition').click({ force: true });
});
});
92 changes: 92 additions & 0 deletions .cypress/integration/02-edit.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

describe('Cypress', () => {
it('Visit edit page, update name and description', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
'/reports-dashboards'
);

cy.wait(12500);

cy.get('#reportDefinitionDetailsLink').first().click();

cy.get('#editReportDefinitionButton').should('exist');

cy.get('#editReportDefinitionButton').click();

cy.url().should('include', 'edit');

cy.wait(1000);

// update the report name
cy.get('#reportSettingsName').type(' update name');

// update report description
cy.get('#reportSettingsDescription').type(' update description');

cy.get('#editReportDefinitionButton').click({ force: true });
});

it('Visit edit page, change report source and trigger', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
'/reports-dashboards'
);

cy.wait(12500);

cy.get('#reportDefinitionDetailsLink').first().click();

cy.get('#editReportDefinitionButton').should('exist');

cy.get('#editReportDefinitionButton').click();

cy.url().should('include', 'edit');

cy.wait(1000);
cy.get('#visualizationReportSource').check({ force: true });

cy.get('#Schedule').check({ force: true });
cy.get('#editReportDefinitionButton').click({ force: true });
});

it('Visit edit page, change report source back', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
'/reports-dashboards'
);

cy.wait(12500);

cy.get('#reportDefinitionDetailsLink').first().click();

cy.get('#editReportDefinitionButton').should('exist');

cy.get('#editReportDefinitionButton').click();

cy.url().should('include', 'edit');

cy.wait(1000);

cy.get('#dashboardReportSource').check({ force: true });

cy.get('#editReportDefinitionButton').click({ force: true });
});
});
57 changes: 57 additions & 0 deletions .cypress/integration/03-details.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

describe('Cypress', () => {
it('Visit report definition details page', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
'/reports-dashboards'
);

cy.wait(12500);

cy.get('#reportDefinitionDetailsLink').first().click();

cy.url().should('include', 'report_definition_details');

cy.get('#deleteReportDefinitionButton').should('exist');

cy.get('#editReportDefinitionButton').should('exist');

if (cy.get('body').contains('Schedule details')) {
cy.wait(1000);
cy.get('#changeStatusFromDetailsButton').click();
} else {
cy.wait(1000);
cy.get('#generateReportFromDetailsButton').click();
}

cy.get('#deleteReportDefinitionButton').click();
});

it('Visit report details page', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
'/reports-dashboards'
);

cy.wait(12500);
cy.get('#reportDetailsLink').first().click();

cy.url().should('include', 'report_details');
});
});
104 changes: 104 additions & 0 deletions .cypress/integration/04-download.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

describe('Cypress', () => {
it('Download from reporting homepage', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
'/reports-dashboards'
);

cy.wait(12500);
cy.get('#landingPageOnDemandDownload').click({ force: true });
cy.get('body').then($body => {
if ($body.find('#downloadInProgressLoadingModal').length > 0) {
return;
}
else {
assert(false);
}
})
});

it('Download pdf from in-context menu', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/dashboards#`);
cy.wait(5000);

// click first entry in dashboards page
cy.get('tr.euiTableRow:nth-child(1) > td:nth-child(2) > div:nth-child(2) > a:nth-child(1)').click({ force: true });

// click Reporting in-context menu
cy.get('#downloadReport > span:nth-child(1) > span:nth-child(1)').click({ force: true });

// download PDF
cy.get('#generatePDF > span:nth-child(1) > span:nth-child(2)').click({ force: true });

cy.get('#reportGenerationProgressModal');
});

it('Download png from in-context menu', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/dashboards#`);
cy.wait(5000);

// click first entry in dashboards page
cy.get('tr.euiTableRow:nth-child(1) > td:nth-child(2) > div:nth-child(2) > a:nth-child(1)').click({ force: true });

// click Reporting in-context menu
cy.get('#downloadReport > span:nth-child(1) > span:nth-child(1)').click({ force: true });

cy.get('#generatePNG').click({ force: true });

cy.get('#reportGenerationProgressModal');
});

it('Download csv from saved search in-context menu', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/discover#`);
cy.wait(5000);

// open saved search list
cy.get('button.euiButtonEmpty:nth-child(3) > span:nth-child(1) > span:nth-child(1)').click({ force: true });
cy.wait(5000);

// click first entry
cy.get('li.euiListGroupItem:nth-child(1) > button:nth-child(1)').click({ force: true });

// open reporting menu
cy.get('#downloadReport').click({ force: true });

cy.get('#generateCSV').click({ force: true });
});

it('Download from Report definition details page', () => {
// create an on-demand report definition

cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
'/reports-dashboards'
);
cy.wait(10000);

cy.get('tr.euiTableRow-isSelectable:nth-child(1) > td:nth-child(1) > div:nth-child(2) > button:nth-child(1)').first().click();

cy.url().should('include', 'report_definition_details');

cy.get('#generateReportFromDetailsButton').should('exist');

cy.get('#generateReportFromDetailsButton').click({ force: true });

cy.get('#downloadInProgressLoadingModal');
});
});
36 changes: 36 additions & 0 deletions .cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
* @type {Cypress.PluginConfig}
*/
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
Loading

0 comments on commit 72658e7

Please sign in to comment.