@@ -57,14 +57,14 @@ describe('AddToStartupProgramAction', () => {
5757 expect ( await screen . findByTestId ( 'balance' ) ) . toHaveTextContent ( '$30.00 owed' ) ;
5858 } ) ;
5959
60- it ( 'has default values for credit amount and notes ' , async ( ) => {
60+ it ( 'has default values for credit amount and program ' , async ( ) => {
6161 triggerAddToStartupProgramModal ( modalProps ) ;
6262
6363 renderGlobalModal ( ) ;
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 ( 'Sentry for Startups' ) ) . toBeInTheDocument ( ) ;
6868 } ) ;
6969
7070 it ( 'can submit with default values' , async ( ) => {
@@ -97,7 +97,57 @@ describe('AddToStartupProgramAction', () => {
9797 expect ( onSuccess ) . toHaveBeenCalled ( ) ;
9898 } ) ;
9999
100- it ( 'can submit with custom values' , async ( ) => {
100+ it ( 'can submit with a different program 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+ // Change the program dropdown
112+ await userEvent . click ( await screen . findByText ( 'Sentry for Startups' ) ) ;
113+ await userEvent . click ( screen . getByText ( 'Y Combinator' ) ) ;
114+
115+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Submit' } ) ) ;
116+
117+ await waitForModalToHide ( ) ;
118+
119+ await waitFor ( ( ) => {
120+ expect ( updateMock ) . toHaveBeenCalledWith (
121+ `/_admin/customers/${ organization . slug } /balance-changes/` ,
122+ expect . objectContaining ( {
123+ method : 'POST' ,
124+ data : {
125+ creditAmount : 500000 ,
126+ ticketUrl : '' ,
127+ notes : 'ycombinator' ,
128+ } ,
129+ } )
130+ ) ;
131+ } ) ;
132+ } ) ;
133+
134+ it ( 'shows custom notes field when "Other" is selected' , async ( ) => {
135+ triggerAddToStartupProgramModal ( modalProps ) ;
136+
137+ renderGlobalModal ( ) ;
138+
139+ // Custom notes should not be visible initially
140+ expect ( screen . queryByRole ( 'textbox' , { name : 'Custom Notes' } ) ) . not . toBeInTheDocument ( ) ;
141+
142+ // Select "Other"
143+ await userEvent . click ( await screen . findByText ( 'Sentry for Startups' ) ) ;
144+ await userEvent . click ( screen . getByText ( 'Other' ) ) ;
145+
146+ // Custom notes field should now be visible
147+ expect ( screen . getByRole ( 'textbox' , { name : 'Custom Notes' } ) ) . toBeInTheDocument ( ) ;
148+ } ) ;
149+
150+ it ( 'can submit with custom notes when "Other" is selected' , async ( ) => {
101151 const updateMock = MockApiClient . addMockResponse ( {
102152 url : `/_admin/customers/${ organization . slug } /balance-changes/` ,
103153 method : 'POST' ,
@@ -115,9 +165,14 @@ describe('AddToStartupProgramAction', () => {
115165
116166 await userEvent . type ( screen . getByRole ( 'textbox' , { name : 'Ticket URL' } ) , url ) ;
117167
118- const notesInput = screen . getByRole ( 'textbox' , { name : 'Notes' } ) ;
119- await userEvent . clear ( notesInput ) ;
120- await userEvent . type ( notesInput , 'custom note' ) ;
168+ // Select "Other" to show custom notes
169+ await userEvent . click ( screen . getByText ( 'Sentry for Startups' ) ) ;
170+ await userEvent . click ( screen . getByText ( 'Other' ) ) ;
171+
172+ await userEvent . type (
173+ screen . getByRole ( 'textbox' , { name : 'Custom Notes' } ) ,
174+ 'custom note'
175+ ) ;
121176
122177 await userEvent . click ( screen . getByRole ( 'button' , { name : 'Submit' } ) ) ;
123178
@@ -156,7 +211,6 @@ describe('AddToStartupProgramAction', () => {
156211 expect ( submitButton ) . toBeDisabled ( ) ;
157212 expect ( screen . getByRole ( 'spinbutton' , { name : 'Credit Amount' } ) ) . toBeDisabled ( ) ;
158213 expect ( screen . getByRole ( 'textbox' , { name : 'Ticket URL' } ) ) . toBeDisabled ( ) ;
159- expect ( screen . getByRole ( 'textbox' , { name : 'Notes' } ) ) . toBeDisabled ( ) ;
160214 await waitForModalToHide ( ) ;
161215 } ) ;
162216
@@ -205,7 +259,6 @@ describe('AddToStartupProgramAction', () => {
205259 { timeout : 5_000 }
206260 ) ;
207261 expect ( screen . getByRole ( 'textbox' , { name : 'Ticket URL' } ) ) . toBeEnabled ( ) ;
208- expect ( screen . getByRole ( 'textbox' , { name : 'Notes' } ) ) . toBeEnabled ( ) ;
209262 expect ( screen . getByRole ( 'button' , { name : / s u b m i t / i} ) ) . toBeEnabled ( ) ;
210263 } , 25_000 ) ;
211264
0 commit comments