@@ -3,7 +3,7 @@ import { Response, Roles } from "../../../support/pages/rbac";
33import { UI_HELPER_ELEMENTS } from "../../../support/page-objects/global-obj" ;
44import {
55 SEARCH_OBJECTS_COMPONENTS ,
6- ROLE_OVERVIEW_COMPONENTS ,
6+ ROLE_OVERVIEW_COMPONENTS_TEST_ID ,
77 ROLES_PAGE_COMPONENTS ,
88} from "../../../support/page-objects/page-obj" ;
99import { Common , setupBrowser } from "../../../utils/common" ;
@@ -213,8 +213,6 @@ test.describe.serial("Test RBAC", () => {
213213 } ) ;
214214
215215 test . describe ( "Test RBAC plugin as an admin user" , ( ) => {
216- // TODO: fix https://issues.redhat.com/browse/RHIDP-6625 and remove the skip
217- test . skip ( ( ) => process . env . IS_OPENSHIFT . includes ( "false" ) ) ;
218216 test . beforeEach ( async ( { page } , testInfo ) => {
219217 testInfo . setTimeout ( testInfo . timeout + 30_000 ) ; // Additional time due to repeated timeout failure in OSD env.
220218 const common = new Common ( page ) ;
@@ -236,28 +234,33 @@ test.describe.serial("Test RBAC", () => {
236234 await uiHelper . verifyCellsInTable ( allCellsIdentifier ) ;
237235 } ) ;
238236
239- test ( "Should download the user list" , async ( { page } ) => {
240- await page . locator ( 'a:has-text("Download User List")' ) . click ( ) ;
241- const fileContent = await downloadAndReadFile (
242- page ,
243- 'a:has-text("Download User List")' ,
244- ) ;
237+ test ( "Should export CSV of the user list" , async ( { page } ) => {
238+ const exportCsvLink = page . getByRole ( "link" , { name : "Export CSV" } ) ;
239+ await exportCsvLink . click ( ) ;
240+ const fileContent = await downloadAndReadFile ( page , exportCsvLink ) ;
241+ await test . info ( ) . attach ( "user-list-file" , {
242+ body : fileContent ,
243+ contentType : "text/plain" ,
244+ } ) ;
245245 const lines = fileContent . trim ( ) . split ( "\n" ) ;
246246
247247 const header = "userEntityRef,displayName,email,lastAuthTime" ;
248- // eslint-disable-next-line playwright/no-conditional-in-test
249- if ( lines [ 0 ] !== header ) {
250- throw new Error ( "Header does not match" ) ;
251- }
248+ expect ( lines [ 0 ] , "Header needs to match the expected header" ) . toBe (
249+ header ,
250+ ) ;
252251
253- // Check that each subsequent line starts with "user:default"
254- const allUsersValid = lines
252+ // Check that each subsequent line starts with "user:default" or "user:development"
253+ const invalidLines = lines
255254 . slice ( 1 )
256- . every ( ( line ) => line . startsWith ( "user:default" ) ) ;
257- // eslint-disable-next-line playwright/no-conditional-in-test
258- if ( ! allUsersValid ) {
259- throw new Error ( "Not all users info are valid" ) ;
260- }
255+ . filter (
256+ ( line ) =>
257+ ! line . startsWith ( "user:default" ) &&
258+ ! line . startsWith ( "user:development" ) ,
259+ ) ;
260+
261+ await test . step ( `Validate user lines: ${ invalidLines . length } invalid out of ${ lines . length } total` , async ( ) => {
262+ expect ( invalidLines , "All users should be valid" ) . toHaveLength ( 0 ) ;
263+ } ) ;
261264 } ) ;
262265
263266 test ( "View details of a role" , async ( { page } ) => {
@@ -277,7 +280,7 @@ test.describe.serial("Test RBAC", () => {
277280 Roles . getUsersAndGroupsListCellsIdentifier ( ) ;
278281 await uiHelper . verifyCellsInTable ( usersAndGroupsCellsIdentifier ) ;
279282
280- await uiHelper . verifyHeading ( "Permission policies (5) " ) ;
283+ await uiHelper . verifyHeading ( "5 permissions " ) ;
281284 const permissionPoliciesColumnsText =
282285 Roles . getPermissionPoliciesListColumnsText ( ) ;
283286 await uiHelper . verifyColumnHeading ( permissionPoliciesColumnsText ) ;
@@ -381,7 +384,9 @@ test.describe.serial("Test RBAC", () => {
381384 await uiHelper . verifyHeading ( "role:default/test-role1" ) ;
382385 await uiHelper . clickTab ( "Overview" ) ;
383386
384- await page . click ( ROLE_OVERVIEW_COMPONENTS . updateMembers ) ;
387+ await page
388+ . getByTestId ( ROLE_OVERVIEW_COMPONENTS_TEST_ID . updateMembers )
389+ . click ( ) ;
385390 await uiHelper . verifyHeading ( "Edit Role" ) ;
386391 await uiHelper . fillTextInputByLabel (
387392 "Select users and groups" ,
@@ -409,7 +414,9 @@ test.describe.serial("Test RBAC", () => {
409414 ) ;
410415 await uiHelper . verifyHeading ( rbacPo . regexpShortUsersAndGroups ( 1 , 1 ) ) ;
411416
412- await page . click ( ROLE_OVERVIEW_COMPONENTS . updatePolicies ) ;
417+ await page
418+ . getByTestId ( ROLE_OVERVIEW_COMPONENTS_TEST_ID . updatePolicies )
419+ . click ( ) ;
413420 await uiHelper . verifyHeading ( "Edit Role" ) ;
414421 await rbacPo . selectPluginsCombobox . click ( ) ;
415422 await rbacPo . selectOption ( "scaffolder" ) ;
@@ -421,21 +428,26 @@ test.describe.serial("Test RBAC", () => {
421428 await uiHelper . verifyText (
422429 "Role role:default/test-role1 updated successfully" ,
423430 ) ;
424- await uiHelper . verifyHeading ( "Permission Policies (2) " ) ;
431+ await uiHelper . verifyHeading ( "2 permissions " ) ;
425432
426433 await rbacPo . deleteRole ( "role:default/test-role1" ) ;
427434 } ) ;
428435
429436 test ( "Create a role with a permission policy per resource type and verify that the only authorized users can access specific resources." , async ( {
430437 page,
431438 } ) => {
439+ // TODO: https://issues.redhat.com/browse/RHDHBUGS-2127
440+ test . fixme ( true , "Cannot delete role because of missing permissions" ) ;
441+
432442 const uiHelper = new UIhelper ( page ) ;
433443 const rbacPo = new RbacPo ( page ) ;
434444 await rbacPo . createConditionalRole (
435445 "test-role1" ,
436- [ "Guest User" , "rhdh-qe" ] ,
446+ [ "Guest User" , "rhdh-qe rhdh-qe " ] ,
437447 [ "Backstage" ] ,
438448 "anyOf" ,
449+ "catalog" ,
450+ "user:default/rhdh-qe" ,
439451 ) ;
440452
441453 await page
0 commit comments