@@ -3,6 +3,7 @@ import type {Locator, Page} from '@playwright/test';
33import { retryAction } from '../../../utils/retryAction' ;
44import { MemoryViewer } from '../../memoryViewer/MemoryViewer' ;
55import { NodesPage } from '../../nodes/NodesPage' ;
6+ import type { Sidebar } from '../../sidebar/Sidebar' ;
67import { StoragePage } from '../../storage/StoragePage' ;
78import { VISIBILITY_TIMEOUT } from '../TenantPage' ;
89
@@ -229,6 +230,33 @@ export const TopShardsHistoricalColumns = [
229230 TOP_SHARDS_COLUMNS_IDS . IntervalEnd ,
230231] ;
231232
233+ export const ACL_SYNTAX_TEST_CONFIGS = [
234+ {
235+ syntax : 'YQL' as const ,
236+ patterns : {
237+ USERS : 'CONNECT' ,
238+ 'METADATA-READERS' : 'LIST' ,
239+ 'DATA-READERS' : 'SELECT ROW' ,
240+ } ,
241+ } ,
242+ {
243+ syntax : 'KiKiMr' as const ,
244+ patterns : {
245+ USERS : 'ConnectDatabase' ,
246+ 'METADATA-READERS' : 'List' ,
247+ 'DATA-READERS' : 'SelectRow' ,
248+ } ,
249+ } ,
250+ {
251+ syntax : 'YDB Short' as const ,
252+ patterns : {
253+ USERS : 'connect' ,
254+ 'METADATA-READERS' : 'list' ,
255+ 'DATA-READERS' : 'select_row' ,
256+ } ,
257+ } ,
258+ ] ;
259+
232260export class Diagnostics {
233261 table : Table ;
234262 storage : StoragePage ;
@@ -536,4 +564,71 @@ export class Diagnostics {
536564 . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
537565 return true ;
538566 }
567+
568+ async getEffectiveRightsFromTable ( ) : Promise < Record < string , string > > {
569+ const rightsTable = this . page . locator ( '.ydb-access-rights__rights-table' ) ;
570+ await rightsTable . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
571+
572+ const rows = await rightsTable . locator ( 'tbody tr' ) . all ( ) ;
573+ const rights : Record < string , string > = { } ;
574+
575+ for ( const row of rows ) {
576+ const cells = await row . locator ( 'td' ) . all ( ) ;
577+ if ( cells . length >= 3 ) {
578+ // Get the subject name from the avatar component
579+ const subjectElement = cells [ 0 ] . locator ( '.ydb-subject-with-avatar__subject' ) ;
580+ const subject = await subjectElement . textContent ( ) ;
581+ const effectiveRights = await cells [ 2 ] . textContent ( ) ;
582+ if ( subject && effectiveRights ) {
583+ rights [ subject . trim ( ) ] = effectiveRights . trim ( ) ;
584+ }
585+ }
586+ }
587+
588+ return rights ;
589+ }
590+
591+ async waitForTableDataToLoad ( ) : Promise < void > {
592+ // Wait for the table to be visible and have at least one row of data
593+ const rightsTable = this . page . locator ( '.ydb-access-rights__rights-table' ) ;
594+ await rightsTable . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
595+ await rightsTable
596+ . locator ( 'tbody tr' )
597+ . first ( )
598+ . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
599+ // Additional small delay to ensure data is fully loaded
600+ await this . page . waitForTimeout ( 500 ) ;
601+ }
602+
603+ async getPermissionLabelsInGrantDialog ( ) : Promise < string [ ] > {
604+ const labels = await this . page
605+ . locator ( '.ydb-grant-access__rights-wrapper .g-switch__text' )
606+ . all ( ) ;
607+ const texts : string [ ] = [ ] ;
608+ for ( const label of labels ) {
609+ const text = await label . textContent ( ) ;
610+ if ( text ) {
611+ texts . push ( text . trim ( ) ) ;
612+ }
613+ }
614+ return texts ;
615+ }
616+
617+ async switchAclSyntaxAndGetRights (
618+ sidebar : Sidebar ,
619+ syntax : 'KiKiMr' | 'YDB Short' | 'YDB' | 'YQL' ,
620+ ) : Promise < Record < string , string > > {
621+ // Switch syntax
622+ await sidebar . clickSettings ( ) ;
623+ await sidebar . selectAclSyntax ( syntax ) ;
624+ await sidebar . closeDrawer ( ) ;
625+
626+ // Refresh the page data by navigating away and back
627+ await this . clickTab ( DiagnosticsTab . Info ) ;
628+ await this . clickTab ( DiagnosticsTab . Access ) ;
629+ await this . waitForTableDataToLoad ( ) ;
630+
631+ // Get and return the rights
632+ return await this . getEffectiveRightsFromTable ( ) ;
633+ }
539634}
0 commit comments