@@ -5,6 +5,7 @@ import babelTraverse from '@babel/traverse';
55import { prepareJsCompiler } from './PrepareCompiler' ;
66import { ImportExportTranspiler } from '../../src/compiler/transpilers' ;
77import { ErrorReporter } from '../../src/compiler/ErrorReporter' ;
8+ import { PostgresQuery } from '../../src' ;
89
910describe ( 'Transpilers' , ( ) => {
1011 it ( 'CubeCheckDuplicatePropTranspiler' , async ( ) => {
@@ -50,6 +51,72 @@ describe('Transpilers', () => {
5051 await compiler . compile ( ) ;
5152 } ) ;
5253
54+ it ( 'CubePropContextTranspiler with full path to userAttributes should work normally' , async ( ) => {
55+ const { cubeEvaluator, compiler } = prepareJsCompiler ( `
56+ cube(\`Test\`, {
57+ sql: 'SELECT * FROM users',
58+ dimensions: {
59+ userId: {
60+ sql: \`userId\`,
61+ type: 'string'
62+ }
63+ },
64+ accessPolicy: [
65+ {
66+ role: \`*\`,
67+ rowLevel: {
68+ filters: [
69+ {
70+ member: \`userId\`,
71+ operator: \`equals\`,
72+ values: [ securityContext.cubeCloud.userAttributes.userId ]
73+ }
74+ ]
75+ }
76+ }
77+ ]
78+ })
79+ ` ) ;
80+
81+ await compiler . compile ( ) ;
82+
83+ const transpiledValues = cubeEvaluator . cubeFromPath ( 'Test' ) . accessPolicy ?. [ 0 ] . rowLevel ?. filters ?. [ 0 ] . values ;
84+ expect ( transpiledValues . toString ( ) ) . toMatch ( 'securityContext.cubeCloud.userAttributes.userId' ) ;
85+ } ) ;
86+
87+ it ( 'CubePropContextTranspiler with shorthand userAttributes should work normally' , async ( ) => {
88+ const { cubeEvaluator, compiler } = prepareJsCompiler ( `
89+ cube(\`Test\`, {
90+ sql: 'SELECT * FROM users',
91+ dimensions: {
92+ userId: {
93+ sql: \`userId\`,
94+ type: 'string'
95+ }
96+ },
97+ accessPolicy: [
98+ {
99+ role: \`*\`,
100+ rowLevel: {
101+ filters: [
102+ {
103+ member: \`userId\`,
104+ operator: \`equals\`,
105+ values: [ userAttributes.userId ]
106+ }
107+ ]
108+ }
109+ }
110+ ]
111+ })
112+ ` ) ;
113+
114+ await compiler . compile ( ) ;
115+
116+ const transpiledValues = cubeEvaluator . cubeFromPath ( 'Test' ) . accessPolicy ?. [ 0 ] . rowLevel ?. filters ?. [ 0 ] . values ;
117+ expect ( transpiledValues . toString ( ) ) . toMatch ( 'securityContext.cubeCloud.userAttributes.userId' ) ;
118+ } ) ;
119+
53120 it ( 'ImportExportTranspiler' , async ( ) => {
54121 const ieTranspiler = new ImportExportTranspiler ( ) ;
55122 const errorsReport = new ErrorReporter ( ) ;
0 commit comments