-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-2374] Implement claim banner with status and cta support #890
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
VadimKovalenkoSNF
merged 28 commits into
main
from
OSDEV-2374-implement-claim-banner-with-status-and-CTA-support
Mar 3, 2026
Merged
Changes from 12 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
eeca1f1
Add basic classes for ClaimFlag (partial impl)
VadimKovalenkoSNF c83b677
Optimize class assigment
VadimKovalenkoSNF fb4d282
Minor style refactoring
VadimKovalenkoSNF b32a24c
Dialog tooltip optimization
VadimKovalenkoSNF b738170
Pass embed config flag (secure measure)
VadimKovalenkoSNF ee87028
Clear timeout for TooltipDialog popup
VadimKovalenkoSNF 6304eab
Clear timeout for DialogTooltip popup, adjust user accessibility
VadimKovalenkoSNF 5e3984d
Connect closure status badge
VadimKovalenkoSNF e2a475e
Guard React.cloneElement against non-element children in interactive …
VadimKovalenkoSNF af374f6
Add unit tests
VadimKovalenkoSNF 1b60b17
Fix lint issues
VadimKovalenkoSNF e07a9ed
Add proptypes to the closure report component, fix minor issues
VadimKovalenkoSNF 5be8398
Fix unit test
VadimKovalenkoSNF a8ddc91
Merge branch 'main' into OSDEV-2374-implement-claim-banner-with-statu…
VadimKovalenkoSNF 3234ffe
Merge branch 'main' into OSDEV-2374-implement-claim-banner-with-statu…
VadimKovalenkoSNF 31761c9
Fix post-merge errors
VadimKovalenkoSNF 249ba92
Refactor DialogTooltip to pass href as a separate component
VadimKovalenkoSNF ee7fda9
Refactor DialogTooltip keyboard navigation
VadimKovalenkoSNF bfc273e
Refactor ClaimFlag util functions
VadimKovalenkoSNF 84f9d9b
Split ClaimFlag into smaller inner components
VadimKovalenkoSNF 5ecf343
Fix lint issues
VadimKovalenkoSNF 0e6a972
Introduce InteractiveTrigger component
VadimKovalenkoSNF 740ea07
Arrow function for redux methods, upd release notes
VadimKovalenkoSNF b239ca7
Move InteractiveTrigger into the separate file
VadimKovalenkoSNF 71f8be8
Fix lint issues
VadimKovalenkoSNF 34d46ea
Fix lint issues with long string
VadimKovalenkoSNF c4645f1
Update claim badge tooltip text
VadimKovalenkoSNF 9b8ad7d
Increase font size for the inlineHighlight class
VadimKovalenkoSNF 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
118 changes: 118 additions & 0 deletions
118
src/react/src/__tests__/components/ProductionLocationClaimFlag.test.jsx
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,118 @@ | ||
| import React from 'react'; | ||
| import { BrowserRouter as Router } from 'react-router-dom'; | ||
| import { screen } from '@testing-library/react'; | ||
| import renderWithProviders from '../../util/testUtils/renderWithProviders'; | ||
| import ProductionLocationClaimFlag from '../../components/ProductionLocation/Heading/ClaimFlag/ClaimFlag'; | ||
|
|
||
| describe('ProductionLocation ClaimFlag', () => { | ||
| const defaultProps = { | ||
| osId: 'US202510850SQCV', | ||
| isClaimed: false, | ||
| isPending: false, | ||
| isEmbed: false, | ||
| }; | ||
|
|
||
| test('renders without crashing', () => { | ||
| renderWithProviders( | ||
| <Router> | ||
| <ProductionLocationClaimFlag | ||
| {...defaultProps} | ||
| isClaimed | ||
| /> | ||
| </Router>, | ||
| ); | ||
|
|
||
| const banner = screen.getByTestId('claim-banner'); | ||
| expect(banner).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('shows CLAIMED PROFILE when claimed', () => { | ||
| renderWithProviders( | ||
| <Router> | ||
| <ProductionLocationClaimFlag | ||
| {...defaultProps} | ||
| isClaimed | ||
| /> | ||
| </Router>, | ||
| ); | ||
|
|
||
| const banner = screen.getByTestId('claim-banner'); | ||
| expect(banner).toHaveTextContent('CLAIMED PROFILE'); | ||
| }); | ||
|
|
||
| test('shows unclaimed message when not claimed', () => { | ||
| renderWithProviders( | ||
| <Router> | ||
| <ProductionLocationClaimFlag {...defaultProps} /> | ||
| </Router>, | ||
| ); | ||
|
|
||
| const banner = screen.getByTestId('claim-banner'); | ||
| expect(banner).toHaveTextContent( | ||
| 'This production location has not been claimed', | ||
| ); | ||
| }); | ||
|
|
||
| test('shows claim link when not claimed and not pending', () => { | ||
| renderWithProviders( | ||
| <Router> | ||
| <ProductionLocationClaimFlag {...defaultProps} /> | ||
| </Router>, | ||
| ); | ||
|
|
||
| const link = screen.getByRole('link', { | ||
| name: /I want to claim this production location/i, | ||
| }); | ||
| expect(link).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('shows pending claim message when pending', () => { | ||
| renderWithProviders( | ||
| <Router> | ||
| <ProductionLocationClaimFlag | ||
| {...defaultProps} | ||
| isPending | ||
| /> | ||
| </Router>, | ||
| ); | ||
|
|
||
| const banner = screen.getByTestId('claim-banner'); | ||
| expect(banner).toHaveTextContent( | ||
| 'There is a pending claim for this production location', | ||
| ); | ||
| }); | ||
|
|
||
| test('returns null when embed is true', () => { | ||
| renderWithProviders( | ||
| <Router> | ||
| <ProductionLocationClaimFlag | ||
| {...defaultProps} | ||
| isEmbed | ||
| /> | ||
| </Router>, | ||
| ); | ||
|
|
||
| const banner = screen.queryByTestId('claim-banner'); | ||
| expect(banner).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('shows claimed-by line when claimed with contributor and date', () => { | ||
| const claimInfo = { | ||
| contributor: { name: 'Acme Corp' }, | ||
| approved_at: '2023-06-15T12:00:00Z', | ||
| }; | ||
|
|
||
| renderWithProviders( | ||
| <Router> | ||
| <ProductionLocationClaimFlag | ||
| {...defaultProps} | ||
| isClaimed | ||
| claimInfo={claimInfo} | ||
| /> | ||
| </Router>, | ||
| ); | ||
|
|
||
| expect(screen.getByText(/Claimed by/)).toBeInTheDocument(); | ||
| expect(screen.getByText(/Acme Corp/)).toBeInTheDocument(); | ||
| }); | ||
| }); |
121 changes: 121 additions & 0 deletions
121
src/react/src/__tests__/components/ProductionLocationClosureStatus.test.jsx
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,121 @@ | ||
| import React from 'react'; | ||
| import { BrowserRouter as Router } from 'react-router-dom'; | ||
| import { screen } from '@testing-library/react'; | ||
| import PropTypes from 'prop-types'; | ||
| import renderWithProviders from '../../util/testUtils/renderWithProviders'; | ||
| import ClosureStatus from '../../components/ProductionLocation/Heading/ClosureStatus/ClosureStatus'; | ||
|
|
||
| jest.mock('../../components/FeatureFlag', () => { | ||
| const MockFeatureFlag = ({ children }) => <>{children}</>; | ||
| MockFeatureFlag.propTypes = { children: PropTypes.node }; | ||
| MockFeatureFlag.defaultProps = { children: null }; | ||
| return MockFeatureFlag; | ||
| }); | ||
|
|
||
| describe('ProductionLocation ClosureStatus', () => { | ||
| const clearFacility = jest.fn(); | ||
|
|
||
| afterEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| test('returns null when there is no activity report', () => { | ||
| const data = { | ||
| properties: {}, | ||
| }; | ||
|
|
||
| renderWithProviders( | ||
| <Router> | ||
| <ClosureStatus data={data} clearFacility={clearFacility} /> | ||
| </Router>, | ||
| ); | ||
|
|
||
| expect(screen.queryByText('Status pending')).not.toBeInTheDocument(); | ||
| expect( | ||
| screen.queryByText(/This facility may be/), | ||
| ).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('returns null when report exists but not pending and not closed', () => { | ||
| const data = { | ||
| properties: { | ||
| activity_reports: [{ status: 'RESOLVED' }], | ||
| is_closed: false, | ||
| }, | ||
| }; | ||
|
|
||
| renderWithProviders( | ||
| <Router> | ||
| <ClosureStatus data={data} clearFacility={clearFacility} /> | ||
| </Router>, | ||
| ); | ||
|
|
||
| expect(screen.queryByText('Status pending')).not.toBeInTheDocument(); | ||
| expect( | ||
| screen.queryByText(/This facility is closed/), | ||
| ).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders pending message when report status is PENDING', () => { | ||
| const data = { | ||
| properties: { | ||
| activity_reports: [ | ||
| { status: 'PENDING', closure_state: 'closed' }, | ||
| ], | ||
| is_closed: false, | ||
| }, | ||
| }; | ||
|
|
||
| renderWithProviders( | ||
| <Router> | ||
| <ClosureStatus data={data} clearFacility={clearFacility} /> | ||
| </Router>, | ||
| ); | ||
|
|
||
| expect( | ||
| screen.getByText(/This facility may be closed\./), | ||
| ).toBeInTheDocument(); | ||
| expect(screen.getByText('Status pending')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders closed message when facility is closed and no new OS ID', () => { | ||
| const data = { | ||
| properties: { | ||
| activity_reports: [{ status: 'RESOLVED' }], | ||
| is_closed: true, | ||
| }, | ||
| }; | ||
|
|
||
| renderWithProviders( | ||
| <Router> | ||
| <ClosureStatus data={data} clearFacility={clearFacility} /> | ||
| </Router>, | ||
| ); | ||
|
|
||
| expect( | ||
| screen.getByText(/This facility is closed\./), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders moved-to link when closed with new_os_id', () => { | ||
| const data = { | ||
| properties: { | ||
| activity_reports: [{ status: 'RESOLVED' }], | ||
| is_closed: true, | ||
| new_os_id: 'US2025123456ABCD', | ||
| }, | ||
| }; | ||
|
|
||
| renderWithProviders( | ||
| <Router> | ||
| <ClosureStatus data={data} clearFacility={clearFacility} /> | ||
| </Router>, | ||
| ); | ||
|
|
||
| const link = screen.getByRole('link', { name: 'US2025123456ABCD' }); | ||
| expect(link).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByText(/This facility has moved to/), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.