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 2.12] Updating app analytics jest and cypress tests #1417

Merged
merged 1 commit into from
Feb 6, 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
111 changes: 49 additions & 62 deletions .cypress/integration/app_analytics_test/app_analytics.spec.js

Large diffs are not rendered by default.

106 changes: 102 additions & 4 deletions .cypress/utils/app_constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,110 @@

export const delay = 1000;
export const timeoutDelay = 30000;
export const TYPING_DELAY = 150;
export const TYPING_DELAY = 450;

export const loadAllData = () => {
// flights and web logs, not using ecommerce currently
loadAllSampleData();

loadOtelData();
}

export const loadOtelData = () => {
testIndexDataSet.forEach(({ mapping_url, data_url, index }) =>
dumpDataSet(mapping_url, data_url, index)
);
}

export const loadAllSampleData = () => {
// Deleting all indices, cypress doesn't support conditionals in any way so to create a single
// line of execution, need to start from a clean slate
cy.request(
'DELETE',
`${Cypress.env('opensearch')}/index*,sample*,opensearch_dashboards*,test*,cypress*`
);

cy.visit(`${Cypress.env('opensearchDashboards')}/app/home#/tutorial_directory`);

// Load sample flights data
cy.get(`button[data-test-subj="addSampleDataSetflights"]`).click({

Check warning on line 34 in .cypress/utils/app_constants.js

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
force: true,
});
// Load sample logs data
cy.get(`button[data-test-subj="addSampleDataSetlogs"]`).click({

Check warning on line 38 in .cypress/utils/app_constants.js

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
force: true,
});

// Verify that sample data is add by checking toast notification
cy.contains('Sample flight data installed', { timeout: 60000 });
cy.contains('Sample web logs installed', { timeout: 60000 });
}

// took dumpDataSet and testIndexDataSet from https://github.com/opensearch-project/opensearch-dashboards-functional-test/blob/main/cypress/integration/plugins/observability-dashboards/0_before.spec.js
const dumpDataSet = (mapping_url, data_url, index) => {
cy.request({
method: 'PUT',
failOnStatusCode: false,
url: `${Cypress.env('opensearch')}/${index}`,
headers: {
'content-type': 'application/json;charset=UTF-8',
'osd-xsrf': true,
},
});

cy.request(mapping_url).then((response) => {
cy.request({
method: 'POST',
form: false,
url: `${Cypress.env('opensearch')}/${index}/_mapping`,
headers: {
'content-type': 'application/json;charset=UTF-8',
'osd-xsrf': true,
},
body: response.body,
});
});

cy.request(data_url).then((response) => {
cy.request({
method: 'POST',
form: false,
url: `${Cypress.env('opensearch')}/${index}/_bulk`,
headers: {
'content-type': 'application/json;charset=UTF-8',
'osd-xsrf': true,
},
body: response.body,
});
});
};

const testIndexDataSet = [
{
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',
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',
index: 'otel-v1-apm-span-000002',
},
];

export const moveToHomePage = () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-applications#/`);
cy.wait(delay * 3);
cy.get('.euiTitle').contains('Applications').should('exist');
};

Expand All @@ -32,19 +131,18 @@
moveToApplication(nameOne);
cy.get('[data-test-subj="app-analytics-configTab"]').click();
cy.get('[data-test-subj="editApplicationButton"]').click();
cy.wait(delay);
cy.get('[data-test-subj="createPageTitle"]').should('contain', 'Edit application');
};

export const changeTimeTo24 = (timeUnit) => {
cy.get('[data-test-subj="superDatePickerToggleQuickMenuButton"]').trigger('mouseover').click();
cy.get('[data-test-subj="superDatePickerToggleQuickMenuButton"]').trigger('mouseover').click({ force: true });

Check warning on line 138 in .cypress/utils/app_constants.js

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
cy.get('[aria-label="Time unit"]').select(timeUnit);
cy.get('.euiButton').contains('Apply').click();
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();
};

export const expectMessageOnHover = (button, message) => {
cy.get(`[data-test-subj="${button}"]`).click({ force: true });

Check warning on line 145 in .cypress/utils/app_constants.js

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
cy.get('.euiToolTipPopover').contains(message).should('exist');
};

Expand Down
25 changes: 13 additions & 12 deletions .github/workflows/integration-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ jobs:
matrix:
os: [ubuntu-latest]
java: [11]
testgroups: [
app_analytics_test,
datasources_test,
event_analytics_test,
integrations_test,
metrics_analytics_test,
notebooks_test,
panels_test,
trace_analytics_test
]
testgroups:
[
app_analytics_test,
datasources_test,
event_analytics_test,
integrations_test,
metrics_analytics_test,
notebooks_test,
panels_test,
trace_analytics_test,
]
include:
- os: ubuntu-latest
cypress_cache_folder: ~/.cache/Cypress
Expand Down Expand Up @@ -134,7 +135,7 @@ jobs:
cd OpenSearch-Dashboards
nohup yarn start --no-base-path --no-watch | tee dashboard.log &

- name : Check If OpenSearch Dashboards Is Ready
- name: Check If OpenSearch Dashboards Is Ready
if: ${{ runner.os == 'Linux' }}
run: |
cd ./OpenSearch-Dashboards
Expand Down Expand Up @@ -165,7 +166,7 @@ jobs:
- name: Run Cypress tests for test group of ${{ matrix.testgroups }}
run: |
cd ./OpenSearch-Dashboards/plugins/dashboards-observability
yarn cypress:run --browser chrome --headless --spec '.cypress/integration/${{ matrix.testgroups }}/*'
yarn cypress:run --headless --spec '.cypress/integration/${{ matrix.testgroups }}/*'

- name: Capture failure screenshots
uses: actions/upload-artifact@v1
Expand Down
Loading
Loading