-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-2369][PL Redesign] Implement Contribute to this profile section #889
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
vlad-shapik
merged 11 commits into
main
from
OSDEV-2369-implement-contribute-to-this-profile-section
Feb 27, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
47f97dc
Draft version of Contribute to this profile
vlad-shapik ccd9b0e
Updated fetching of location data and contribute section
vlad-shapik b2037e2
Update comment
vlad-shapik 39993f7
Updated variable names
vlad-shapik adc00a1
Updates styles
vlad-shapik 24bb102
Refactored code
vlad-shapik c6d4afb
Refactored code and fixed errors/warnings
vlad-shapik e46bc93
Add ContributeFields tests, data-testids, and release notes for OSDEV…
vlad-shapik 8d25883
fix: apply Prettier to ClosureStatus and ProductionLocationDetailsLoc…
vlad-shapik 0c879a1
refactor(tests): use arrow functions in ContributeFields.test.js
vlad-shapik f9f812a
Refactored code
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,3 +104,4 @@ dumps | |
| # Cursor | ||
| .cursor-rules | ||
| .cursor-test-conventions.md | ||
| .cursor | ||
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 |
|---|---|---|
|
|
@@ -71,6 +71,7 @@ function App({ | |
| }, | ||
| background: { | ||
| grey: COLOURS.LIGHT_GREY, | ||
| white: COLOURS.WHITE, | ||
| }, | ||
| }, | ||
| }), | ||
|
|
||
267 changes: 267 additions & 0 deletions
267
src/react/src/__tests__/components/ContributeFields.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,267 @@ | ||
| import React from 'react'; | ||
| import { MemoryRouter } from 'react-router-dom'; | ||
| import { screen, within, fireEvent } from '@testing-library/react'; | ||
| import renderWithProviders from '../../util/testUtils/renderWithProviders'; | ||
| import { setupStore } from '../../configureStore'; | ||
| import ContributeFields from '../../components/ProductionLocation/Sidebar/ContributeFields/ContributeFields'; | ||
| import { USER_DEFAULT_STATE } from '../../util/constants'; | ||
| import { completeFetchSingleFacility } from '../../actions/facilities'; | ||
|
|
||
| const TEST_OS_ID = 'US2026055ETKBY0'; | ||
|
|
||
| const minimalFacilityFeature = { | ||
| id: TEST_OS_ID, | ||
| type: 'Feature', | ||
| geometry: { | ||
| type: 'Point', | ||
| coordinates: [-73.83, 40.76], | ||
| }, | ||
| properties: { | ||
| name: 'Test Facility Name', | ||
| address: '123 Test St', | ||
| country_code: 'US', | ||
| country_name: 'United States', | ||
| is_closed: false, | ||
| }, | ||
| }; | ||
|
|
||
| const getDefaultPreloadedState = (overrides = {}) => { | ||
| const defaultState = { | ||
| facilities: { | ||
| singleFacility: { | ||
| data: minimalFacilityFeature, | ||
| fetching: false, | ||
| error: null, | ||
| }, | ||
| }, | ||
| auth: { | ||
| user: { | ||
| user: { ...USER_DEFAULT_STATE }, | ||
| }, | ||
| }, | ||
| dashboardActivityReports: { | ||
| activityReports: { | ||
| data: [], | ||
| fetching: false, | ||
| error: null, | ||
| message: null, | ||
| }, | ||
| }, | ||
| }; | ||
| return { | ||
| ...defaultState, | ||
| ...overrides, | ||
| facilities: { | ||
| ...defaultState.facilities, | ||
| ...(overrides.facilities || {}), | ||
| singleFacility: { | ||
| ...defaultState.facilities.singleFacility, | ||
| ...(overrides.facilities?.singleFacility || {}), | ||
| }, | ||
| }, | ||
| auth: { | ||
| ...defaultState.auth, | ||
| ...(overrides.auth || {}), | ||
| user: { | ||
| ...defaultState.auth.user, | ||
| ...(overrides.auth?.user || {}), | ||
| user: { | ||
| ...defaultState.auth.user.user, | ||
| ...(overrides.auth?.user?.user || {}), | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| const renderContributeFields = (preloadedStateOverrides = {}, props = {}) => { | ||
| const preloadedState = getDefaultPreloadedState(preloadedStateOverrides); | ||
|
|
||
| return renderWithProviders( | ||
| <MemoryRouter> | ||
| <ContributeFields osId={props.osId ?? TEST_OS_ID} /> | ||
| </MemoryRouter>, | ||
| { preloadedState }, | ||
| ); | ||
| } | ||
|
|
||
| describe('ContributeFields and ReportFacilityStatusDialog', () => { | ||
| describe('ContributeFields section', () => { | ||
| test('renders contribute section with test id', () => { | ||
| renderContributeFields(); | ||
|
|
||
| expect(screen.getByTestId('contribute-fields')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders suggest correction link with correct path', () => { | ||
| renderContributeFields(); | ||
|
|
||
| const link = screen.getByTestId('contribute-suggest-correction'); | ||
| expect(link).toBeInTheDocument(); | ||
| expect(link).toHaveAttribute( | ||
| 'href', | ||
| expect.stringContaining(`/contribute/single-location/${TEST_OS_ID}/info/`), | ||
| ); | ||
| }); | ||
|
|
||
| test('renders report duplicate mailto link', () => { | ||
| renderContributeFields(); | ||
|
|
||
| const link = screen.getByTestId('contribute-report-duplicate'); | ||
| expect(link).toBeInTheDocument(); | ||
| expect(link).toHaveAttribute('href', expect.stringMatching(/^mailto:/)); | ||
| }); | ||
|
|
||
| test('renders report status action that opens dialog', () => { | ||
| renderContributeFields(); | ||
|
|
||
| expect(screen.getByTestId('contribute-report-status')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders report status action when facility is closed', () => { | ||
| const closedFacility = { | ||
| ...minimalFacilityFeature, | ||
| properties: { | ||
| ...minimalFacilityFeature.properties, | ||
| is_closed: true, | ||
| }, | ||
| }; | ||
| renderContributeFields({ | ||
| facilities: { | ||
| singleFacility: { | ||
| data: closedFacility, | ||
| fetching: false, | ||
| error: null, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| expect(screen.getByTestId('contribute-report-status')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('ReportFacilityStatusDialog integration', () => { | ||
| test('opening report status shows dialog with facility data', () => { | ||
| renderContributeFields(); | ||
|
|
||
| expect(screen.queryByTestId('report-facility-status-dialog')).not.toBeInTheDocument(); | ||
|
|
||
| fireEvent.click(screen.getByTestId('contribute-report-status')); | ||
|
|
||
| const dialog = screen.getByTestId('report-facility-status-dialog'); | ||
| expect(dialog).toBeInTheDocument(); | ||
| expect( | ||
| within(dialog).getByTestId('report-facility-status-dialog-facility-name'), | ||
| ).toHaveTextContent(minimalFacilityFeature.properties.name); | ||
| }); | ||
|
|
||
| test('when single facility data is null dialog does not render content when opened', () => { | ||
| renderContributeFields({ | ||
| facilities: { | ||
| singleFacility: { | ||
| data: null, | ||
| fetching: false, | ||
| error: null, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| fireEvent.click(screen.getByTestId('contribute-report-status')); | ||
|
|
||
| expect(screen.queryByTestId('report-facility-status-dialog')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('anonymous user sees login prompt in dialog', () => { | ||
| renderContributeFields(); | ||
|
|
||
| fireEvent.click(screen.getByTestId('contribute-report-status')); | ||
|
|
||
| expect( | ||
| screen.getByTestId('report-facility-status-dialog-login'), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('logged-in user sees reason field and report action', () => { | ||
| renderContributeFields({ | ||
| auth: { | ||
| user: { | ||
| user: { | ||
| ...USER_DEFAULT_STATE, | ||
| isAnon: false, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| fireEvent.click(screen.getByTestId('contribute-report-status')); | ||
|
|
||
| expect(screen.getByTestId('report-facility-status-reason')).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByTestId('report-facility-status-dialog-cancel'), | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByTestId('report-facility-status-dialog-report'), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('cancel closes dialog', () => { | ||
| renderContributeFields({ | ||
| auth: { | ||
| user: { | ||
| user: { | ||
| ...USER_DEFAULT_STATE, | ||
| isAnon: false, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| fireEvent.click(screen.getByTestId('contribute-report-status')); | ||
| expect(screen.getByTestId('report-facility-status-dialog')).toBeInTheDocument(); | ||
|
|
||
| fireEvent.click(screen.getByTestId('report-facility-status-dialog-cancel')); | ||
|
|
||
| const dialogAfterClose = screen.getByTestId('report-facility-status-dialog'); | ||
| expect(dialogAfterClose).not.toBeVisible(); | ||
| }); | ||
|
|
||
| test('report with empty reason keeps dialog open', () => { | ||
| renderContributeFields({ | ||
| auth: { | ||
| user: { | ||
| user: { | ||
| ...USER_DEFAULT_STATE, | ||
| isAnon: false, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| fireEvent.click(screen.getByTestId('contribute-report-status')); | ||
| fireEvent.click(screen.getByTestId('report-facility-status-dialog-report')); | ||
|
|
||
| expect(screen.getByTestId('report-facility-status-dialog')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Redux state via actions', () => { | ||
| test('prefilled facility via completeFetchSingleFacility is used by dialog', () => { | ||
| const store = setupStore({}); | ||
| store.dispatch(completeFetchSingleFacility(minimalFacilityFeature)); | ||
|
|
||
| const { getByTestId } = renderWithProviders( | ||
| <MemoryRouter> | ||
| <ContributeFields osId={TEST_OS_ID} /> | ||
| </MemoryRouter>, | ||
| { reduxStore: store }, | ||
| ); | ||
|
|
||
| fireEvent.click(getByTestId('contribute-report-status')); | ||
|
|
||
| expect(getByTestId('report-facility-status-dialog')).toBeInTheDocument(); | ||
| expect( | ||
| getByTestId('report-facility-status-dialog-facility-name'), | ||
| ).toHaveTextContent(minimalFacilityFeature.properties.name); | ||
| }); | ||
| }); | ||
| }); |
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
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.
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.