@@ -64,7 +64,7 @@ describe('AddToStartupProgramAction', () => {
6464 expect ( await screen . findByRole ( 'spinbutton' , { name : 'Credit Amount' } ) ) . toHaveValue (
6565 5000
6666 ) ;
67- expect ( screen . getByRole ( 'textbox' , { name : 'Notes' } ) ) . toHaveValue ( 'sentryforstartups' ) ;
67+ expect ( screen . getByText ( 'sentryforstartups' ) ) . toBeInTheDocument ( ) ;
6868 } ) ;
6969
7070 it ( 'can submit with default values' , async ( ) => {
@@ -97,7 +97,69 @@ describe('AddToStartupProgramAction', () => {
9797 expect ( onSuccess ) . toHaveBeenCalled ( ) ;
9898 } ) ;
9999
100- it ( 'can submit with custom values' , async ( ) => {
100+ it ( 'can submit with a different option selected' , async ( ) => {
101+ const updateMock = MockApiClient . addMockResponse ( {
102+ url : `/_admin/customers/${ organization . slug } /balance-changes/` ,
103+ method : 'POST' ,
104+ body : { } ,
105+ } ) ;
106+
107+ triggerAddToStartupProgramModal ( modalProps ) ;
108+
109+ const { waitForModalToHide} = renderGlobalModal ( ) ;
110+
111+ await userEvent . click ( await screen . findByText ( 'sentryforstartups' ) ) ;
112+ await userEvent . click ( screen . getByText ( 'ycombinator' ) ) ;
113+
114+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Submit' } ) ) ;
115+
116+ await waitForModalToHide ( ) ;
117+
118+ await waitFor ( ( ) => {
119+ expect ( updateMock ) . toHaveBeenCalledWith (
120+ `/_admin/customers/${ organization . slug } /balance-changes/` ,
121+ expect . objectContaining ( {
122+ method : 'POST' ,
123+ data : {
124+ creditAmount : 500000 ,
125+ ticketUrl : '' ,
126+ notes : 'ycombinator' ,
127+ } ,
128+ } )
129+ ) ;
130+ } ) ;
131+ } ) ;
132+
133+ it ( 'shows custom notes field when "Enter custom notes" is selected' , async ( ) => {
134+ triggerAddToStartupProgramModal ( modalProps ) ;
135+
136+ renderGlobalModal ( ) ;
137+
138+ expect ( screen . queryByRole ( 'textbox' , { name : 'Custom Notes' } ) ) . not . toBeInTheDocument ( ) ;
139+
140+ await userEvent . click ( await screen . findByText ( 'sentryforstartups' ) ) ;
141+ await userEvent . click ( screen . getByText ( 'Enter custom notes' ) ) ;
142+
143+ expect ( screen . getByRole ( 'textbox' , { name : 'Custom Notes' } ) ) . toBeInTheDocument ( ) ;
144+ } ) ;
145+
146+ it ( 'hides custom notes field when switching back to a preset option' , async ( ) => {
147+ triggerAddToStartupProgramModal ( modalProps ) ;
148+
149+ renderGlobalModal ( ) ;
150+
151+ // Select "Enter custom notes"
152+ await userEvent . click ( await screen . findByText ( 'sentryforstartups' ) ) ;
153+ await userEvent . click ( screen . getByText ( 'Enter custom notes' ) ) ;
154+ expect ( screen . getByRole ( 'textbox' , { name : 'Custom Notes' } ) ) . toBeInTheDocument ( ) ;
155+
156+ // Switch back to a preset option
157+ await userEvent . click ( screen . getByText ( 'Enter custom notes' ) ) ;
158+ await userEvent . click ( screen . getByText ( 'a16z' ) ) ;
159+ expect ( screen . queryByRole ( 'textbox' , { name : 'Custom Notes' } ) ) . not . toBeInTheDocument ( ) ;
160+ } ) ;
161+
162+ it ( 'can submit with custom notes' , async ( ) => {
101163 const updateMock = MockApiClient . addMockResponse ( {
102164 url : `/_admin/customers/${ organization . slug } /balance-changes/` ,
103165 method : 'POST' ,
@@ -115,9 +177,13 @@ describe('AddToStartupProgramAction', () => {
115177
116178 await userEvent . type ( screen . getByRole ( 'textbox' , { name : 'Ticket URL' } ) , url ) ;
117179
118- const notesInput = screen . getByRole ( 'textbox' , { name : 'Notes' } ) ;
119- await userEvent . clear ( notesInput ) ;
120- await userEvent . type ( notesInput , 'custom note' ) ;
180+ await userEvent . click ( screen . getByText ( 'sentryforstartups' ) ) ;
181+ await userEvent . click ( screen . getByText ( 'Enter custom notes' ) ) ;
182+
183+ await userEvent . type (
184+ screen . getByRole ( 'textbox' , { name : 'Custom Notes' } ) ,
185+ 'custom note'
186+ ) ;
121187
122188 await userEvent . click ( screen . getByRole ( 'button' , { name : 'Submit' } ) ) ;
123189
@@ -156,7 +222,6 @@ describe('AddToStartupProgramAction', () => {
156222 expect ( submitButton ) . toBeDisabled ( ) ;
157223 expect ( screen . getByRole ( 'spinbutton' , { name : 'Credit Amount' } ) ) . toBeDisabled ( ) ;
158224 expect ( screen . getByRole ( 'textbox' , { name : 'Ticket URL' } ) ) . toBeDisabled ( ) ;
159- expect ( screen . getByRole ( 'textbox' , { name : 'Notes' } ) ) . toBeDisabled ( ) ;
160225 await waitForModalToHide ( ) ;
161226 } ) ;
162227
@@ -205,7 +270,6 @@ describe('AddToStartupProgramAction', () => {
205270 { timeout : 5_000 }
206271 ) ;
207272 expect ( screen . getByRole ( 'textbox' , { name : 'Ticket URL' } ) ) . toBeEnabled ( ) ;
208- expect ( screen . getByRole ( 'textbox' , { name : 'Notes' } ) ) . toBeEnabled ( ) ;
209273 expect ( screen . getByRole ( 'button' , { name : / s u b m i t / i} ) ) . toBeEnabled ( ) ;
210274 } , 25_000 ) ;
211275
0 commit comments