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
4 changes: 2 additions & 2 deletions docs/feature_flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ For example, to enable the "autocomplete" feature:

* Enable: https://datacommons.org/explore?enable_feature=autocomplete

To enable both the autocomplete and metadata_modal features:
To enable both the autocomplete and autocomplete2 features:

* Enable: https://datacommons.org/explore?enable_feature=autocomplete&enable_feature=metadata_modal
* Enable: https://datacommons.org/explore?enable_feature=autocomplete&enable_feature=autocomplete2

To manually disable a feature flag, use the `disable_feature` URL parameter.

Expand Down
91 changes: 91 additions & 0 deletions server/webdriver/shared_tests/timeline_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,97 @@ def test_check_statvar_and_uncheck(self):
value='//*[@id="chart-region"]/div[@class="chart-container"]')
self.assertEqual(len(charts), 0)

def test_per_capita_metadata(self):
"""Test that per capita toggle affects metadata dialog content."""

TIMELINE_URL = '/tools/visualization?disable_feature=standardized_vis_tool#visType=timeline'
URL_HASH = '&place=country/USA&sv=%7B"dcid"%3A"Amount_EconomicActivity_GrossDomesticProduction_Nominal"%7D'

self.driver.get(self.url_ + TIMELINE_URL + URL_HASH)

# Wait for the chart to load
shared.wait_for_charts_to_render(self.driver,
timeout_seconds=self.TIMEOUT_SEC)

# Check the sources before toggling per capita
original_source_text = find_elem(self.driver, By.CLASS_NAME, 'sources').text
self.assertIn('datacatalog.worldbank.org', original_source_text)
self.assertIn('About this data', original_source_text)
self.assertNotIn('census.gov', original_source_text)

# Click on the button to open the metadata dialog
sources_div = find_elem(self.driver, value='sources', by=By.CLASS_NAME)
metadata_link = sources_div.find_element(
By.XPATH, ".//a[contains(text(), 'About this data')]")
self.assertIsNotNone(metadata_link, "About this data link not found")
metadata_link.click()

# Wait until the dialog is visible and populated with content
WebDriverWait(self.driver, self.TIMEOUT_SEC).until(
EC.presence_of_element_located((By.CSS_SELECTOR, '.dialog-content h3')))

# Search for "Total population" text in dialog-content h3 elements
dialog_content = find_elem(self.driver,
value='dialog-content',
by=By.CLASS_NAME)
h3_elements = dialog_content.find_elements(By.XPATH, './/h3')

# "Per capita" is not checked, so we expect "Total population" to not be found
total_pop_found = any('Total population' in h3.text for h3 in h3_elements)
self.assertFalse(
total_pop_found,
"Total population should not be present before per capita is checked")

# Close the dialog by clicking the close button
dialog_actions = find_elem(self.driver,
value='dialog-actions',
by=By.CLASS_NAME)
close_button = dialog_actions.find_element(
By.XPATH, ".//button[contains(text(), 'Close')]")
close_button.click()

# Toggle the per capita checkbox
per_capita_checkbox = self.driver.find_element(
By.CSS_SELECTOR, '.chart-options .option-inputs .form-check-input')
per_capita_checkbox.click()

# Wait for the chart to reload
shared.wait_for_loading(self.driver)
shared.wait_for_charts_to_render(self.driver,
timeout_seconds=self.TIMEOUT_SEC)

# Verify the source text has changed
updated_source_text = find_elem(self.driver, By.CLASS_NAME, 'sources').text
self.assertIn('datacatalog.worldbank.org', updated_source_text)
self.assertIn('census.gov', updated_source_text)
self.assertIn('About this data', updated_source_text)

# Open the metadata dialog again
sources_div = find_elem(self.driver, value='sources', by=By.CLASS_NAME)
metadata_link = sources_div.find_element(
By.XPATH, ".//a[contains(text(), 'About this data')]")
self.assertIsNotNone(metadata_link, "About this data link not found")
metadata_link.click()

# Wait until the dialog is visible and populated with content
WebDriverWait(self.driver, self.TIMEOUT_SEC).until(
EC.visibility_of_element_located((
By.XPATH,
"//div[contains(@class, 'dialog-content')]//h3[contains(text(), 'Total population')]"
)))

# Search for "Total population" text in dialog-content h3 elements
dialog_content = find_elem(self.driver,
value='dialog-content',
by=By.CLASS_NAME)
h3_elements = dialog_content.find_elements(By.XPATH, './/h3')

# "Per capita" is checked, so we expect "Total population" to be found
total_pop_found = any('Total population' in h3.text for h3 in h3_elements)
self.assertTrue(
total_pop_found,
"Total population should be present after per capita is checked")

def test_place_search_box_and_remove_place(self):
"""Test the timeline tool place search can work correctly."""
# Load Timeline Tool page with Statistical Variables.
Expand Down
92 changes: 0 additions & 92 deletions server/webdriver/tests/timeline_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,95 +27,3 @@
class TestTimeline(TimelineTestMixin, StandardizedTimelineTestMixin,
BaseDcWebdriverTest):
"""Class to test scatter page. Tests come from TimelineTestMixin."""

# TODO(nick-next): Move to shared_tests once metadata_modal feature flag is dropped
def test_per_capita_metadata(self):
"""Test that per capita toggle affects metadata dialog content."""

TIMELINE_URL = '/tools/visualization?disable_feature=standardized_vis_tool#visType=timeline'
URL_HASH = '&place=country/USA&sv=%7B"dcid"%3A"Amount_EconomicActivity_GrossDomesticProduction_Nominal"%7D'

self.driver.get(self.url_ + TIMELINE_URL + URL_HASH)

# Wait for the chart to load
shared.wait_for_charts_to_render(self.driver,
timeout_seconds=self.TIMEOUT_SEC)

# Check the sources before toggling per capita
original_source_text = find_elem(self.driver, By.CLASS_NAME, 'sources').text
self.assertIn('datacatalog.worldbank.org', original_source_text)
self.assertIn('About this data', original_source_text)
self.assertNotIn('census.gov', original_source_text)

# Click on the button to open the metadata dialog
sources_div = find_elem(self.driver, value='sources', by=By.CLASS_NAME)
metadata_link = sources_div.find_element(
By.XPATH, ".//a[contains(text(), 'About this data')]")
self.assertIsNotNone(metadata_link, "About this data link not found")
metadata_link.click()

# Wait until the dialog is visible and populated with content
WebDriverWait(self.driver, self.TIMEOUT_SEC).until(
EC.presence_of_element_located((By.CSS_SELECTOR, '.dialog-content h3')))

# Search for "Total population" text in dialog-content h3 elements
dialog_content = find_elem(self.driver,
value='dialog-content',
by=By.CLASS_NAME)
h3_elements = dialog_content.find_elements(By.XPATH, './/h3')

# "Per capita" is not checked, so we expect "Total population" to not be found
total_pop_found = any('Total population' in h3.text for h3 in h3_elements)
self.assertFalse(
total_pop_found,
"Total population should not be present before per capita is checked")

# Close the dialog by clicking the close button
dialog_actions = find_elem(self.driver,
value='dialog-actions',
by=By.CLASS_NAME)
close_button = dialog_actions.find_element(
By.XPATH, ".//button[contains(text(), 'Close')]")
close_button.click()

# Toggle the per capita checkbox
per_capita_checkbox = self.driver.find_element(
By.CSS_SELECTOR, '.chart-options .option-inputs .form-check-input')
per_capita_checkbox.click()

# Wait for the chart to reload
shared.wait_for_loading(self.driver)
shared.wait_for_charts_to_render(self.driver,
timeout_seconds=self.TIMEOUT_SEC)

# Verify the source text has changed
updated_source_text = find_elem(self.driver, By.CLASS_NAME, 'sources').text
self.assertIn('datacatalog.worldbank.org', updated_source_text)
self.assertIn('census.gov', updated_source_text)
self.assertIn('About this data', updated_source_text)

# Open the metadata dialog again
sources_div = find_elem(self.driver, value='sources', by=By.CLASS_NAME)
metadata_link = sources_div.find_element(
By.XPATH, ".//a[contains(text(), 'About this data')]")
self.assertIsNotNone(metadata_link, "About this data link not found")
metadata_link.click()

# Wait until the dialog is visible and populated with content
WebDriverWait(self.driver, self.TIMEOUT_SEC).until(
EC.visibility_of_element_located((
By.XPATH,
"//div[contains(@class, 'dialog-content')]//h3[contains(text(), 'Total population')]"
)))

# Search for "Total population" text in dialog-content h3 elements
dialog_content = find_elem(self.driver,
value='dialog-content',
by=By.CLASS_NAME)
h3_elements = dialog_content.find_elements(By.XPATH, './/h3')

# "Per capita" is checked, so we expect "Total population" to be found
total_pop_found = any('Total population' in h3.text for h3 in h3_elements)
self.assertTrue(
total_pop_found,
"Total population should be present after per capita is checked")
4 changes: 2 additions & 2 deletions static/js/apps/homepage/components/tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export const Tools = ({ routes }: ToolsProps): ReactElement => {
${theme.typography.text.lg};
`}
>
Data Commons offers data exploration tools and cloud-based
APIs to access and integrate cleaned datasets.
Data Commons offers data exploration tools and cloud-based APIs to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this should get cleaned up in #5824

access and integrate cleaned datasets.
</p>
</header>
<div
Expand Down
6 changes: 1 addition & 5 deletions static/js/components/subject_page/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ import {
FacetSelector,
FacetSelectorFacetInfo,
} from "../../shared/facet_selector/facet_selector";
import {
isFeatureEnabled,
METADATA_FEATURE_FLAG,
} from "../../shared/feature_flags/util";
import { usePromiseResolver } from "../../shared/hooks/promise_resolver";
import { NamedPlace, NamedTypedPlace, StatVarSpec } from "../../shared/types";
import {
Expand Down Expand Up @@ -246,7 +242,7 @@ function blockEligibleForFacetSelector(
columns: ColumnConfig[],
isWebComponentBlock: boolean
): boolean {
if (isWebComponentBlock || !isFeatureEnabled(METADATA_FEATURE_FLAG)) {
if (isWebComponentBlock) {
return false;
}

Expand Down
25 changes: 10 additions & 15 deletions static/js/components/tiles/chart_footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import React, { RefObject, useState } from "react";

import { intl } from "../../i18n/i18n";
import { messages } from "../../i18n/i18n_messages";
import {
isFeatureEnabled,
METADATA_FEATURE_FLAG,
} from "../../shared/feature_flags/util";
import {
GA_EVENT_TILE_DOWNLOAD,
GA_EVENT_TILE_EXPLORE_MORE,
Expand Down Expand Up @@ -99,17 +95,16 @@ export function ChartFooter(props: ChartFooterPropType): JSX.Element {
</div>
)}

{props.getObservationSpecs &&
isFeatureEnabled(METADATA_FEATURE_FLAG) && (
<div className="outlink-item api-outlink">
<ApiButton
apiRoot={props.apiRoot}
getObservationSpecs={props.getObservationSpecs}
containerRef={props.containerRef}
surface={props.surface}
/>
</div>
)}
{props.getObservationSpecs && (
<div className="outlink-item api-outlink">
<ApiButton
apiRoot={props.apiRoot}
getObservationSpecs={props.getObservationSpecs}
containerRef={props.containerRef}
surface={props.surface}
/>
</div>
)}

{props.exploreLink && (
<div className="outlink-item explore-in-outlink">
Expand Down
9 changes: 1 addition & 8 deletions static/js/shared/facet_selector/facet_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
import React, { ReactElement } from "react";

import { FacetSelectionCriteria } from "../../types/facet_selection_criteria";
import { isFeatureEnabled, METADATA_FEATURE_FLAG } from "../feature_flags/util";
import { StatMetadata } from "../stat_types";
import { FacetSelectorRich } from "./facet_selector_rich";
import { FacetSelectorSimple } from "./facet_selector_simple";

export interface FacetSelectorFacetInfo {
// dcid of the stat var
Expand Down Expand Up @@ -71,10 +69,5 @@ interface FacetSelectorPropType {
}

export function FacetSelector(props: FacetSelectorPropType): ReactElement {
const useRichSelector = isFeatureEnabled(METADATA_FEATURE_FLAG);

if (useRichSelector) {
return <FacetSelectorRich {...props} />;
}
return <FacetSelectorSimple {...props} />;
return <FacetSelectorRich {...props} />;
}
Comment on lines 71 to 73
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Now that the feature flag is removed, this component is just a wrapper around FacetSelectorRich. As the TODO comment at the top of the file suggests (lines 22-24), you should consider removing this file and renaming FacetSelectorRich to FacetSelector. This would also involve updating all imports of FacetSelector to point to the new file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to streamline the code

2 changes: 1 addition & 1 deletion static/js/shared/feature_flags/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

// Feature flag names
export const AUTOCOMPLETE_FEATURE_FLAG = "autocomplete";
export const METADATA_FEATURE_FLAG = "metadata_modal";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: delete newline

export const FOLLOW_UP_QUESTIONS_GA = "follow_up_questions_ga";
export const PAGE_OVERVIEW_GA = "page_overview_ga";
export const EXPLORE_RESULT_HEADER = "explore_result_header";
Expand Down
8 changes: 1 addition & 7 deletions static/js/tools/shared/metadata/tile_sources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ import { ApiButton } from "../../../components/tiles/components/api_button";
import { NL_SOURCE_REPLACEMENTS } from "../../../constants/app/explore_constants";
import { intl } from "../../../i18n/i18n";
import { messages } from "../../../i18n/i18n_messages";
import {
isFeatureEnabled,
METADATA_FEATURE_FLAG,
} from "../../../shared/feature_flags/util";
import {
GA_EVENT_TILE_EXPLORE_MORE,
GA_PARAM_URL,
Expand Down Expand Up @@ -82,8 +78,6 @@ export function TileSources(props: {
return null;
}

const allowNewMetadataModal = isFeatureEnabled(METADATA_FEATURE_FLAG);

const sourceList: string[] = facets
? Array.from(
new Set(Object.values(facets).map((facet) => facet.provenanceUrl))
Expand Down Expand Up @@ -132,7 +126,7 @@ export function TileSources(props: {
<>
<span {...{ part: "source-separator" }}> • </span>
<span {...{ part: "source-show-metadata-link" }}>
{allowNewMetadataModal && facets && statVarToFacets ? (
{facets && statVarToFacets ? (
<TileMetadataModal
apiRoot={props.apiRoot}
containerRef={props.containerRef}
Expand Down
Loading