Skip to content

Commit

Permalink
Add functional test for UI Metric
Browse files Browse the repository at this point in the history
Signed-off-by: Suchit Sahoo <suchsah@amazon.com>
  • Loading branch information
LDrago27 committed Apr 22, 2024
1 parent 6e3cc01 commit 70340cf
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cypress-workflow-bundle-snapshot-based.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
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
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true --usageCollection.uiMetric.enabled=true

tests-without-security:
needs: changes
Expand All @@ -35,5 +35,5 @@ jobs:
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-without-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
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true --usageCollection.uiMetric.enabled=true
security-enabled: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);

describe('dev_console_ui_metric', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
miscUtils.visitPage('app/dev_tools#/console');
cy.wait(30000);
cy.get('[data-test-subj="help-close-button"]').then(($btn) => {
if ($btn.is(':visible')) {
cy.wrap($btn).click({ force: true });
} else {
cy.get('[type="button"]').contains('Console').click({ force: true });
}
});
cy.wait(5000);
});

it('check UI Metric are being recorded', function () {
cy.intercept('api/ui_metric/report', cy.spy().as('reportreq'));

miscUtils.visitPage('app/home#/');

cy.wait(45000);

cy.get('@reportreq').should('be.called');

// Now verify the response of api/stat

cy.wait(5000);

cy.request(
'GET',
'http://localhost:5601/api/stats?extended=true&legacy=true&exclude_usage=false'
).then((res) => {
expect(res.status).to.eq(200);
expect(res.body)
.to.have.property('usage')
.that.has.property('application_usage')
.that.has.property('dev_tools');
expect(res.body)
.to.have.property('usage')
.that.has.property('ui_metric')
.that.has.property('console')
.that.has.property('length')
.that.is.gt(0);
});
});
});

0 comments on commit 70340cf

Please sign in to comment.