@@ -43,6 +43,10 @@ const upgradeableRun: typeof makeCourseRun = (overrides) =>
4343 ...overrides ,
4444 } )
4545
46+ const getCourseSelect = ( ) => {
47+ return screen . getByRole ( "combobox" , { name : / c h o o s e a c o u r s e / i } )
48+ }
49+
4650describe ( "ProgramEnrollmentDialog" , ( ) => {
4751 setupLocationMock ( )
4852
@@ -93,7 +97,7 @@ describe("ProgramEnrollmentDialog", () => {
9397 renderWithProviders ( null )
9498 await openProgramDialog ( program )
9599
96- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
100+ const select = getCourseSelect ( )
97101 expect ( select ) . toHaveTextContent ( / p l e a s e s e l e c t / i)
98102 } )
99103
@@ -107,7 +111,7 @@ describe("ProgramEnrollmentDialog", () => {
107111 renderWithProviders ( null )
108112 await openProgramDialog ( program )
109113
110- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
114+ const select = getCourseSelect ( )
111115 await user . click ( select )
112116
113117 expect (
@@ -126,7 +130,7 @@ describe("ProgramEnrollmentDialog", () => {
126130 renderWithProviders ( null )
127131 await openProgramDialog ( program )
128132
129- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
133+ const select = getCourseSelect ( )
130134 await waitFor ( ( ) => {
131135 expect ( select ) . toHaveAttribute ( "aria-invalid" , "true" )
132136 } )
@@ -151,7 +155,7 @@ describe("ProgramEnrollmentDialog", () => {
151155 renderWithProviders ( null )
152156 await openProgramDialog ( program )
153157
154- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
158+ const select = getCourseSelect ( )
155159 await user . click ( select )
156160
157161 const options = screen . getAllByRole ( "option" )
@@ -172,7 +176,7 @@ describe("ProgramEnrollmentDialog", () => {
172176 renderWithProviders ( null )
173177 await openProgramDialog ( program )
174178
175- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
179+ const select = getCourseSelect ( )
176180 await user . click ( select )
177181
178182 expect (
@@ -194,7 +198,7 @@ describe("ProgramEnrollmentDialog", () => {
194198 renderWithProviders ( null )
195199 await openProgramDialog ( program )
196200
197- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
201+ const select = getCourseSelect ( )
198202 await user . click ( select )
199203
200204 screen . getByRole ( "option" , {
@@ -218,7 +222,7 @@ describe("ProgramEnrollmentDialog", () => {
218222 renderWithProviders ( null )
219223 await openProgramDialog ( program )
220224
221- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
225+ const select = getCourseSelect ( )
222226 await user . click ( select )
223227
224228 expect (
@@ -241,7 +245,7 @@ describe("ProgramEnrollmentDialog", () => {
241245 renderWithProviders ( null )
242246 await openProgramDialog ( program )
243247
244- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
248+ const select = getCourseSelect ( )
245249 await user . click ( select )
246250
247251 const option = screen . getByRole ( "option" , {
@@ -280,7 +284,7 @@ describe("ProgramEnrollmentDialog", () => {
280284 await openProgramDialog ( program )
281285
282286 // Select the course
283- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
287+ const select = getCourseSelect ( )
284288 await user . click ( select )
285289 const courseOption = screen . getByRole ( "option" , {
286290 name : / T e s t C o u r s e - 6 .0 0 5 / i,
@@ -316,7 +320,7 @@ describe("ProgramEnrollmentDialog", () => {
316320 await openProgramDialog ( program )
317321
318322 // Select the course
319- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
323+ const select = getCourseSelect ( )
320324 await user . click ( select )
321325 const courseOption = screen . getByRole ( "option" , {
322326 name : / A l g o r i t h m s - 6 .0 0 6 / i,
@@ -378,7 +382,7 @@ describe("ProgramEnrollmentDialog", () => {
378382 await openProgramDialog ( program )
379383
380384 // Try to select the course without runs
381- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
385+ const select = getCourseSelect ( )
382386 await user . click ( select )
383387 const courseOption = screen . getByRole ( "option" , {
384388 name : / N o a v a i l a b l e r u n s / i,
@@ -406,7 +410,7 @@ describe("ProgramEnrollmentDialog", () => {
406410 await openProgramDialog ( program )
407411
408412 // Select the course
409- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
413+ const select = getCourseSelect ( )
410414 await user . click ( select )
411415 const courseOption = screen . getByRole ( "option" , {
412416 name : / T e s t C o u r s e - 6 .0 0 7 / i,
@@ -451,7 +455,7 @@ describe("ProgramEnrollmentDialog", () => {
451455 await screen . findByRole ( "dialog" )
452456
453457 // Select the course
454- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
458+ const select = getCourseSelect ( )
455459 await user . click ( select )
456460 const courseOption = screen . getByRole ( "option" , {
457461 name : / A n o t h e r C o u r s e - 6 .0 0 8 / i,
@@ -495,7 +499,7 @@ describe("ProgramEnrollmentDialog", () => {
495499 await openProgramDialog ( program )
496500
497501 // Select the course
498- const select = screen . getByRole ( "combobox" , { name : / c h o o s e a d a t e / i } )
502+ const select = getCourseSelect ( )
499503 await user . click ( select )
500504 const courseOption = screen . getByRole ( "option" , {
501505 name : / E r r o r T e s t C o u r s e - 6 .0 0 9 / i,
0 commit comments