1+ import { nav } from '../../views/nav' ;
2+ import { runCOORBACPersesTestsDevUser1 } from '../../support/perses/99.coo_rbac_perses_user1.cy' ;
3+
4+
5+ // Set constants for the operators that need to be installed for tests.
6+ const MCP = {
7+ namespace : 'openshift-cluster-observability-operator' ,
8+ packageName : 'cluster-observability-operator' ,
9+ operatorName : 'Cluster Observability Operator' ,
10+ config : {
11+ kind : 'UIPlugin' ,
12+ name : 'monitoring' ,
13+ } ,
14+ } ;
15+
16+ const MP = {
17+ namespace : 'openshift-monitoring' ,
18+ operatorName : 'Cluster Monitoring Operator' ,
19+ } ;
20+
21+ //TODO: change tag to @smoke , @dashboards, @perses when customizable-dashboards gets merged
22+ describe ( 'BVT: COO - Dashboards (Perses) - Administrator perspective' , { tags : [ '@smoke-' , '@dashboards-' , '@perses-dev' ] } , ( ) => {
23+
24+ before ( ( ) => {
25+ //TODO: https://issues.redhat.com/browse/OCPBUGS-58468 - when it gets fixed, installation can be don using non-admin user
26+ // Step 1: Grant temporary cluster-admin role to dev user for COO/Perses installation
27+ // cy.log('Granting temporary cluster-admin role to dev user for setup');
28+ // cy.adminCLI(
29+ // `oc adm policy add-cluster-role-to-user cluster-admin ${Cypress.env('LOGIN_USERNAME')}`,
30+ // );
31+
32+ // Step 2: Setup COO and Perses dashboards (requires admin privileges)
33+ cy . beforeBlockCOO ( MCP , MP ) ;
34+ cy . setupPersesRBACandExtraDashboards ( ) ;
35+
36+ //TODO: https://issues.redhat.com/browse/OCPBUGS-58468 - when it gets fixed, installation can be don using non-admin user
37+ // Step 3: Remove cluster-admin role - dev user now has limited permissions
38+ // cy.log('Removing cluster-admin role from dev user');
39+ // cy.adminCLI(
40+ // `oc adm policy remove-cluster-role-from-user cluster-admin ${Cypress.env('LOGIN_USERNAME')}`,
41+ // );
42+
43+ // Step 4: Clear Cypress session cache and logout
44+ // This is critical because beforeBlockCOO uses cy.session() which caches the login state
45+ cy . log ( 'Clearing Cypress session cache to ensure fresh login' ) ;
46+ Cypress . session . clearAllSavedSessions ( ) ;
47+
48+ // Clear all cookies and storage to fully reset browser state
49+ cy . clearAllCookies ( ) ;
50+ cy . clearAllLocalStorage ( ) ;
51+ cy . clearAllSessionStorage ( ) ;
52+
53+ // Step 5: Re-login as dev user (now without cluster-admin role)
54+ // Using cy.relogin() because it doesn't require oauthurl and handles the login page directly
55+ cy . log ( 'Re-logging in as dev user with limited permissions' ) ;
56+ cy . relogin (
57+ Cypress . env ( 'LOGIN_IDP_DEV_USER' ) ,
58+ Cypress . env ( 'LOGIN_USERNAME1' ) ,
59+ Cypress . env ( 'LOGIN_PASSWORD1' ) ,
60+ ) ;
61+ cy . validateLogin ( ) ;
62+ cy . closeOnboardingModalIfPresent ( ) ;
63+ } ) ;
64+
65+ beforeEach ( ( ) => {
66+ nav . sidenav . clickNavLink ( [ 'Observe' , 'Dashboards (Perses)' ] ) ;
67+ } ) ;
68+
69+ after ( ( ) => {
70+ cy . cleanupExtraDashboards ( ) ;
71+ } ) ;
72+
73+ //TODO: rename after customizable-dashboards gets merged
74+ runCOORBACPersesTestsDevUser1 ( {
75+ name : 'Administrator' ,
76+ } ) ;
77+
78+ } ) ;
0 commit comments