-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-2371] Implemented "General Information" section with contribution hierarchy logic #911
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
Open
vlad-shapik
wants to merge
11
commits into
main
Choose a base branch
from
OSDEV-2371-implement-general-information-section-with-contribution-hierarchy-logic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
96bf7ec
Simplify ProductionLocation general fields and sidebar nav
vlad-shapik 3d0db44
Production location: drawer UX, aligned name logic, shared utils, sta…
vlad-shapik 21a497e
Drawer: show ISIC 4 and array values as stacked blocks, not one string
vlad-shapik 7567c6a
Production location: General fields and utils updates
vlad-shapik 6396ba1
Fix MR conflict
vlad-shapik d9ddd3a
refactor(ProductionLocation): shared drawer state, utils, and DataPoi…
vlad-shapik 0a70145
Merge branch 'main' into OSDEV-2371-implement-general-information-sec…
vlad-shapik e913b4e
chore(ProductionLocation): update constants, Map and GeneralFields utils
vlad-shapik bf4c5b1
test(ProductionLocation): add GeneralFields and getVisibleFields tests
vlad-shapik 4bf5d64
OSDEV-2371: Add release note for General Information section (2.20.0 …
vlad-shapik a1d84c0
Normalize source names with trim before deduplication in getContribut…
vlad-shapik 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
155 changes: 155 additions & 0 deletions
155
src/react/src/__tests__/components/ProductionLocationDetailsGeneralFields.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,155 @@ | ||
| import React from 'react'; | ||
| import { MemoryRouter } from 'react-router-dom'; | ||
| import { screen, within } from '@testing-library/react'; | ||
| import renderWithProviders from '../../util/testUtils/renderWithProviders'; | ||
| import ProductionLocationDetailsGeneralFields from '../../components/ProductionLocation/ProductionLocationDetailsGeneralFields/ProductionLocationDetailsGeneralFields'; | ||
|
|
||
| describe('ProductionLocationDetailsGeneralFields component', () => { | ||
| const mockDataWithVisibleFields = { | ||
| id: 'XX2025000000000', | ||
| type: 'Feature', | ||
| geometry: { type: 'Point', coordinates: [0, 0] }, | ||
| properties: { | ||
| name: 'Test Facility Name', | ||
| country_code: 'XX', | ||
| os_id: 'XX2025000000000', | ||
| other_names: [], | ||
| contributors: [], | ||
| country_name: 'Test Country', | ||
| claim_info: null, | ||
| other_locations: [], | ||
| is_closed: false, | ||
| activity_reports: [], | ||
| contributor_fields: [], | ||
| new_os_id: null, | ||
| has_inexact_coordinates: false, | ||
| extended_fields: { | ||
| name: [ | ||
| { | ||
| value: 'Test Facility Name', | ||
| field_name: 'name', | ||
| contributor_id: 1, | ||
| contributor_name: 'Test Contributor', | ||
| updated_at: '2025-01-01T00:00:00.000Z', | ||
| created_at: '2025-01-01T00:00:00.000Z', | ||
| }, | ||
| ], | ||
| address: [], | ||
| number_of_workers: [], | ||
| native_language_name: [], | ||
| facility_type: [], | ||
| processing_type: [], | ||
| product_type: [], | ||
| parent_company: [], | ||
| parent_company_os_id: [], | ||
| duns_id: [], | ||
| lei_id: [], | ||
| rba_id: [], | ||
| isic_4: [], | ||
| }, | ||
| created_from: { | ||
| created_at: '2025-01-01T00:00:00.000Z', | ||
| contributor: 'Test Contributor', | ||
| }, | ||
| sector: [ | ||
| { | ||
| updated_at: '2025-01-01T00:00:00.000Z', | ||
| contributor_id: 1, | ||
| contributor_name: 'Test Contributor', | ||
| values: ['Apparel'], | ||
| is_from_claim: false, | ||
| created_at: '2025-01-01T00:00:00.000Z', | ||
| }, | ||
| { | ||
| updated_at: '2025-01-02T00:00:00.000Z', | ||
| contributor_id: 2, | ||
| contributor_name: 'Other Contributor', | ||
| values: ['Apparel'], | ||
| is_from_claim: false, | ||
| created_at: '2025-01-02T00:00:00.000Z', | ||
| }, | ||
| ], | ||
| is_claimed: false, | ||
| }, | ||
| }; | ||
|
|
||
| const defaultPreloadedState = { | ||
| featureFlags: { | ||
| fetching: false, | ||
| flags: {}, | ||
| }, | ||
| }; | ||
|
|
||
| const renderComponent = (props = {}, preloadedState = defaultPreloadedState) => | ||
| renderWithProviders( | ||
| <MemoryRouter> | ||
| <ProductionLocationDetailsGeneralFields | ||
| data={mockDataWithVisibleFields} | ||
| {...props} | ||
| /> | ||
| </MemoryRouter>, | ||
| { preloadedState }, | ||
| ); | ||
|
|
||
| test('renders the general fields section', () => { | ||
| renderComponent(); | ||
| expect( | ||
| screen.getByTestId('production-location-details-general-fields'), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders at least one data point when data has visible fields', () => { | ||
| renderComponent(); | ||
| const dataPoints = screen.getAllByTestId('data-point'); | ||
| expect(dataPoints.length).toBeGreaterThanOrEqual(1); | ||
| }); | ||
|
|
||
| test('renders data points with labels and values', () => { | ||
| renderComponent(); | ||
| const dataPoints = screen.getAllByTestId('data-point'); | ||
| const first = dataPoints[0]; | ||
| expect(within(first).getByTestId('data-point-label')).toBeInTheDocument(); | ||
| expect(within(first).getByTestId('data-point-value')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders the contributions drawer when opened via sources button', () => { | ||
| renderComponent(); | ||
| const sourcesButtons = screen.queryAllByTestId('data-point-sources-button'); | ||
| expect(sourcesButtons.length).toBeGreaterThan(0); | ||
| sourcesButtons[0].click(); | ||
| expect(screen.getByTestId('contributions-drawer')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('drawer has title and close control when opened', () => { | ||
| renderComponent(); | ||
| const sourcesButtons = screen.queryAllByTestId('data-point-sources-button'); | ||
| if (sourcesButtons.length > 0) { | ||
| sourcesButtons[0].click(); | ||
| expect(screen.getByTestId('contributions-drawer-title')).toBeInTheDocument(); | ||
| expect(screen.getByTestId('contributions-drawer-close')).toBeInTheDocument(); | ||
| } | ||
| }); | ||
|
|
||
| test('opening a field with sources opens the drawer', () => { | ||
| renderComponent(); | ||
| const sourcesButtons = screen.queryAllByTestId('data-point-sources-button'); | ||
| expect(sourcesButtons.length).toBeGreaterThan(0); | ||
| sourcesButtons[0].click(); | ||
| const drawer = screen.getByTestId('contributions-drawer'); | ||
| expect(drawer).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders no data points when data is null', () => { | ||
| renderComponent({ data: null }); | ||
| const container = screen.getByTestId('production-location-details-general-fields'); | ||
| const dataPoints = within(container).queryAllByTestId('data-point'); | ||
| expect(dataPoints).toHaveLength(0); | ||
| }); | ||
|
|
||
| test('renders no data points when data is undefined', () => { | ||
| renderComponent({ data: undefined }); | ||
| const container = screen.getByTestId('production-location-details-general-fields'); | ||
| const dataPoints = within(container).queryAllByTestId('data-point'); | ||
| expect(dataPoints).toHaveLength(0); | ||
| }); | ||
| }); | ||
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
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.