Skip to content

Commit

Permalink
Cypress e2e Test - Verify That "Usage Data Collection" Can Be Set In …
Browse files Browse the repository at this point in the history
…"Cluster Settings" (#3647)

* adding new test

* add additional tag
  • Loading branch information
ConorOM1 authored Jan 16, 2025
1 parent bfe6c12 commit 67669d6
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers';
import {
clusterSettings,
telemetrySettings,
} from '~/__tests__/cypress/cypress/pages/clusterSettings';
import { getCustomResource } from '~/__tests__/cypress/cypress/utils/oc_commands/customResources';

describe('Verify That Usage Data Collection Can Be Set In Cluster Settings', () => {
let skipTest = false;

before(() => {
// Check if the operator is RHOAI, if its not, skip the test
cy.step('Check if the operator is RHOAI');
getCustomResource('redhat-ods-operator', 'Deployment', 'name=rhods-operator').then((result) => {
if (!result.stdout.includes('rhods-operator')) {
cy.log('RHOAI operator not found, skipping the test.');
skipTest = true;
} else {
cy.log('RHOAI operator confirmed:', result.stdout);
}
});
});

it(
'Verify Usage Data Collection can be Enabled/Disabled',
{ tags: ['@Sanity', '@SanitySet1', '@ODS-1218', '@Dashboard', '@ExcludeOnODH'] },
() => {
if (skipTest) {
cy.log('Skipping test confirmed');
return;
}

// Authentication and navigation
cy.step('Log into the application');
cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER);
clusterSettings.navigate();

// Check that usage data collection is enabled by default
cy.step('Data collection is enabled');
telemetrySettings.findEnabledCheckbox().should('be.checked');

// Disable data usage collection
cy.step('Disable usage data collection');
telemetrySettings.findEnabledCheckbox().click();

// Save changes in cluster settings
cy.step('Save changes and wait for changes to be applied');
clusterSettings.findSubmitButton().click();

// Refresh and verify data collection is still disabled
cy.step('Refresh settings view');
cy.reload();
telemetrySettings.findEnabledCheckbox().should('not.be.checked');
},
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const getCustomResource = (
kind: string,
labelSelector: string,
): Cypress.Chainable<CommandLineResult> => {
const ocCommand = `Oc Get kind=${kind}, label_selector=${labelSelector}, namespace=${resourceNamespace}`;
const ocCommand = `oc get ${kind} -l ${labelSelector} -n ${resourceNamespace}`;
cy.log(`Executing command: ${ocCommand}`);
return cy.exec(ocCommand, { failOnNonZeroExit: false });
};
Expand Down

0 comments on commit 67669d6

Please sign in to comment.