@@ -105,10 +105,17 @@ describe("Content", () => {
105105 } ) ;
106106 } ) ;
107107
108+ } ) ;
109+
110+ describe ( "Advanced form" , ( ) => {
108111 it ( "should conditionally show security analyzer based on confirmation mode" , async ( ) => {
109112 renderLlmSettingsScreen ( ) ;
110113 await screen . findByTestId ( "llm-settings-screen" ) ;
111114
115+ // Enable advanced mode first
116+ const advancedSwitch = screen . getByTestId ( "advanced-settings-switch" ) ;
117+ await userEvent . click ( advancedSwitch ) ;
118+
112119 const confirmation = screen . getByTestId (
113120 "enable-confirmation-mode-switch" ,
114121 ) ;
@@ -135,9 +142,7 @@ describe("Content", () => {
135142 screen . queryByTestId ( "security-analyzer-input" ) ,
136143 ) . not . toBeInTheDocument ( ) ;
137144 } ) ;
138- } ) ;
139145
140- describe ( "Advanced form" , ( ) => {
141146 it ( "should render the advanced form if the switch is toggled" , async ( ) => {
142147 renderLlmSettingsScreen ( ) ;
143148 await screen . findByTestId ( "llm-settings-screen" ) ;
@@ -615,7 +620,7 @@ describe("Form submission", () => {
615620 expect . objectContaining ( {
616621 llm_model : "openhands/claude-sonnet-4-20250514" ,
617622 llm_base_url : "" ,
618- confirmation_mode : true , // Confirmation mode is now a basic setting, should be preserved
623+ confirmation_mode : false , // Confirmation mode is now an advanced setting, should be cleared when saving basic settings
619624 } ) ,
620625 ) ;
621626 } ) ;
@@ -776,19 +781,20 @@ describe("SaaS mode", () => {
776781 const modelInput = screen . getByTestId ( "llm-model-input" ) ;
777782 const apiKeyInput = screen . getByTestId ( "llm-api-key-input" ) ;
778783 const advancedSwitch = screen . getByTestId ( "advanced-settings-switch" ) ;
779- const confirmationModeSwitch = screen . getByTestId (
780- "enable-confirmation-mode-switch" ,
781- ) ;
782784 const submitButton = screen . getByTestId ( "submit-button" ) ;
783785
784786 // Inputs should be disabled
785787 expect ( providerInput ) . toBeDisabled ( ) ;
786788 expect ( modelInput ) . toBeDisabled ( ) ;
787789 expect ( apiKeyInput ) . toBeDisabled ( ) ;
788790 expect ( advancedSwitch ) . toBeDisabled ( ) ;
789- expect ( confirmationModeSwitch ) . toBeDisabled ( ) ;
790791 expect ( submitButton ) . toBeDisabled ( ) ;
791792
793+ // Confirmation mode switch is in advanced view, so it's not visible in basic view
794+ expect (
795+ screen . queryByTestId ( "enable-confirmation-mode-switch" ) ,
796+ ) . not . toBeInTheDocument ( ) ;
797+
792798 // Try to interact with inputs - they should not respond
793799 await userEvent . click ( providerInput ) ;
794800 await userEvent . type ( apiKeyInput , "test-key" ) ;
@@ -935,19 +941,17 @@ describe("SaaS mode", () => {
935941 renderLlmSettingsScreen ( ) ;
936942 await screen . findByTestId ( "llm-settings-screen" ) ;
937943
938- // Verify that form elements are disabled for unsubscribed users
939- const confirmationModeSwitch = screen . getByTestId (
940- "enable-confirmation-mode-switch" ,
941- ) ;
944+ // Verify that basic form elements are disabled for unsubscribed users
945+ const advancedSwitch = screen . getByTestId ( "advanced-settings-switch" ) ;
942946 const submitButton = screen . getByTestId ( "submit-button" ) ;
943947
944- expect ( confirmationModeSwitch ) . not . toBeChecked ( ) ;
945- expect ( confirmationModeSwitch ) . toBeDisabled ( ) ;
948+ expect ( advancedSwitch ) . toBeDisabled ( ) ;
946949 expect ( submitButton ) . toBeDisabled ( ) ;
947950
948- // Try to click the disabled confirmation mode switch - it should not change state
949- await userEvent . click ( confirmationModeSwitch ) ;
950- expect ( confirmationModeSwitch ) . not . toBeChecked ( ) ; // Should remain unchecked
951+ // Confirmation mode switch is in advanced view, which can't be accessed when form is disabled
952+ expect (
953+ screen . queryByTestId ( "enable-confirmation-mode-switch" ) ,
954+ ) . not . toBeInTheDocument ( ) ;
951955
952956 // Try to submit the form - button should remain disabled
953957 await userEvent . click ( submitButton ) ;
@@ -1107,14 +1111,17 @@ describe("SaaS mode", () => {
11071111 const providerInput = screen . getByTestId ( "llm-provider-input" ) ;
11081112 const modelInput = screen . getByTestId ( "llm-model-input" ) ;
11091113 const apiKeyInput = screen . getByTestId ( "llm-api-key-input" ) ;
1110- const confirmationModeSwitch = screen . getByTestId (
1111- "enable-confirmation-mode-switch" ,
1112- ) ;
1114+ const advancedSwitch = screen . getByTestId ( "advanced-settings-switch" ) ;
11131115
11141116 expect ( providerInput ) . toBeDisabled ( ) ;
11151117 expect ( modelInput ) . toBeDisabled ( ) ;
11161118 expect ( apiKeyInput ) . toBeDisabled ( ) ;
1117- expect ( confirmationModeSwitch ) . toBeDisabled ( ) ;
1119+ expect ( advancedSwitch ) . toBeDisabled ( ) ;
1120+
1121+ // Confirmation mode switch is in advanced view, which can't be accessed when form is disabled
1122+ expect (
1123+ screen . queryByTestId ( "enable-confirmation-mode-switch" ) ,
1124+ ) . not . toBeInTheDocument ( ) ;
11181125 } ) ;
11191126 } ) ;
11201127} ) ;
0 commit comments