Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 4 additions & 36 deletions server/webdriver/shared_tests/map_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,46 +80,14 @@ def test_charts_from_url(self):
by=By.CSS_SELECTOR,
value='#choropleth-legend .tick')), 5)

# Click United States breadcrumb
shared.click_el(self.driver, (By.LINK_TEXT, 'United States'))

# Assert redirect was correct
shared.wait_for_loading(self.driver)
self.assertEqual(
find_elem(self.driver,
by=By.CSS_SELECTOR,
value='#place-list > div > span').text,
'United States of America')

# Select State place type
shared.wait_for_loading(self.driver)
place_type_selector = find_elem(self.driver,
by=By.ID,
value='place-selector-place-type')
place_type_selector.click()
find_elem(place_type_selector, by=By.XPATH, value='./option[2]').click()

# Assert that a map chart is loaded
self.assertIsNotNone(wait_elem(self.driver, by=By.ID, value='map-items'))
self.assertIn(
"median age of population ",
find_elem(self.driver,
by=By.XPATH,
value='//*[@id="map-chart"]/div/div[1]/h3').text.lower())
self.assertEqual(
len(find_elems(self.driver, by=By.CSS_SELECTOR,
value='#map-items path')), 52)

# Click explore timeline
find_elem(self.driver, value='explore-timeline-text').click()

# Assert rankings page loaded
new_page_title = (
'Ranking by Median Age - States in United States of America - Place ' +
'Rankings - ' + self.dc_title_string)
WebDriverWait(self.driver,
self.TIMEOUT_SEC).until(EC.title_contains(new_page_title))
self.assertEqual(new_page_title, self.driver.title)
expected_ranking_page_title = 'Ranking by Median Age - Counties in California - Place Rankings - ' + self.dc_title_string
WebDriverWait(self.driver, self.TIMEOUT_SEC).until(
EC.title_contains(expected_ranking_page_title))
self.assertEqual(expected_ranking_page_title, self.driver.title)

@pytest.mark.one_at_a_time
def test_manually_enter_options(self):
Expand Down
44 changes: 13 additions & 31 deletions static/js/tools/map/place_details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ import {
} from "../../shared/types";
import { MAP_CONTAINER_ID } from "./chart";
import { Context, DisplayOptions, PlaceInfo, StatVar } from "./context";
import {
getAllChildPlaceTypes,
getParentPlaces,
getRedirectLink,
} from "./util";
import { getParentPlaces } from "./util";

interface PlaceDetailsPropType {
breadcrumbDataValues: { [dcid: string]: number };
Expand Down Expand Up @@ -133,8 +129,8 @@ export function PlaceDetails(props: PlaceDetailsPropType): JSX.Element {
);
}

function highlightPlace(e: React.MouseEvent<HTMLAnchorElement>): void {
const target = e.target as HTMLAnchorElement;
function highlightPlace(e: React.MouseEvent<HTMLElement>): void {
const target = e.target as HTMLElement;
const placeDcid = target.dataset.geodcid;
highlightPlaceToggle(
document.getElementById(MAP_CONTAINER_ID),
Expand All @@ -143,8 +139,8 @@ function highlightPlace(e: React.MouseEvent<HTMLAnchorElement>): void {
);
}

function unhighlightPlace(e: React.MouseEvent<HTMLAnchorElement>): void {
const target = e.target as HTMLAnchorElement;
function unhighlightPlace(e: React.MouseEvent<HTMLElement>): void {
const target = e.target as HTMLElement;
const placeDcid = target.dataset.geodcid;
highlightPlaceToggle(
document.getElementById(MAP_CONTAINER_ID),
Expand Down Expand Up @@ -183,31 +179,17 @@ function getListItemElement(
enclosingPlace,
placeInfo.parentPlaces
);
const redirectLink = getRedirectLink(
statVar,
place,
parentPlaces,
placeInfo.mapPointPlaceType,
display
);
const shouldBeClickable = !_.isEmpty(
getAllChildPlaceTypes(place, parentPlaces)
);

return (
<div key={place.dcid}>
{itemNumber && `${itemNumber}. `}
{shouldBeClickable ? (
<a
href={redirectLink}
data-geodcid={place.dcid}
onMouseEnter={highlightPlace}
onMouseLeave={unhighlightPlace}
>
{place.name}
</a>
) : (
`${place.name}`
)}
<span
data-geodcid={place.dcid}
onMouseEnter={highlightPlace}
onMouseLeave={unhighlightPlace}
>
{place.name}
</span>
{date}: {value}
</div>
);
Expand Down
Loading