@@ -45,6 +45,9 @@ describe("Resource tests", () => {
4545 commitmentSum : 10 ,
4646 editableResource : true ,
4747 per_az : [ [ "az1" , { projects_usage : 10 } ] ] ,
48+ commitment_config : {
49+ durations : [ "1 year" ] ,
50+ } ,
4851 } ;
4952 let forwardProps = {
5053 area : "testArea" ,
@@ -64,7 +67,7 @@ describe("Resource tests", () => {
6467 </ StoreProvider >
6568 </ PortalProvider >
6669 ) ;
67- const { result } = await waitFor ( ( ) => {
70+ const { rerender , result } = await waitFor ( ( ) => {
6871 return renderHook (
6972 ( ) => ( {
7073 globalStore : globalStore ( ) ,
@@ -73,18 +76,24 @@ describe("Resource tests", () => {
7376 { wrapper }
7477 ) ;
7578 } ) ;
76-
77- // Project level
79+ // The forbidAutogrowth edit option is available at the project level.
7880 act ( ( ) => {
7981 result . current . globalStoreActions . setScope ( scope ) ;
8082 } ) ;
81- // The forbidAutogrowthSwitch edit option is available for project level.
83+ expect ( screen . queryByTestId ( "forbidAutogrowthSwitch" ) ) . toBeInTheDocument ( ) ;
84+ expect ( screen . getByTestId ( "edit/testResource" ) ) . toBeInTheDocument ( ) ;
85+ expect ( screen . queryByTestId ( "setMaxQuotaPanel" ) ) . not . toBeInTheDocument ( ) ;
86+
87+ // The forbidAutogrowth edit option is only available for committable resources.
88+ delete res . commitment_config ;
89+ rerender ( ) ;
8290 act ( ( ) => {
8391 result . current . globalStoreActions . setScope ( scope ) ;
8492 } ) ;
85- expect ( screen . queryByTestId ( "forbidAutogrowthSwitch" ) ) . toBeInTheDocument ( ) ;
93+ expect ( screen . queryByTestId ( "forbidAutogrowthSwitch" ) ) . not . toBeInTheDocument ( ) ;
8694 expect ( screen . getByTestId ( "edit/testResource" ) ) . toBeInTheDocument ( ) ;
8795 expect ( screen . queryByTestId ( "setMaxQuotaPanel" ) ) . not . toBeInTheDocument ( ) ;
96+ res . commitment_config = { durations : [ "1 year" ] } ;
8897
8998 // Domain level allows setting Max-Quota.
9099 scope = new Scope ( { domainID : "456" } ) ;
0 commit comments