diff --git a/docs/feature_flags.md b/docs/feature_flags.md index 84a4b7614b..04555617ac 100644 --- a/docs/feature_flags.md +++ b/docs/feature_flags.md @@ -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. diff --git a/server/webdriver/shared_tests/timeline_test.py b/server/webdriver/shared_tests/timeline_test.py index 3984e31fc6..3b96e6987b 100644 --- a/server/webdriver/shared_tests/timeline_test.py +++ b/server/webdriver/shared_tests/timeline_test.py @@ -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. diff --git a/server/webdriver/tests/timeline_test.py b/server/webdriver/tests/timeline_test.py index f17e6b54a4..9e4a2b1c81 100644 --- a/server/webdriver/tests/timeline_test.py +++ b/server/webdriver/tests/timeline_test.py @@ -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") diff --git a/static/js/apps/homepage/components/tools.tsx b/static/js/apps/homepage/components/tools.tsx index c853f73f34..49d948b098 100644 --- a/static/js/apps/homepage/components/tools.tsx +++ b/static/js/apps/homepage/components/tools.tsx @@ -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 + access and integrate cleaned datasets.

)} - {props.getObservationSpecs && - isFeatureEnabled(METADATA_FEATURE_FLAG) && ( -
- -
- )} + {props.getObservationSpecs && ( +
+ +
+ )} {props.exploreLink && (
diff --git a/static/js/shared/facet_selector/facet_selector.tsx b/static/js/shared/facet_selector/facet_selector.tsx index 6196fedde5..2d78cb40c2 100644 --- a/static/js/shared/facet_selector/facet_selector.tsx +++ b/static/js/shared/facet_selector/facet_selector.tsx @@ -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 @@ -71,10 +69,5 @@ interface FacetSelectorPropType { } export function FacetSelector(props: FacetSelectorPropType): ReactElement { - const useRichSelector = isFeatureEnabled(METADATA_FEATURE_FLAG); - - if (useRichSelector) { - return ; - } - return ; + return ; } diff --git a/static/js/shared/feature_flags/util.ts b/static/js/shared/feature_flags/util.ts index 48687fdbcf..f80b344cb5 100644 --- a/static/js/shared/feature_flags/util.ts +++ b/static/js/shared/feature_flags/util.ts @@ -16,7 +16,7 @@ // Feature flag names export const AUTOCOMPLETE_FEATURE_FLAG = "autocomplete"; -export const METADATA_FEATURE_FLAG = "metadata_modal"; + 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"; diff --git a/static/js/tools/shared/metadata/tile_sources.tsx b/static/js/tools/shared/metadata/tile_sources.tsx index a1366678dc..97ea1fb02d 100644 --- a/static/js/tools/shared/metadata/tile_sources.tsx +++ b/static/js/tools/shared/metadata/tile_sources.tsx @@ -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, @@ -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)) @@ -132,7 +126,7 @@ export function TileSources(props: { <> - {allowNewMetadataModal && facets && statVarToFacets ? ( + {facets && statVarToFacets ? (