-
Notifications
You must be signed in to change notification settings - Fork 4
feat: require cancelling self-onboarding before editing a contractor #2407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
serikjensen
merged 5 commits into
main
from
feat/contractor-list-gate-edit-during-self-onboarding
Jul 15, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e06dc1a
feat: require cancelling self-onboarding before editing a contractor
serikjensen c64fa54
feat: hide W-9 instructions when contractor has signed W-9
serikjensen 9f109c9
fix: correct API response mocks in Submit component tests
cursoragent e7abba6
fix: update E2E test to use 'Open menu' button label
cursoragent d30fd5d
Merge branch 'main' into feat/contractor-list-gate-edit-during-self-o…
serikjensen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| import { describe, test, expect, vi } from 'vitest' | ||
| import { screen } from '@testing-library/react' | ||
| import { HttpResponse } from 'msw' | ||
| import { ContractorSubmit } from './Submit' | ||
| import { server } from '@/test/mocks/server' | ||
| import { handleGetContractor } from '@/test/mocks/apis/contractors' | ||
| import { handleGetContractorOnboardingStatus } from '@/test/mocks/apis/contractors' | ||
| import { handleGetContractorDocuments } from '@/test/mocks/apis/contractors' | ||
| import { handleGetContractorDocumentPdf } from '@/test/mocks/apis/contractor_documents' | ||
| import { renderWithProviders } from '@/test-utils/renderWithProviders' | ||
|
|
||
| describe('ContractorSubmit', () => { | ||
| const mockOnEvent = vi.fn() | ||
|
|
||
| test('hides documents section when contractor has signed W-9', () => { | ||
| server.use( | ||
| handleGetContractor(() => | ||
| HttpResponse.json({ | ||
| uuid: 'contractor-uuid', | ||
| type: 'Individual', | ||
| first_name: 'Test', | ||
| last_name: 'Contractor', | ||
| }), | ||
| ), | ||
| handleGetContractorOnboardingStatus(() => | ||
| HttpResponse.json({ | ||
| uuid: 'status-uuid', | ||
| onboarding_status: 'admin_onboarding_review', | ||
| onboarding_steps: [], | ||
| }), | ||
| ), | ||
| handleGetContractorDocuments(() => | ||
| HttpResponse.json([ | ||
| { | ||
| uuid: 'doc-uuid', | ||
| name: 'taxpayer_identification_form_w_9', | ||
| requires_signing: true, | ||
| signed_at: '2025-01-15T12:00:00Z', | ||
| }, | ||
| ]), | ||
| ), | ||
| ) | ||
|
|
||
| renderWithProviders(<ContractorSubmit contractorId="contractor-uuid" onEvent={mockOnEvent} />) | ||
|
|
||
| // Documents section should NOT render when W-9 is signed | ||
| expect(screen.queryByText('Documents')).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| test('shows documents section when contractor has not signed W-9', async () => { | ||
| server.use( | ||
| handleGetContractor(() => | ||
| HttpResponse.json({ | ||
| uuid: 'contractor-uuid', | ||
| type: 'Individual', | ||
| first_name: 'Test', | ||
| last_name: 'Contractor', | ||
| }), | ||
| ), | ||
| handleGetContractorOnboardingStatus(() => | ||
| HttpResponse.json({ | ||
| uuid: 'status-uuid', | ||
| onboarding_status: 'admin_onboarding_review', | ||
| onboarding_steps: [], | ||
| }), | ||
| ), | ||
| handleGetContractorDocuments(() => | ||
| HttpResponse.json([ | ||
| { | ||
| uuid: 'doc-uuid', | ||
| name: 'taxpayer_identification_form_w_9', | ||
| requires_signing: true, | ||
| signed_at: null, | ||
| }, | ||
| ]), | ||
| ), | ||
| handleGetContractorDocumentPdf(() => | ||
| HttpResponse.json({ | ||
| uuid: 'doc-uuid', | ||
| document_url: 'https://example.com/w9.pdf', | ||
| }), | ||
| ), | ||
| ) | ||
|
|
||
| renderWithProviders(<ContractorSubmit contractorId="contractor-uuid" onEvent={mockOnEvent} />) | ||
|
|
||
| // Documents section SHOULD render when W-9 is not signed | ||
| expect(await screen.findByText('Documents')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| test('hides documents section when there are no documents to collect', () => { | ||
| server.use( | ||
| handleGetContractor(() => | ||
| HttpResponse.json({ | ||
| uuid: 'contractor-uuid', | ||
| type: 'Individual', | ||
| first_name: 'Test', | ||
| last_name: 'Contractor', | ||
| }), | ||
| ), | ||
| handleGetContractorOnboardingStatus(() => | ||
| HttpResponse.json({ | ||
| uuid: 'status-uuid', | ||
| onboarding_status: 'admin_onboarding_review', | ||
| onboarding_steps: [], | ||
| }), | ||
| ), | ||
| handleGetContractorDocuments(() => HttpResponse.json([])), | ||
| ) | ||
|
|
||
| renderWithProviders(<ContractorSubmit contractorId="contractor-uuid" onEvent={mockOnEvent} />) | ||
|
|
||
| // No documents section when there are no documents to collect | ||
| expect(screen.queryByText('Documents')).not.toBeInTheDocument() | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/components/Contractor/shared/useContractorHasSignedW9.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { useContractorDocumentsGetAllSuspense } from '@gusto/embedded-api/react-query/contractorDocumentsGetAll' | ||
| import { isW9Document } from '@/components/Contractor/Documents/SignatureForm/useContractorSignatureForm' | ||
|
|
||
| /** | ||
| * Returns `true` when the contractor has a W-9 with a `signedAt` timestamp on | ||
| * file. Fetches via Suspense — must be rendered inside a Suspense boundary | ||
| * (SDK `BaseBoundaries` supplies one). | ||
| * | ||
| * @internal | ||
| */ | ||
| export function useContractorHasSignedW9(contractorId: string): boolean { | ||
| const { data } = useContractorDocumentsGetAllSuspense({ contractorUuid: contractorId }) | ||
| return (data.documents ?? []).some(doc => isW9Document(doc) && !!doc.signedAt) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this is an abstraction that we're using in this PR #2394 whoever merges first will rebase and get it.