@@ -1946,5 +1946,106 @@ describe('ContractorOnboardingFlow', () => {
19461946 expect ( fileDisplay ) . toBeInTheDocument ( ) ;
19471947 } ) ;
19481948 } ) ;
1949+
1950+ it ( 'should not call uploadFileMutationAsync when ir35 status is exempt' , async ( ) => {
1951+ const postSpy = vi . fn ( ) ;
1952+ const contractDocumentSpy = vi . fn ( ) ;
1953+ const uploadSpy = vi . fn ( ) ;
1954+
1955+ server . use (
1956+ http . post ( '*/v1/employments' , async ( { request } ) => {
1957+ const requestBody = await request . json ( ) ;
1958+ postSpy ( requestBody ) ;
1959+ return HttpResponse . json ( mockContractorEmploymentResponse ) ;
1960+ } ) ,
1961+ http . post (
1962+ '*/v1/contractors/employments/*/contract-documents' ,
1963+ async ( { request } ) => {
1964+ const requestBody = await request . json ( ) ;
1965+ contractDocumentSpy ( requestBody ) ;
1966+ return HttpResponse . json ( mockContractDocumentCreatedResponse ) ;
1967+ } ,
1968+ ) ,
1969+ http . post ( '*/v1/documents' , async ( ) => {
1970+ uploadSpy ( ) ;
1971+ return HttpResponse . json ( {
1972+ data : {
1973+ file : {
1974+ id : 'ad8a15a5-88a5-4fb6-9225-2c4ec3e9a809' ,
1975+ name : 'test-file.pdf' ,
1976+ type : 'other' ,
1977+ inserted_at : '2026-01-16T15:33:28Z' ,
1978+ } ,
1979+ } ,
1980+ } ) ;
1981+ } ) ,
1982+ ) ;
1983+
1984+ mockRender . mockImplementation (
1985+ ( {
1986+ contractorOnboardingBag,
1987+ components,
1988+ } : ContractorOnboardingRenderProps ) => {
1989+ const currentStepIndex =
1990+ contractorOnboardingBag . stepState . currentStep . index ;
1991+
1992+ const steps : Record < number , string > = {
1993+ [ 0 ] : 'Basic Information' ,
1994+ [ 1 ] : 'Pricing Plan' ,
1995+ [ 2 ] : 'Contract Details' ,
1996+ [ 3 ] : 'Contract Preview' ,
1997+ [ 4 ] : 'Review' ,
1998+ } ;
1999+
2000+ return (
2001+ < >
2002+ < h1 > Step: { steps [ currentStepIndex ] } </ h1 >
2003+ < MultiStepFormWithoutCountry
2004+ contractorOnboardingBag = { contractorOnboardingBag }
2005+ components = { components }
2006+ />
2007+ </ >
2008+ ) ;
2009+ } ,
2010+ ) ;
2011+
2012+ render (
2013+ < ContractorOnboardingFlow
2014+ countryCode = 'GBR'
2015+ skipSteps = { [ 'select_country' ] }
2016+ { ...defaultProps }
2017+ /> ,
2018+ { wrapper : TestProviders } ,
2019+ ) ;
2020+
2021+ await screen . findByText ( / S t e p : B a s i c I n f o r m a t i o n / i) ;
2022+ await waitForElementToBeRemoved ( ( ) => screen . getByTestId ( 'spinner' ) ) ;
2023+
2024+ // Fill basic information
2025+ await fillBasicInformation ( ) ;
2026+
2027+ // Select IR35 status as 'exempt' (no file upload required)
2028+ const ir35Select = screen . getByLabelText ( / I R 3 5 S t a t u s / i) ;
2029+ fireEvent . change ( ir35Select , { target : { value : 'exempt' } } ) ;
2030+
2031+ // Verify file upload field does NOT appear
2032+ await waitFor ( ( ) => {
2033+ const fileUploadField = screen . queryByLabelText ( / U p l o a d S D S / i) ;
2034+ expect ( fileUploadField ) . not . toBeInTheDocument ( ) ;
2035+ } ) ;
2036+
2037+ const nextButton = screen . getByText ( / N e x t S t e p / i) ;
2038+ nextButton . click ( ) ;
2039+
2040+ await waitFor ( ( ) => {
2041+ // Verify contract document was created with exempt status
2042+ expect ( contractDocumentSpy ) . toHaveBeenCalled ( ) ;
2043+
2044+ // Verify file upload was NOT called
2045+ expect ( uploadSpy ) . not . toHaveBeenCalled ( ) ;
2046+ } ) ;
2047+
2048+ await screen . findByText ( / S t e p : P r i c i n g P l a n / i) ;
2049+ } ) ;
19492050 } ) ;
19502051} ) ;
0 commit comments