File tree Expand file tree Collapse file tree 4 files changed +49
-4
lines changed Expand file tree Collapse file tree 4 files changed +49
-4
lines changed Original file line number Diff line number Diff line change 11import { IPlugin } from '@shell/core/types' ;
22import { PRODUCT_SETTING_NAME , SETTING_PAGE_NAME } from './constants' ;
3+ import { IF_HAVE } from '@shell/store/type-map' ;
4+ import { SCC } from '@shell/store/features' ;
35
46// Product configuration
57export function init ( $plugin : IPlugin , store : any ) {
@@ -9,9 +11,11 @@ export function init($plugin: IPlugin, store: any) {
911 } = $plugin . DSL ( store , PRODUCT_SETTING_NAME ) ;
1012
1113 virtualType ( {
12- labelKey : 'registration.navigation.label' ,
13- name : SETTING_PAGE_NAME ,
14- route : { name : SETTING_PAGE_NAME } ,
14+ ifHave : IF_HAVE . ADMIN ,
15+ ifFeature : SCC ,
16+ labelKey : 'registration.navigation.label' ,
17+ name : SETTING_PAGE_NAME ,
18+ route : { name : SETTING_PAGE_NAME } ,
1519 } ) ;
1620
1721 basicType ( [ SETTING_PAGE_NAME ] ) ;
Original file line number Diff line number Diff line change 1+ import { SCC } from '@shell/store/features' ;
2+ const { IF_HAVE } = require ( '@shell/store/type-map' ) ;
3+
4+ jest . doMock ( '@rancher/auto-import' , ( ) => ( { importTypes : jest . fn ( ) } ) , { virtual : true } ) ;
5+
6+ describe ( 'extension: rancher-prime' , ( ) => {
7+ it ( 'should enable routing for admin users with SCC feature' , async ( ) => {
8+ const plugin = await import ( './index' ) ; // initialized after the mock
9+ const virtualTypeSpy = jest . fn ( ) ;
10+ const basicTypeSpy = jest . fn ( ) ;
11+ const dslMock = jest . fn ( ) . mockReturnValue ( {
12+ virtualType : virtualTypeSpy ,
13+ basicType : basicTypeSpy
14+ } ) ;
15+
16+ const pluginMock = {
17+ environment : { isPrime : true } ,
18+ addProduct : jest . fn ( ) ,
19+ addRoutes : jest . fn ( ) ,
20+ addPanel : jest . fn ( ) ,
21+ addNavHooks : jest . fn ( ) ,
22+ register : jest . fn ( ) , // Used in installDocHandler
23+ metadata : { } ,
24+ DSL : dslMock
25+ } as any ;
26+
27+ plugin . default ( pluginMock ) ; // basic extension import
28+ pluginMock . addProduct . mock . calls [ 0 ] [ 0 ] . init ( pluginMock , { } ) ; // force init to trigger as in @rancher /shell
29+
30+ expect ( pluginMock . addProduct ) . toHaveBeenCalledWith (
31+ expect . objectContaining ( { init : expect . any ( Function ) } )
32+ ) ;
33+ expect ( virtualTypeSpy ) . toHaveBeenCalledWith (
34+ expect . objectContaining ( {
35+ ifHave : IF_HAVE . ADMIN ,
36+ ifFeature : SCC
37+ } )
38+ ) ;
39+ } ) ;
40+ } ) ;
Original file line number Diff line number Diff line change @@ -53,8 +53,8 @@ const poolRegistration = (store: Store<any>) => {
5353 if ( store . state [ 'managementReady' ] ) {
5454 setNotification ( store ) ;
5555 clearInterval ( id ) ;
56+ attempts -= 1 ;
5657 }
57- attempts -= 1 ;
5858 } , 1000 ) ;
5959} ;
6060
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export const STEVE_CACHE = create('ui-sql-cache', false);
3737export const UIEXTENSION = create ( 'uiextension' , true ) ;
3838export const PROVISIONING_PRE_BOOTSTRAP = create ( 'provisioningprebootstrap' , false ) ;
3939export const SCHEDULING_CUSTOMIZATION = create ( SCHEDULING_CUSTOMIZATION_FEATURE , false ) ;
40+ export const SCC = create ( 'rancher-scc-registration-extension' , true ) ;
4041
4142// Not currently used.. no point defining ones we don't use
4243// export const EMBEDDED_CLUSTER_API = create('embedded-cluster-api', true);
You can’t perform that action at this time.
0 commit comments