@@ -5,6 +5,7 @@ import { mockUser } from 'test-utils/mockGenerators/mockUser';
55import { describe , expect , it } from 'vitest' ;
66import MockAdapter from 'axios-mock-adapter' ;
77import axios from 'axios' ;
8+ import { REGISTRATION_FORM_INITIAL_SUBMIT_BUTTON } from 'common/constants/testIDs' ;
89import { RegistrationForm } from '../RegistrationForm' ;
910
1011const axiosMock = new MockAdapter ( axios ) ;
@@ -22,11 +23,11 @@ describe('RegistrationForm', () => {
2223 const successSpy = vi . fn ( ) ;
2324 const submitSpy = vi . fn ( ) ;
2425
25- const { getByText } = render (
26+ const { getByTestId } = render (
2627 < RegistrationForm onSubmit = { submitSpy } onSuccess = { successSpy } initialValues = { user } /> ,
2728 ) ;
2829
29- fireEvent . click ( getByText ( 'Submit' ) ) ;
30+ fireEvent . click ( getByTestId ( REGISTRATION_FORM_INITIAL_SUBMIT_BUTTON ) ) ;
3031
3132 await waitFor ( ( ) => {
3233 expect ( submitSpy ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -40,13 +41,13 @@ describe('RegistrationForm', () => {
4041 axiosMock . onPost ( '/api/registration/new' , user ) . reply ( 200 ) ;
4142
4243 const successSpy = vi . fn ( ( ) => Promise . resolve ( true ) ) ;
43- const { container, getByText , findByText } = render (
44+ const { container, getByTestId , findByTestId } = render (
4445 < RegistrationForm onSuccess = { successSpy } initialValues = { user } /> ,
4546 ) ;
4647
47- fireEvent . click ( getByText ( 'Submit' ) ) ;
48+ fireEvent . click ( getByTestId ( REGISTRATION_FORM_INITIAL_SUBMIT_BUTTON ) ) ;
4849
49- const submit = await findByText ( 'Submit' ) ;
50+ const submit = await findByTestId ( REGISTRATION_FORM_INITIAL_SUBMIT_BUTTON ) ;
5051 expect ( submit ) . not . toBeDisabled ( ) ;
5152 container . querySelectorAll ( 'input' ) . forEach ( input => {
5253 expect ( input . textContent ) . toBeFalsy ( ) ;
@@ -64,7 +65,7 @@ describe('RegistrationForm', () => {
6465
6566 // No Alert on mount
6667 expect ( screen . queryByRole ( 'alert' ) ) . not . toBeInTheDocument ( ) ;
67- fireEvent . click ( screen . getByText ( 'Submit' ) ) ;
68+ fireEvent . click ( screen . getByTestId ( REGISTRATION_FORM_INITIAL_SUBMIT_BUTTON ) ) ;
6869
6970 // Alert shown after submitting
7071 await waitFor ( ( ) => expect ( submitSpy ) . toHaveBeenCalledTimes ( 1 ) ) ;
0 commit comments