@@ -372,6 +372,26 @@ describe('Schema Testing', () => {
372372 } ) ;
373373 } ) ;
374374
375+ it ( 'throws an error on duplicate member names' , async ( ) => {
376+ const orders = fs . readFileSync (
377+ path . join ( process . cwd ( ) , '/test/unit/fixtures/orders_dup_members.js' ) ,
378+ 'utf8'
379+ ) ;
380+
381+ const { compiler } = prepareCompiler ( [
382+ {
383+ content : orders ,
384+ fileName : 'orders.js' ,
385+ } ,
386+ ] ) ;
387+
388+ try {
389+ await compiler . compile ( ) ;
390+ } catch ( e : any ) {
391+ expect ( e . toString ( ) ) . toMatch ( / s t a t u s d e f i n e d m o r e t h a n o n c e / ) ;
392+ }
393+ } ) ;
394+
375395 it ( 'valid schema with accessPolicy' , async ( ) => {
376396 const { compiler } = prepareJsCompiler ( [
377397 createCubeSchemaWithAccessPolicy ( 'ProtectedCube' ) ,
@@ -380,6 +400,159 @@ describe('Schema Testing', () => {
380400 compiler . throwIfAnyErrors ( ) ;
381401 } ) ;
382402
403+ describe ( 'Views' , ( ) => {
404+ it ( 'throws errors for incorrect referenced includes members' , async ( ) => {
405+ const orders = fs . readFileSync (
406+ path . join ( process . cwd ( ) , '/test/unit/fixtures/orders.js' ) ,
407+ 'utf8'
408+ ) ;
409+ const ordersView = `
410+ views:
411+ - name: orders_view
412+ cubes:
413+ - join_path: orders
414+ includes:
415+ - id
416+ - status
417+ - nonexistent1
418+ - nonexistent2.via.path
419+ ` ;
420+
421+ const { compiler } = prepareCompiler ( [
422+ {
423+ content : orders ,
424+ fileName : 'orders.js' ,
425+ } ,
426+ {
427+ content : ordersView ,
428+ fileName : 'order_view.yml' ,
429+ } ,
430+ ] ) ;
431+
432+ try {
433+ await compiler . compile ( ) ;
434+ } catch ( e : any ) {
435+ expect ( e . toString ( ) ) . toMatch ( / P a t h s a r e n ' t a l l o w e d i n c u b e i n c l u d e s b u t ' n o n e x i s t e n t 2 \. v i a \. p a t h ' p r o v i d e d a s i n c l u d e m e m b e r / ) ;
436+ expect ( e . toString ( ) ) . toMatch ( / M e m b e r ' n o n e x i s t e n t 1 ' i s i n c l u d e d i n ' o r d e r s _ v i e w ' b u t n o t d e f i n e d i n a n y c u b e / ) ;
437+ expect ( e . toString ( ) ) . toMatch ( / M e m b e r ' n o n e x i s t e n t 2 \. v i a \. p a t h ' i s i n c l u d e d i n ' o r d e r s _ v i e w ' b u t n o t d e f i n e d i n a n y c u b e / ) ;
438+ }
439+ } ) ;
440+
441+ it ( 'throws errors for incorrect referenced excludes members' , async ( ) => {
442+ const orders = fs . readFileSync (
443+ path . join ( process . cwd ( ) , '/test/unit/fixtures/orders.js' ) ,
444+ 'utf8'
445+ ) ;
446+ const ordersView = `
447+ views:
448+ - name: orders_view
449+ cubes:
450+ - join_path: orders
451+ includes: "*"
452+ excludes:
453+ - id
454+ - status
455+ - nonexistent3
456+ - nonexistent4
457+ ` ;
458+
459+ const { compiler } = prepareCompiler ( [
460+ {
461+ content : orders ,
462+ fileName : 'orders.js' ,
463+ } ,
464+ {
465+ content : ordersView ,
466+ fileName : 'order_view.yml' ,
467+ } ,
468+ ] ) ;
469+
470+ try {
471+ await compiler . compile ( ) ;
472+ } catch ( e : any ) {
473+ expect ( e . toString ( ) ) . toMatch ( / M e m b e r ' n o n e x i s t e n t 3 ' i s i n c l u d e d i n ' o r d e r s _ v i e w ' b u t n o t d e f i n e d i n a n y c u b e / ) ;
474+ expect ( e . toString ( ) ) . toMatch ( / M e m b e r ' n o n e x i s t e n t 4 ' i s i n c l u d e d i n ' o r d e r s _ v i e w ' b u t n o t d e f i n e d i n a n y c u b e / ) ;
475+ }
476+ } ) ;
477+
478+ it ( 'throws errors for incorrect referenced excludes members with path' , async ( ) => {
479+ const orders = fs . readFileSync (
480+ path . join ( process . cwd ( ) , '/test/unit/fixtures/orders.js' ) ,
481+ 'utf8'
482+ ) ;
483+ const ordersView = `
484+ views:
485+ - name: orders_view
486+ cubes:
487+ - join_path: orders
488+ includes: "*"
489+ excludes:
490+ - id
491+ - status
492+ - nonexistent5.via.path
493+ ` ;
494+
495+ const { compiler } = prepareCompiler ( [
496+ {
497+ content : orders ,
498+ fileName : 'orders.js' ,
499+ } ,
500+ {
501+ content : ordersView ,
502+ fileName : 'order_view.yml' ,
503+ } ,
504+ ] ) ;
505+
506+ try {
507+ await compiler . compile ( ) ;
508+ } catch ( e : any ) {
509+ expect ( e . toString ( ) ) . toMatch ( / P a t h s a r e n ' t a l l o w e d i n c u b e e x c l u d e s b u t ' n o n e x i s t e n t 5 \. v i a \. p a t h ' p r o v i d e d a s e x c l u d e m e m b e r / ) ;
510+ }
511+ } ) ;
512+
513+ it ( 'throws errors for conflicting members of included cubes' , async ( ) => {
514+ const orders = fs . readFileSync (
515+ path . join ( process . cwd ( ) , '/test/unit/fixtures/orders_big.js' ) ,
516+ 'utf8'
517+ ) ;
518+ const orderUsers = fs . readFileSync (
519+ path . join ( process . cwd ( ) , '/test/unit/fixtures/order_users.yml' ) ,
520+ 'utf8'
521+ ) ;
522+ const ordersView = `
523+ views:
524+ - name: orders_view
525+ cubes:
526+ - join_path: orders
527+ includes: "*"
528+ - join_path: orders.order_users
529+ includes: "*"
530+ ` ;
531+
532+ const { compiler } = prepareCompiler ( [
533+ {
534+ content : orders ,
535+ fileName : 'orders.js' ,
536+ } ,
537+ {
538+ content : orderUsers ,
539+ fileName : 'order_users.yml' ,
540+ } ,
541+ {
542+ content : ordersView ,
543+ fileName : 'order_view.yml' ,
544+ } ,
545+ ] ) ;
546+
547+ try {
548+ await compiler . compile ( ) ;
549+ } catch ( e : any ) {
550+ expect ( e . toString ( ) ) . toMatch ( / I n c l u d e d m e m b e r ' c o u n t ' c o n f l i c t s w i t h e x i s t i n g m e m b e r o f ' o r d e r s _ v i e w ' \. P l e a s e c o n s i d e r e x c l u d i n g t h i s m e m b e r o r a s s i g n i n g i t a n a l i a s / ) ;
551+ expect ( e . toString ( ) ) . toMatch ( / I n c l u d e d m e m b e r ' i d ' c o n f l i c t s w i t h e x i s t i n g m e m b e r o f ' o r d e r s _ v i e w ' \. P l e a s e c o n s i d e r e x c l u d i n g t h i s m e m b e r o r a s s i g n i n g i t a n a l i a s / ) ;
552+ }
553+ } ) ;
554+ } ) ;
555+
383556 describe ( 'Inheritance' , ( ) => {
384557 it ( 'CubeB.js correctly extends cubeA.js (no additions)' , async ( ) => {
385558 const orders = fs . readFileSync (
0 commit comments