Skip to content

Commit

Permalink
Fixed bug where export csv wasn't working on place page 'snapshot' gr…
Browse files Browse the repository at this point in the history
…oup bar charts (#4817)

Context: b/384872751
  • Loading branch information
dwnoble authored Dec 26, 2024
1 parent 53037e1 commit 7eea9bf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
25 changes: 24 additions & 1 deletion server/webdriver/shared_tests/place_explorer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,27 @@ def test_ranking_chart_redirect_link(self):

# Check the title text
page_title = self.driver.find_element(By.ID, 'place-name').text
self.assertEqual(page_title, place_name_text)
self.assertEqual(page_title, place_name_text)

def test_export_chart_data(self):
"""Tests the export chart data button works correctly for group bar charts."""
# Load CA housing page
ca_housing_url = CA_URL + "?category=Housing"
self.driver.get(self.url_ + ca_housing_url)

# Wait for trend chart to load
trend_chart = EC.presence_of_element_located(
(By.CSS_SELECTOR, '[data-testclass~="is-snapshot"]'))
WebDriverWait(self.driver, self.TIMEOUT_SEC).until(trend_chart)

# Find and click export link for group bar chart
export_link = self.driver.find_element(
By.XPATH,
"//*[@data-testclass='is-snapshot chart-type-GROUP_BAR']//div[contains(@class,'outlinks')]//a[text()='Export']"
)
export_link.click()

# Wait for entity DCID text to appear in dialog
entity_dcid_present = EC.text_to_be_present_in_element(
(By.CLASS_NAME, "copy-svg"), "Entity DCID")
WebDriverWait(self.driver, self.TIMEOUT_SEC).until(entity_dcid_present)
17 changes: 13 additions & 4 deletions static/js/place/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,16 @@ class Chart extends React.Component<ChartPropType, ChartStateType> {
);
});
return (
<div className="col">
<div
className="col"
data-testclass={`${
this.props.trend
? "is-trend"
: this.props.snapshot
? "is-snapshot"
: ""
} chart-type-${this.props.chartType}`}
>
<div
className={`chart-container ${ASYNC_ELEMENT_HOLDER_CLASS}`}
ref={this.chartElement}
Expand Down Expand Up @@ -445,7 +454,7 @@ class Chart extends React.Component<ChartPropType, ChartStateType> {
entities,
fieldDelimiter: CSV_FIELD_DELIMITER,
transformHeader: transformCsvHeader,
variables: this.props.statsVars,
variables: this.statsVars,
});
} else if (this.props.parentPlaceDcid && this.props.enclosedPlaceType) {
// Ranking & map charts set parentPlaceDcid and rankingPlaceType
Expand All @@ -455,7 +464,7 @@ class Chart extends React.Component<ChartPropType, ChartStateType> {
fieldDelimiter: CSV_FIELD_DELIMITER,
parentEntity: this.props.parentPlaceDcid,
transformHeader: transformCsvHeader,
variables: this.props.statsVars,
variables: this.statsVars,
});
}
// All other charts should fetch data about specific entities and
Expand All @@ -465,7 +474,7 @@ class Chart extends React.Component<ChartPropType, ChartStateType> {
entities,
fieldDelimiter: CSV_FIELD_DELIMITER,
transformHeader: transformCsvHeader,
variables: this.props.statsVars,
variables: this.statsVars,
});
},
this.svgContainerElement.current.offsetWidth,
Expand Down

0 comments on commit 7eea9bf

Please sign in to comment.