Skip to content

Commit

Permalink
Updated cypress test based on text changes. (#630)
Browse files Browse the repository at this point in the history
* Added support for creating cluster metrics monitors with the cat/indices, and cat/shards API.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Updated snapshots.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Updated snapshots.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed import.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Adjusted label text.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Updated cypress test based on text changes.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Made all click() calls forced.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Adjusted check for the monitor creation button.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

---------

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
(cherry picked from commit 0e73fba)
  • Loading branch information
AWSHurneyt authored and github-actions[bot] committed Jul 13, 2023
1 parent 9d4a7b7 commit 4dc5410
Showing 1 changed file with 30 additions and 37 deletions.
67 changes: 30 additions & 37 deletions cypress/integration/cluster_metrics_monitor_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const addClusterMetricsTrigger = (triggerName, triggerIndex, actionName, isEdit,
// TODO: Passing button props in EUI accordion was added in newer versions (31.7.0+).
// If this ever becomes available, it can be used to pass data-test-subj for the button.
// Since the above is currently not possible, referring to the accordion button using its content
cy.get('button').contains('New trigger').click();
cy.get('button').contains('New trigger').click({ force: true });
}

// Type in the trigger name
Expand Down Expand Up @@ -86,27 +86,24 @@ describe('ClusterMetricsMonitor', () => {
});

it('for the Cluster Health API', () => {
// Confirm empty monitor list is loaded
cy.contains('There are no existing monitors');

// Go to create monitor page
cy.contains('Create monitor').click();
cy.contains('Create monitor', { timeout: 20000 }).click({ force: true });

// Select ClusterMetrics radio card
cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click();
cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click({ force: true });

// Wait for input to load and then type in the monitor name
cy.get('input[name="name"]').type(SAMPLE_CLUSTER_METRICS_HEALTH_MONITOR);

// Wait for the API types to load and then type in the Cluster Health API
cy.get('[data-test-subj="clusterMetricsApiTypeComboBox"]').type('cluster health{enter}');

// Confirm the Query parameters field is present and described as "optional"
cy.contains('Query parameters - optional');
// Confirm the Path parameters field is present and described as "optional"
cy.contains('Path parameters - optional');
cy.get('[data-test-subj="clusterMetricsParamsFieldText"]');

// Press the 'Run for response' button
cy.get('[data-test-subj="clusterMetricsPreviewButton"]').click();
cy.get('[data-test-subj="clusterMetricsPreviewButton"]').click({ force: true });

// Add a trigger
cy.contains('Add trigger').click({ force: true });
Expand All @@ -127,7 +124,7 @@ describe('ClusterMetricsMonitor', () => {
// .type('{downarrow}{enter}');

// Click the create button
cy.get('button').contains('Create').click();
cy.get('button').contains('Create').click({ force: true });

// Confirm we can see only one row in the trigger list by checking <caption> element
cy.contains('This table contains 1 row');
Expand All @@ -136,34 +133,31 @@ describe('ClusterMetricsMonitor', () => {
cy.contains(SAMPLE_TRIGGER);

// Go back to the Monitors list
cy.get('a').contains('Monitors').click();
cy.get('a').contains('Monitors').click({ force: true });

// Confirm we can see the created monitor in the list
cy.contains(SAMPLE_CLUSTER_METRICS_HEALTH_MONITOR);
});

it('for the Nodes Stats API', () => {
// Confirm empty monitor list is loaded
cy.contains('There are no existing monitors');

// Go to create monitor page
cy.contains('Create monitor').click();
cy.contains('Create monitor', { timeout: 20000 }).click({ force: true });

// Select ClusterMetrics radio card
cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click();
cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click({ force: true });

// Wait for input to load and then type in the monitor name
cy.get('input[name="name"]').type(SAMPLE_CLUSTER_METRICS_NODES_STATS_MONITOR);

// Wait for the API types to load and then type in the Cluster Health API
cy.get('[data-test-subj="clusterMetricsApiTypeComboBox"]').type('nodes stats{enter}');

// Confirm the Query parameters field is not present
cy.contains('Query parameters').should('not.exist');
// Confirm the Path parameters field is not present
cy.contains('Path parameters').should('not.exist');
cy.get('[data-test-subj="clusterMetricsParamsFieldText"]').should('not.exist');

// Press the 'Run for response' button
cy.get('[data-test-subj="clusterMetricsPreviewButton"]').click();
cy.get('[data-test-subj="clusterMetricsPreviewButton"]').click({ force: true });

// Add a trigger
cy.contains('Add trigger').click({ force: true });
Expand All @@ -184,7 +178,7 @@ describe('ClusterMetricsMonitor', () => {
// .type('{downarrow}{enter}');

// Click the create button
cy.get('button').contains('Create').click();
cy.get('button').contains('Create').click({ force: true });

// Confirm we can see only one row in the trigger list by checking <caption> element
cy.contains('This table contains 1 row');
Expand All @@ -193,38 +187,35 @@ describe('ClusterMetricsMonitor', () => {
cy.contains(SAMPLE_TRIGGER);

// Go back to the Monitors list
cy.get('a').contains('Monitors').click();
cy.get('a').contains('Monitors').click({ force: true });

// Confirm we can see the created monitor in the list
cy.contains(SAMPLE_CLUSTER_METRICS_NODES_STATS_MONITOR);
});
});

describe('displays Query parameters field appropriately', () => {
describe('displays Path parameters field appropriately', () => {
beforeEach(() => {
cy.deleteAllMonitors();
cy.reload();
});

it('for the CAT Snapshots API', () => {
// Confirm empty monitor list is loaded
cy.contains('There are no existing monitors');

// Go to create monitor page
cy.contains('Create monitor').click();
cy.contains('Create monitor', { timeout: 20000 }).click({ force: true });

// Select ClusterMetrics radio card
cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click();
cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click({ force: true });

// Wait for input to load and then type in the monitor name
cy.get('input[name="name"]').type(SAMPLE_CLUSTER_METRICS_CAT_SNAPSHOTS_MONITOR);

// Wait for the API types to load and then type in the Cluster Health API
cy.get('[data-test-subj="clusterMetricsApiTypeComboBox"]').type('list snapshots{enter}');

// Confirm the Query parameters field is present and is not described as "optional"
cy.contains('Query parameters - optional').should('not.exist');
cy.contains('Query parameters');
// Confirm the Path parameters field is present and is not described as "optional"
cy.contains('Path parameters - optional').should('not.exist');
cy.contains('Path parameters');
cy.get('[data-test-subj="clusterMetricsParamsFieldText"]');
});
});
Expand All @@ -235,14 +226,12 @@ describe('ClusterMetricsMonitor', () => {
cy.visit(`${Cypress.env('opensearch_dashboards')}/app/${PLUGIN_NAME}#/monitors`);

// Begin monitor creation
// Confirm empty monitor list is loaded
cy.contains('There are no existing monitors');

// Go to create monitor page
cy.contains('Create monitor').click();
cy.contains('Create monitor', { timeout: 20000 }).click({ force: true });

// Select ClusterMetrics radio card
cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click();
cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click({ force: true });

// Wait for input to load and then type in the monitor name
cy.get('input[name="name"]').type(SAMPLE_CLUSTER_METRICS_HEALTH_MONITOR);
Expand Down Expand Up @@ -302,7 +291,7 @@ describe('ClusterMetricsMonitor', () => {

describe('the modal CLOSE (i.e., the X button) button is clicked', () => {
// Click the CLOSE button
cy.get('[aria-label="Closes this modal window"]').click();
cy.get('[aria-label="Closes this modal window"]').click({ force: true });

// Confirm clearTriggersModal closed
cy.get('[data-test-subj="clusterMetricsClearTriggersModal"]').should('not.exist');
Expand All @@ -319,7 +308,9 @@ describe('ClusterMetricsMonitor', () => {
cy.get('[data-test-subj="clusterMetricsApiTypeComboBox"]').type('cluster stats{enter}');

// Click the KEEP button
cy.get('[data-test-subj="clusterMetricsClearTriggersModalKeepButton"]').click();
cy.get('[data-test-subj="clusterMetricsClearTriggersModalKeepButton"]').click({
force: true,
});

// Confirm clearTriggersModal closed
cy.get('[data-test-subj="clusterMetricsClearTriggersModal"]').should('not.exist');
Expand All @@ -333,7 +324,9 @@ describe('ClusterMetricsMonitor', () => {
cy.get('[data-test-subj="clusterMetricsApiTypeComboBox"]').type('cluster settings{enter}');

// Click the CLEAR button
cy.get('[data-test-subj="clusterMetricsClearTriggersModalClearButton"]').click();
cy.get('[data-test-subj="clusterMetricsClearTriggersModalClearButton"]').click({
force: true,
});

// Confirm clearTriggersModal closed
cy.get('[data-test-subj="clusterMetricsClearTriggersModal"]').should('not.exist');
Expand Down

0 comments on commit 4dc5410

Please sign in to comment.