-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-2200] [Claims Process Update] Implement new claim intro page #772
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
Merged
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
63c0190
WIP UI
roman-stolar 4bd3447
fixes
roman-stolar 4191134
update layout and fonts
roman-stolar 56479f1
fix image layout
roman-stolar ee123e9
small fixes
roman-stolar 5c7150e
clean up
roman-stolar 10d33bd
Color and style update
roman-stolar 94bfe26
size
roman-stolar 58eb494
added auth required component
roman-stolar 6fa9d51
Fixed SonarQube issues
roman-stolar d724a89
fixed ES linter
roman-stolar 2f08539
added UI tests
roman-stolar 7e768e2
fixed ES Linter
roman-stolar 98da41a
added constants
roman-stolar 9b88ef6
updated release notes
roman-stolar fded321
Merge branch 'main' into OSDEV-2200-implement-claim-intro
roman-stolar 8de6632
small styles changes
roman-stolar 01a5e84
small fix
roman-stolar a63e307
small font size update
roman-stolar afb327c
adressed Vlad comments
roman-stolar 28361bc
addressed comments
roman-stolar 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
190 changes: 190 additions & 0 deletions
190
src/react/src/__tests__/components/ClaimInfoSection.test.js
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,190 @@ | ||
| import React from 'react'; | ||
| import { fireEvent, waitFor } from '@testing-library/react'; | ||
| import renderWithProviders from '../../util/testUtils/renderWithProviders'; | ||
| import ClaimInfoSection from '../../components/V1Claim/ClaimInfoSection'; | ||
|
|
||
| describe('ClaimInfoSection component', () => { | ||
| const renderComponent = () => renderWithProviders(<ClaimInfoSection />); | ||
|
|
||
| test('renders without crashing', () => { | ||
| renderComponent(); | ||
| }); | ||
|
|
||
| describe('Step 1 - Eligibility rendering', () => { | ||
| test('displays Step 1 title', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect(getByText('Confirm Your Eligibility')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('displays eligibility requirements', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect( | ||
| getByText(/Claim requests must be submitted by a current employee/) | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| getByText(/If you're not an owner or manager/) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Step 2 - Prove Your Name and Role rendering', () => { | ||
| test('displays Step 2 title', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect(getByText('Prove Your Name and Role')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('displays OPTIONS list', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect( | ||
| getByText(/Company website showing your name and role/) | ||
| ).toBeInTheDocument(); | ||
| expect(getByText(/Employee ID badge/)).toBeInTheDocument(); | ||
| expect(getByText(/Employment letter/)).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('displays employee examples for Step 2', () => { | ||
| const { getAllByAltText } = renderComponent(); | ||
|
|
||
| expect( | ||
| getAllByAltText('Example employee ID badge')[0] | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| getAllByAltText('Example employment letter')[0] | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| getAllByAltText('Example business card')[0] | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Step 3 - Prove Your Company Name and Address rendering', () => { | ||
| test('displays Step 3 title', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect( | ||
| getByText('Prove Your Company Name and Address') | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('displays company verification OPTIONS', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect(getByText(/Business registration/)).toBeInTheDocument(); | ||
| expect(getByText(/Business license/)).toBeInTheDocument(); | ||
| expect(getByText(/Utility bill/)).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('displays NOTE about company name and address', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect( | ||
| getByText(/The document must show the same company name and address/) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('displays company examples for Step 3', () => { | ||
| const { getAllByAltText } = renderComponent(); | ||
|
|
||
| expect( | ||
| getAllByAltText('Example business registration certificate')[0] | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| getAllByAltText('Example business license')[0] | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| getAllByAltText('Example utility bill')[0] | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Step 4 and 5 - Maximum Value section rendering', () => { | ||
| test('displays Maximum Value badge', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect(getByText('Maximum Value')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('displays Step 4 - Add Key Details', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect(getByText(/Add Key Details:/)).toBeInTheDocument(); | ||
| expect( | ||
| getByText(/Provide information about the production location/) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('displays Step 5 - Get Verified', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect(getByText(/Get Verified:/)).toBeInTheDocument(); | ||
| expect( | ||
| getByText(/After the claim is approved, you get a credible/) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Important Note rendering', () => { | ||
| test('displays important warning box', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect(getByText('IMPORTANT!')).toBeInTheDocument(); | ||
| expect( | ||
| getByText(/Any documentation appearing to be forged/) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('displays info icon in warning box', () => { | ||
| const { container } = renderComponent(); | ||
|
|
||
| const svgIcons = container.querySelectorAll('svg'); | ||
| expect(svgIcons.length).toBeGreaterThan(0); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Image Dialog functionality', () => { | ||
| test('opens dialog when example image is clicked', async () => { | ||
| const { getAllByAltText, getByRole } = renderComponent(); | ||
|
|
||
| const exampleImage = getAllByAltText('Example employee ID badge')[0]; | ||
| const imageButton = exampleImage.closest('button'); | ||
|
|
||
| fireEvent.click(imageButton); | ||
|
|
||
| await waitFor(() => { | ||
| const dialog = getByRole('dialog'); | ||
| expect(dialog).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| test('displays image in dialog when opened', async () => { | ||
| const { getAllByAltText } = renderComponent(); | ||
|
|
||
| const exampleImage = getAllByAltText('Example employee ID badge')[0]; | ||
| const imageButton = exampleImage.closest('button'); | ||
|
|
||
| fireEvent.click(imageButton); | ||
|
|
||
| await waitFor(() => { | ||
| const dialogImages = getAllByAltText('Example employee ID badge'); | ||
|
|
||
| expect(dialogImages.length).toBeGreaterThan(1); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('External link', () => { | ||
| test('displays learn more link', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| const link = getByText('Learn more about claiming your production location'); | ||
| expect(link).toBeInTheDocument(); | ||
| expect(link.tagName).toBe('A'); | ||
| expect(link).toHaveAttribute('href', 'https://info.opensupplyhub.org/resources/claim-a-facility'); | ||
| expect(link).toHaveAttribute('target', '_blank'); | ||
| }); | ||
| }); | ||
| }); |
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,125 @@ | ||
| import React from 'react'; | ||
| import { Router } from 'react-router-dom'; | ||
| import { fireEvent } from '@testing-library/react'; | ||
| import history from '../../util/history'; | ||
| import renderWithProviders from '../../util/testUtils/renderWithProviders'; | ||
| import ClaimIntro from '../../components/V1Claim/ClaimIntro'; | ||
| import { makeClaimDetailsLink } from '../../util/util'; | ||
|
|
||
| jest.mock('../../components/V1Claim/ClaimInfoSection', () => () => ( | ||
| <div data-testid="claim-info-section">ClaimInfoSection</div> | ||
| )); | ||
|
|
||
| describe('ClaimIntro component', () => { | ||
| const mockOsID = 'TEST123'; | ||
| const mockMatch = { | ||
| params: { osID: mockOsID }, | ||
| }; | ||
|
|
||
| const renderComponent = (userHasSignedIn = true) => { | ||
| const preloadedState = { | ||
| auth: { | ||
| user: { | ||
| user: { | ||
| isAnon: !userHasSignedIn, | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| return renderWithProviders( | ||
| <Router history={history}> | ||
| <ClaimIntro match={mockMatch} /> | ||
| </Router>, | ||
| { preloadedState } | ||
| ); | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| history.push('/'); | ||
| }); | ||
|
|
||
| describe('Authentication checks', () => { | ||
| test('renders RequireAuthNotice when user is not signed in', () => { | ||
| const { getByText } = renderComponent(false); | ||
|
|
||
| expect(getByText('Claim this production location')).toBeInTheDocument(); | ||
| expect( | ||
| getByText('Log in to claim a production location on Open Supply Hub') | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders main content when user is signed in', () => { | ||
| const { getByText, getByTestId } = renderComponent(true); | ||
|
|
||
| expect(getByText('Claim a Production Location')).toBeInTheDocument(); | ||
| expect(getByTestId('claim-info-section')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Component rendering', () => { | ||
| test('renders without crashing', () => { | ||
| renderComponent(); | ||
| }); | ||
|
|
||
| test('displays the correct title', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect(getByText('Claim a Production Location')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('displays the subtitle text', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect( | ||
| getByText(/In order to submit a claim request/) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders both action buttons', () => { | ||
| const { getByText } = renderComponent(); | ||
|
|
||
| expect(getByText('GO BACK')).toBeInTheDocument(); | ||
| expect(getByText('Continue to Claim Form')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders ClaimInfoSection component', () => { | ||
| const { getByTestId } = renderComponent(); | ||
|
|
||
| expect(getByTestId('claim-info-section')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Navigation functionality', () => { | ||
| test('navigates back when GO BACK button is clicked', () => { | ||
| history.push('/some-page'); | ||
| const previousPath = history.location.pathname; | ||
|
|
||
| const { getByText } = renderComponent(); | ||
| const backButton = getByText('GO BACK'); | ||
|
|
||
| fireEvent.click(backButton); | ||
|
|
||
| expect(history.location.pathname).toBe(previousPath); | ||
| }); | ||
roman-stolar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test('navigates to claim details when Continue button is clicked', () => { | ||
| const { getByText } = renderComponent(); | ||
| const continueButton = getByText('Continue to Claim Form'); | ||
|
|
||
| fireEvent.click(continueButton); | ||
|
|
||
| const expectedPath = makeClaimDetailsLink(mockOsID); | ||
| expect(history.location.pathname).toBe(expectedPath); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Props validation', () => { | ||
| test('receives osID from route params', () => { | ||
| const { container } = renderComponent(); | ||
|
|
||
| expect(container.firstChild).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
| }); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.