-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-1930] Implemented displaying additional identifiers such as RBA, LEI, and DUNS IDs on the production location profile page. #594
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
vladsha-dev
merged 9 commits into
main
from
OSDEV-1930-add-additional-identifiers-to-the-location-profile-page-but-only-for-the-rba-instance
Apr 23, 2025
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f8a4d72
Add new fields to the profile page
vladsha-dev 849e284
Merge branch 'main' into OSDEV-1930-add-additional-identifiers-to-the…
vladsha-dev 1f2f9f4
Add show_additional_identifiers to the DB
vladsha-dev b736ff7
Merge branch 'main' into OSDEV-1930-add-additional-identifiers-to-the…
vladsha-dev a249ac7
Add tests
vladsha-dev 8a63572
Updated the Release notes
vladsha-dev 38235ad
Updated release notes
vladsha-dev 6ce78c8
Fix merge conflict
vladsha-dev a2349da
Fixed inconsistency between mock data and assertions for identifier f…
vladsha-dev 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
25 changes: 25 additions & 0 deletions
25
src/django/api/migrations/0168_introduce_show_additional_identifiers_switch.py
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,25 @@ | ||
| # Generated by Django 3.2.17 on 2025-04-18 14:00 | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| def create_show_additional_identifiers_switch(apps, schema_editor): | ||
| Switch = apps.get_model('waffle', 'Switch') | ||
| Switch.objects.create(name='show_additional_identifiers', | ||
| active=False) | ||
|
|
||
| def delete_show_additional_identifiers_switch(apps, schema_editor): | ||
| Switch = apps.get_model('waffle', 'Switch') | ||
| Switch.objects.get(name='show_additional_identifiers').delete() | ||
|
|
||
| dependencies = [ | ||
| ('api', '0167_add_moderationevent_action_reason_text_fields'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython( | ||
| create_show_additional_identifiers_switch, | ||
| delete_show_additional_identifiers_switch | ||
| ) | ||
| ] |
213 changes: 213 additions & 0 deletions
213
src/react/src/__tests__/components/FacilityDetailsGeneralFields.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,213 @@ | ||
| import React from 'react'; | ||
| import renderWithProviders from '../../util/testUtils/renderWithProviders'; | ||
| import FacilityDetailsGeneralFields from '../../components/FacilityDetailsGeneralFields'; | ||
|
|
||
| describe('FacilityDetailsGeneralFields component: test rendering of additional identifiers', () => { | ||
| const mockData = { | ||
| id: 'US202510850SQCV', | ||
| type: 'Feature', | ||
| geometry: { | ||
| type: 'Point', | ||
| coordinates: [-73.8314318, 40.762569], | ||
| }, | ||
| properties: { | ||
| name: 'Nice production location LTD', | ||
| country_code: 'US', | ||
| os_id: 'US202510850SQCV', | ||
| other_names: [], | ||
| contributors: [ | ||
| { | ||
| id: 1139, | ||
| name: 'Test Org (Test list)', | ||
| is_verified: false, | ||
| contributor_name: 'Test Org', | ||
| list_name: 'Test list', | ||
| }, | ||
| ], | ||
| country_name: 'United States', | ||
| claim_info: null, | ||
| other_locations: [], | ||
| is_closed: null, | ||
| activity_reports: [], | ||
| contributor_fields: [], | ||
| new_os_id: null, | ||
| has_inexact_coordinates: false, | ||
| extended_fields: { | ||
| name: [ | ||
| { | ||
| value: 'Nice production location LTD', | ||
| field_name: 'name', | ||
| contributor_id: 1139, | ||
| contributor_name: 'Test Org', | ||
| updated_at: '2025-04-18T11:25:32.798875Z', | ||
| created_at: '2025-04-18T11:21:15.877648Z', | ||
| }, | ||
| ], | ||
| number_of_workers: [], | ||
| native_language_name: [], | ||
| facility_type: [], | ||
| processing_type: [], | ||
| product_type: [], | ||
| parent_company: [ | ||
| { | ||
| id: 3394113, | ||
| is_verified: false, | ||
| value: { | ||
| name: 'Moon company', | ||
| raw_value: 'Moon company', | ||
| }, | ||
| created_at: '2025-04-18T11:21:15.940646Z', | ||
| updated_at: '2025-04-18T11:25:32.885850Z', | ||
| contributor_name: 'Test Org', | ||
| contributor_id: 1139, | ||
| value_count: 1, | ||
| is_from_claim: false, | ||
| field_name: 'parent_company', | ||
| verified_count: 0, | ||
| }, | ||
| ], | ||
| duns_id: [ | ||
| { | ||
| id: 83087, | ||
| is_verified: false, | ||
| value: { | ||
| raw_value: 2120383532, | ||
| }, | ||
| created_at: '2022-04-01T10:49:15.174025Z', | ||
| updated_at: '2022-04-01T10:58:25.043413Z', | ||
| contributor_name: 'Test Org', | ||
| contributor_id: 1139, | ||
| value_count: 1, | ||
| is_from_claim: false, | ||
| field_name: 'duns_id', | ||
| verified_count: 0, | ||
| }, | ||
| ], | ||
| lei_id: [ | ||
| { | ||
| id: 83087, | ||
| is_verified: false, | ||
| value: { | ||
| raw_value: '529900T8BM49AURSDO55', | ||
| }, | ||
| created_at: '2022-04-01T10:49:15.174025Z', | ||
| updated_at: '2022-04-01T10:58:25.043413Z', | ||
| contributor_name: 'Test Org', | ||
| contributor_id: 1139, | ||
| value_count: 1, | ||
| is_from_claim: false, | ||
| field_name: 'lei_id', | ||
| verified_count: 0, | ||
| }, | ||
| ], | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| rba_id: [ | ||
| { | ||
| id: 83087, | ||
| is_verified: false, | ||
| value: { | ||
| raw_value: | ||
| 'F342E6157BD84B70AB40BF9A6C0C19E1F342E6157BD84B70AB40BF9A6C0C19E1F342E6157BD84B70AB40BF9A6C0C19E1F342E6157BD84B70AB40BF9A6C0C19E1F342E6157BD84B70AB40BF9A6C0C19E1F342E6157BD84B70AB40BF9A6C0C19E', | ||
| }, | ||
| created_at: '2022-04-01T10:49:15.174025Z', | ||
| updated_at: '2022-04-01T10:58:25.043413Z', | ||
| contributor_name: 'Test Org', | ||
| contributor_id: 1139, | ||
| value_count: 1, | ||
| is_from_claim: false, | ||
| field_name: 'rba_id', | ||
| verified_count: 0, | ||
| }, | ||
| ], | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| created_from: { | ||
| created_at: '2025-04-18T11:21:15.877648Z', | ||
| contributor: 'Test Org', | ||
| }, | ||
| sector: [ | ||
| { | ||
| updated_at: '2025-04-18T11:25:32.798875Z', | ||
| contributor_id: 1139, | ||
| contributor_name: 'Test Org', | ||
| values: ['Unspecified'], | ||
| is_from_claim: false, | ||
| created_at: '2025-04-18T11:21:15.877648Z', | ||
| }, | ||
| ], | ||
| is_claimed: false, | ||
| }, | ||
| }; | ||
|
|
||
| const handleFormat = ({ value, formatValue }) => ({ | ||
| primary: formatValue(value), | ||
| }); | ||
|
|
||
| const defaultProps = { | ||
| data: mockData, | ||
| nameField: { primary: 'Nice production location LTD' }, | ||
| otherNames: [], | ||
| embed: false, | ||
| embedConfig: {}, | ||
| formatExtendedField: handleFormat, | ||
| formatIfListAndRemoveDuplicates: jest.fn(), | ||
| hideSectorData: false, | ||
| isClaimed: false, | ||
| }; | ||
|
|
||
| test('renders only non-additional identifier extended fields when the show_additional_identifiers feature flag is false', () => { | ||
| const preloadedState = { | ||
| featureFlags: { | ||
| fetching: false, | ||
| flags: { | ||
| show_additional_identifiers: false, | ||
| }, | ||
| }, | ||
| }; | ||
| const { | ||
| getByText, | ||
| queryByText, | ||
| } = renderWithProviders( | ||
| <FacilityDetailsGeneralFields {...defaultProps} />, | ||
| { preloadedState }, | ||
| ); | ||
|
|
||
| expect(getByText('Name')).toBeInTheDocument(); | ||
| expect(getByText('Nice production location LTD')).toBeInTheDocument(); | ||
| expect(getByText('Parent Company')).toBeInTheDocument(); | ||
| expect(getByText('Moon company')).toBeInTheDocument(); | ||
|
|
||
| expect(queryByText('LEI ID')).not.toBeInTheDocument(); | ||
| expect(queryByText('RBA ID')).not.toBeInTheDocument(); | ||
| expect(queryByText('DUNS ID')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders all extended fields when the show_additional_identifiers feature flag is true', () => { | ||
| const preloadedState = { | ||
| featureFlags: { | ||
| fetching: false, | ||
| flags: { | ||
| show_additional_identifiers: true, | ||
| }, | ||
| }, | ||
| }; | ||
| const { getByText } = renderWithProviders( | ||
| <FacilityDetailsGeneralFields {...defaultProps} />, | ||
| { preloadedState }, | ||
| ); | ||
|
|
||
| expect(getByText('Name')).toBeInTheDocument(); | ||
| expect(getByText('Nice production location LTD')).toBeInTheDocument(); | ||
| expect(getByText('Parent Company')).toBeInTheDocument(); | ||
| expect(getByText('Moon company')).toBeInTheDocument(); | ||
|
|
||
| expect(getByText('LEI ID')).toBeInTheDocument(); | ||
| expect(getByText('2120383532')).toBeInTheDocument(); | ||
| expect(getByText('RBA ID')).toBeInTheDocument(); | ||
| expect(getByText('529900T8BM49AURSDO55')).toBeInTheDocument(); | ||
| expect(getByText('DUNS ID')).toBeInTheDocument(); | ||
| expect( | ||
| getByText( | ||
| 'F342E6157BD84B70AB40BF9A6C0C19E1F342E6157BD84B70AB40BF9A6C0C19E1F342E6157BD84B70AB40BF9A6C0C19E1F342E6157BD84B70AB40BF9A6C0C19E1F342E6157BD84B70AB40BF9A6C0C19E1F342E6157BD84B70AB40BF9A6C0C19E', | ||
| ), | ||
| ).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
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
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.