diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testDataCollection.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testDataCollection.cy.ts new file mode 100644 index 0000000000..ce5d9e0190 --- /dev/null +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testDataCollection.cy.ts @@ -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'); + }, + ); +}); diff --git a/frontend/src/__tests__/cypress/cypress/utils/oc_commands/customResources.ts b/frontend/src/__tests__/cypress/cypress/utils/oc_commands/customResources.ts index 38416ce394..d9a3ffef63 100644 --- a/frontend/src/__tests__/cypress/cypress/utils/oc_commands/customResources.ts +++ b/frontend/src/__tests__/cypress/cypress/utils/oc_commands/customResources.ts @@ -49,7 +49,7 @@ export const getCustomResource = ( kind: string, labelSelector: string, ): Cypress.Chainable => { - 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 }); };