Skip to content

Commit

Permalink
Sort place page sub-topics alphabetically (#1057)
Browse files Browse the repository at this point in the history
* Sort place page sub-topics alphabetically

* fix tests
  • Loading branch information
shifucun authored Jul 16, 2021
1 parent b540019 commit 4f6b96b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions server/webdriver_tests/place_explorer_i18n_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ def test_demographics_link_in_fr(self):

# Assert chart title is correct.
chart_title = self.driver.find_element_by_xpath(
'//*[@id="main-pane"]/section[4]/div/div[2]/div/h4')
'//*[@id="main-pane"]/section[5]/div/div[2]/div/h4')
self.assertEqual(chart_title.text,
'Population urbaine et rurale : autres pays(2019)')

# Click through to ranking
pop_growth_rate_chip = self.driver.find_element_by_xpath(
'//*[@id="main-pane"]/section[2]/div/div[1]/div/div/div/div/a')
'//*[@id="main-pane"]/section[6]/div/div[1]/div/div/div/div/a')
self.assertEqual(pop_growth_rate_chip.text,
'Taux de croissance de la population')
pop_growth_rate_chip.click()
Expand Down
4 changes: 2 additions & 2 deletions server/webdriver_tests/place_explorer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_demographics_link(self):
"""
Test the demographics link can work correctly.
"""
CHART_TITLE = "Gender distribution: states near California(2019)"
CHART_TITLE = "Median age by gender: states near California(2019)"
# Load California page.
self.driver.get(self.url_ + CA_URL)

Expand Down Expand Up @@ -185,5 +185,5 @@ def test_demographics_redirect_link(self):
'//*[@id="main-pane"]/section[4]/div/div[2]/div/h4').text

# Assert chart title is correct.
self.assertEqual("Gender distribution: states near California(2019)",
self.assertEqual("Median age by gender: states near California(2019)",
chart_title)
4 changes: 3 additions & 1 deletion static/js/place/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class MainPane extends React.Component<MainPanePropType> {
const topicData = this.props.pageChart[this.props.topic];
const currentPageTopic = this.props.topic;
const isOverview = currentPageTopic === "Overview";
const topics = Object.keys(topicData);
topics.sort();
return (
<RawIntlProvider value={intl}>
{this.props.isUsaPlace &&
Expand All @@ -97,7 +99,7 @@ class MainPane extends React.Component<MainPanePropType> {
// Only Show map and ranking for US places.
<Overview dcid={this.props.dcid} locale={this.props.locale} />
)}
{Object.keys(topicData).map((topic: string) => {
{topics.map((topic: string) => {
let subtopicHeader: JSX.Element;
if (isOverview) {
subtopicHeader = (
Expand Down
1 change: 1 addition & 0 deletions static/js/place/topic_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class Menu extends React.Component<MenuPropsType> {
)}
{categories.map((category: string) => {
let topics = Object.keys(this.props.pageChart[category]);
topics.sort();
if (category === "Overview") {
topics = topics.map((t) => this.props.categories[t]);
}
Expand Down

0 comments on commit 4f6b96b

Please sign in to comment.