Skip to content

Commit 53cc217

Browse files
authored
feat(contractor-onboarding) - show eor when there are no subscriptions (#764)
* feat(contractor-onboarding) - show eor when there are no subscriptions * add test
1 parent 2dfb2d9 commit 53cc217

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

src/flows/ContractorOnboarding/api.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ export const useContractorSubscriptionSchemaField = (
389389
},
390390
});
391391

392+
const isEmptyContractorSubscriptions = contractorSubscriptions?.length === 0;
393+
392394
const isOnlyCORSubscription =
393395
contractorSubscriptions?.length === 1 &&
394396
contractorSubscriptions[0].product.short_name === 'COR';
@@ -401,7 +403,9 @@ export const useContractorSubscriptionSchemaField = (
401403
corSubscription?.eligibility_questionnaire?.is_blocking;
402404

403405
const showEorSubscription =
404-
(isOnlyCORSubscription || isEligibilityQuestionnaireBlocked === true) &&
406+
(isOnlyCORSubscription ||
407+
isEligibilityQuestionnaireBlocked === true ||
408+
isEmptyContractorSubscriptions) &&
405409
selectedCountry?.eor_onboarding;
406410

407411
const { eorSubscription, isLoading: isLoadingEorSubscription } =

src/flows/ContractorOnboarding/tests/ContractorOnboarding.test.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,6 +2286,47 @@ describe('ContractorOnboardingFlow', () => {
22862286
});
22872287
});
22882288

2289+
it('should show Employer of Record option when contractor subscriptions are empty', async () => {
2290+
server.use(
2291+
http.get(
2292+
'*/v1/contractors/employments/*/contractor-subscriptions',
2293+
() => {
2294+
return HttpResponse.json({
2295+
data: [],
2296+
});
2297+
},
2298+
),
2299+
);
2300+
2301+
mockRender.mockImplementation(
2302+
createMockRenderImplementation(MultiStepFormWithoutCountry),
2303+
);
2304+
2305+
render(
2306+
<ContractorOnboardingFlow
2307+
{...defaultProps}
2308+
countryCode='PRT'
2309+
skipSteps={['select_country']}
2310+
/>,
2311+
{ wrapper: TestProviders },
2312+
);
2313+
2314+
await screen.findByText(/Step: Basic Information/i);
2315+
await fillBasicInformation();
2316+
2317+
const nextButton = screen.getByText(/Next Step/i);
2318+
nextButton.click();
2319+
2320+
await screen.findByText(/Step: Pricing Plan/i);
2321+
2322+
await waitFor(() => {
2323+
const eorOption = screen.getByRole('radio', {
2324+
name: /Employer of Record/i,
2325+
});
2326+
expect(eorOption).toBeInTheDocument();
2327+
});
2328+
});
2329+
22892330
it('should NOT show Employer of Record option when eor_onboarding is false', async () => {
22902331
server.use(
22912332
http.get('*/v1/countries', () => {

0 commit comments

Comments
 (0)