diff --git a/app/src/components/calculators/SolarCalculator.js b/app/src/components/calculators/SolarCalculator.js index 2b492e3b..011ce2e8 100644 --- a/app/src/components/calculators/SolarCalculator.js +++ b/app/src/components/calculators/SolarCalculator.js @@ -2,7 +2,6 @@ import React from "react"; import {useSearchParams} from "react-router"; import { Accordion, - Anchor, Button, Grid, Group, @@ -199,6 +198,17 @@ const compassLabel = azimuth => { // Small explanatory text at the top of a collapsed section. const Hint = ({children}) =>

{children}

; +// NASA POWER's requested acknowledgment, the license, and how WROLPi changed the data (CC BY 4.0). +function DataAttribution() { + return
+
Data attribution
+

{CLIMATOLOGY_ACKNOWLEDGMENT} {CLIMATOLOGY_DATA_REFERENCE}

+

License: {CLIMATOLOGY_LICENSE}

+

{CLIMATOLOGY_CHANGES}

+
; +} + const ESTIMATE_INFO = 'A typical-year estimate from monthly averages. Real years vary; expect roughly ±10–15% ' + 'over a year and more in any single month. Shading from trees and buildings is not modeled beyond the ' + 'Shading loss.'; @@ -216,7 +226,6 @@ const GEOLOCATION_ERRORS = { function LocationSection({get, set, s, climatology}) { const [locating, setLocating] = React.useState(false); - const [showAttribution, setShowAttribution] = React.useState(false); const [geoError, setGeoError] = React.useState(null); const latError = get('lat') && s.latitude === null ? 'Latitude must be between -90 and 90' : null; const lonError = get('lon') && s.longitude === null ? 'Longitude must be between -180 and 180' : null; @@ -248,17 +257,7 @@ function LocationSection({get, set, s, climatology}) { Enter your own monthly sunlight under "Use my own sunlight data" below. ; } else { - source = <> - Sunlight and temperature: {CLIMATOLOGY_SOURCE}.{' '} - setShowAttribution(!showAttribution)}> - Data attribution - - {showAttribution &&
-

{CLIMATOLOGY_ACKNOWLEDGMENT} {CLIMATOLOGY_DATA_REFERENCE}

-

License: {CLIMATOLOGY_LICENSE}

-

{CLIMATOLOGY_CHANGES}

-
} - ; + source = `Sunlight and temperature: ${CLIMATOLOGY_SOURCE}; see Data attribution at the bottom of the page.`; } return <> @@ -622,5 +621,7 @@ export function SolarCalculator() { + + ; } diff --git a/app/src/components/calculators/SolarCalculator.test.js b/app/src/components/calculators/SolarCalculator.test.js index 5eaf4b55..81837b09 100644 --- a/app/src/components/calculators/SolarCalculator.test.js +++ b/app/src/components/calculators/SolarCalculator.test.js @@ -122,14 +122,18 @@ describe('SolarCalculator', () => { expect(global.fetch).toHaveBeenCalledWith(expect.stringMatching(/\/data\/solar-climatology\.bin$/)); }); - test('the data attribution expands', async () => { + test('the data attribution is at the bottom of the page', async () => { renderWithProviders(, {route: DENVER}); await findEstimate(); - expect(screen.queryByText(/Prediction Of Worldwide Energy Resources/)).not.toBeInTheDocument(); - fireEvent.click(screen.getByRole('button', {name: 'Data attribution'})); - expect(screen.getByText(/Prediction Of Worldwide Energy Resources/)).toBeInTheDocument(); - expect(screen.getByText(/WROLPi modified the data/)).toBeInTheDocument(); - expect(screen.getByText(/CC BY 4\.0/, {selector: 'p'})).toBeInTheDocument(); + const heading = screen.getByRole('heading', {name: 'Data attribution'}); + const section = screen.getByRole('region', {name: 'Data attribution'}); + expect(within(section).getByText(/Prediction Of Worldwide Energy Resources/)).toBeInTheDocument(); + expect(within(section).getByText(/WROLPi modified the data/)).toBeInTheDocument(); + expect(within(section).getByText(/CC BY 4\.0/)).toBeInTheDocument(); + // After everything else, including the last Fine-tune section. + const lastControl = screen.getByText('Use my own sunlight data: off'); + expect(lastControl.compareDocumentPosition(heading) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + expect(screen.getByText(/see Data attribution at the bottom of the page/)).toBeInTheDocument(); }); test('typing writes the URL and leaves defaults out', async () => { diff --git a/docker/help/wrolpi-help b/docker/help/wrolpi-help index 241ba003..e118fe46 160000 --- a/docker/help/wrolpi-help +++ b/docker/help/wrolpi-help @@ -1 +1 @@ -Subproject commit 241ba0032e3b571f1919b2b4f1905449fbd567ed +Subproject commit e118fe46c94a0f5f371b009ccc9d7fd14ca979df