From 2c6f2048e5f662dd0583b7cb508633c3300cc600 Mon Sep 17 00:00:00 2001 From: Amir Alami Date: Wed, 30 Oct 2024 14:07:16 +0100 Subject: [PATCH] feat: Adds snapshot testing to wrapper selectors --- .../test-utils-wrapper.test.tsx.snap | 469 ++++++++++++++++++ src/__tests__/test-utils-wrapper.test.tsx | 16 + 2 files changed, 485 insertions(+) create mode 100644 src/__tests__/__snapshots__/test-utils-wrapper.test.tsx.snap create mode 100644 src/__tests__/test-utils-wrapper.test.tsx diff --git a/src/__tests__/__snapshots__/test-utils-wrapper.test.tsx.snap b/src/__tests__/__snapshots__/test-utils-wrapper.test.tsx.snap new file mode 100644 index 0000000000..8c6f17ea4e --- /dev/null +++ b/src/__tests__/__snapshots__/test-utils-wrapper.test.tsx.snap @@ -0,0 +1,469 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component wrappers dom wrapper 1`] = ` +[ + "constructor", + "findAlert", + "findAllAlerts", + "findAlertByTestId", + "findAnchorNavigation", + "findAllAnchorNavigations", + "findAnchorNavigationByTestId", + "findAnnotation", + "findAllAnnotations", + "findAnnotationByTestId", + "findAppLayout", + "findAllAppLayouts", + "findAppLayoutByTestId", + "findAreaChart", + "findAllAreaCharts", + "findAreaChartByTestId", + "findAttributeEditor", + "findAllAttributeEditors", + "findAttributeEditorByTestId", + "findAutosuggest", + "findAllAutosuggests", + "findAutosuggestByTestId", + "findBadge", + "findAllBadges", + "findBadgeByTestId", + "findBarChart", + "findAllBarCharts", + "findBarChartByTestId", + "findBox", + "findAllBoxes", + "findBoxByTestId", + "findBreadcrumbGroup", + "findAllBreadcrumbGroups", + "findBreadcrumbGroupByTestId", + "findButton", + "findAllButtons", + "findButtonByTestId", + "findButtonDropdown", + "findAllButtonDropdowns", + "findButtonDropdownByTestId", + "findButtonGroup", + "findAllButtonGroups", + "findButtonGroupByTestId", + "findCalendar", + "findAllCalendars", + "findCalendarByTestId", + "findCards", + "findAllCards", + "findCardsByTestId", + "findCheckbox", + "findAllCheckboxes", + "findCheckboxByTestId", + "findCodeEditor", + "findAllCodeEditors", + "findCodeEditorByTestId", + "findCollectionPreferences", + "findAllCollectionPreferences", + "findCollectionPreferencesByTestId", + "findColumnLayout", + "findAllColumnLayouts", + "findColumnLayoutByTestId", + "findContainer", + "findAllContainers", + "findContainerByTestId", + "findContentLayout", + "findAllContentLayouts", + "findContentLayoutByTestId", + "findCopyToClipboard", + "findAllCopyToClipboards", + "findCopyToClipboardByTestId", + "findDateInput", + "findAllDateInputs", + "findDateInputByTestId", + "findDatePicker", + "findAllDatePickers", + "findDatePickerByTestId", + "findDateRangePicker", + "findAllDateRangePickers", + "findDateRangePickerByTestId", + "findDrawer", + "findAllDrawers", + "findDrawerByTestId", + "findExpandableSection", + "findAllExpandableSections", + "findExpandableSectionByTestId", + "findFileUpload", + "findAllFileUploads", + "findFileUploadByTestId", + "findFlashbar", + "findAllFlashbars", + "findFlashbarByTestId", + "findForm", + "findAllForms", + "findFormByTestId", + "findFormField", + "findAllFormFields", + "findFormFieldByTestId", + "findGrid", + "findAllGrids", + "findGridByTestId", + "findHeader", + "findAllHeaders", + "findHeaderByTestId", + "findHelpPanel", + "findAllHelpPanels", + "findHelpPanelByTestId", + "findHotspot", + "findAllHotspots", + "findHotspotByTestId", + "findIcon", + "findAllIcons", + "findIconByTestId", + "findInput", + "findAllInputs", + "findInputByTestId", + "findKeyValuePairs", + "findAllKeyValuePairs", + "findKeyValuePairsByTestId", + "findLineChart", + "findAllLineCharts", + "findLineChartByTestId", + "findLink", + "findAllLinks", + "findLinkByTestId", + "findLiveRegion", + "findAllLiveRegions", + "findLiveRegionByTestId", + "findMixedLineBarChart", + "findAllMixedLineBarCharts", + "findMixedLineBarChartByTestId", + "findModal", + "findAllModals", + "findModalByTestId", + "findMultiselect", + "findAllMultiselects", + "findMultiselectByTestId", + "findPagination", + "findAllPaginations", + "findPaginationByTestId", + "findPieChart", + "findAllPieCharts", + "findPieChartByTestId", + "findPopover", + "findAllPopovers", + "findPopoverByTestId", + "findProgressBar", + "findAllProgressBars", + "findProgressBarByTestId", + "findPromptInput", + "findAllPromptInputs", + "findPromptInputByTestId", + "findPropertyFilter", + "findAllPropertyFilters", + "findPropertyFilterByTestId", + "findRadioGroup", + "findAllRadioGroups", + "findRadioGroupByTestId", + "findS3ResourceSelector", + "findAllS3ResourceSelectors", + "findS3ResourceSelectorByTestId", + "findSegmentedControl", + "findAllSegmentedControls", + "findSegmentedControlByTestId", + "findSelect", + "findAllSelects", + "findSelectByTestId", + "findSideNavigation", + "findAllSideNavigations", + "findSideNavigationByTestId", + "findSlider", + "findAllSliders", + "findSliderByTestId", + "findSpaceBetween", + "findAllSpaceBetweens", + "findSpaceBetweenByTestId", + "findSpinner", + "findAllSpinners", + "findSpinnerByTestId", + "findSplitPanel", + "findAllSplitPanels", + "findSplitPanelByTestId", + "findStatusIndicator", + "findAllStatusIndicators", + "findStatusIndicatorByTestId", + "findSteps", + "findAllSteps", + "findStepsByTestId", + "findTable", + "findAllTables", + "findTableByTestId", + "findTabs", + "findAllTabs", + "findTabsByTestId", + "findTagEditor", + "findAllTagEditors", + "findTagEditorByTestId", + "findTextContent", + "findAllTextContents", + "findTextContentByTestId", + "findTextFilter", + "findAllTextFilters", + "findTextFilterByTestId", + "findTextarea", + "findAllTextareas", + "findTextareaByTestId", + "findTiles", + "findAllTiles", + "findTilesByTestId", + "findTimeInput", + "findAllTimeInputs", + "findTimeInputByTestId", + "findToggle", + "findAllToggles", + "findToggleByTestId", + "findToggleButton", + "findAllToggleButtons", + "findToggleButtonByTestId", + "findTokenGroup", + "findAllTokenGroups", + "findTokenGroupByTestId", + "findTopNavigation", + "findAllTopNavigations", + "findTopNavigationByTestId", + "findTutorialPanel", + "findAllTutorialPanels", + "findTutorialPanelByTestId", + "findWizard", + "findAllWizards", + "findWizardByTestId", +] +`; + +exports[`Component wrappers selector wrapper 1`] = ` +[ + "constructor", + "findAlert", + "findAllAlerts", + "findAlertByTestId", + "findAnchorNavigation", + "findAllAnchorNavigations", + "findAnchorNavigationByTestId", + "findAnnotation", + "findAllAnnotations", + "findAnnotationByTestId", + "findAppLayout", + "findAllAppLayouts", + "findAppLayoutByTestId", + "findAreaChart", + "findAllAreaCharts", + "findAreaChartByTestId", + "findAttributeEditor", + "findAllAttributeEditors", + "findAttributeEditorByTestId", + "findAutosuggest", + "findAllAutosuggests", + "findAutosuggestByTestId", + "findBadge", + "findAllBadges", + "findBadgeByTestId", + "findBarChart", + "findAllBarCharts", + "findBarChartByTestId", + "findBox", + "findAllBoxes", + "findBoxByTestId", + "findBreadcrumbGroup", + "findAllBreadcrumbGroups", + "findBreadcrumbGroupByTestId", + "findButton", + "findAllButtons", + "findButtonByTestId", + "findButtonDropdown", + "findAllButtonDropdowns", + "findButtonDropdownByTestId", + "findButtonGroup", + "findAllButtonGroups", + "findButtonGroupByTestId", + "findCalendar", + "findAllCalendars", + "findCalendarByTestId", + "findCards", + "findAllCards", + "findCardsByTestId", + "findCheckbox", + "findAllCheckboxes", + "findCheckboxByTestId", + "findCodeEditor", + "findAllCodeEditors", + "findCodeEditorByTestId", + "findCollectionPreferences", + "findAllCollectionPreferences", + "findCollectionPreferencesByTestId", + "findColumnLayout", + "findAllColumnLayouts", + "findColumnLayoutByTestId", + "findContainer", + "findAllContainers", + "findContainerByTestId", + "findContentLayout", + "findAllContentLayouts", + "findContentLayoutByTestId", + "findCopyToClipboard", + "findAllCopyToClipboards", + "findCopyToClipboardByTestId", + "findDateInput", + "findAllDateInputs", + "findDateInputByTestId", + "findDatePicker", + "findAllDatePickers", + "findDatePickerByTestId", + "findDateRangePicker", + "findAllDateRangePickers", + "findDateRangePickerByTestId", + "findDrawer", + "findAllDrawers", + "findDrawerByTestId", + "findExpandableSection", + "findAllExpandableSections", + "findExpandableSectionByTestId", + "findFileUpload", + "findAllFileUploads", + "findFileUploadByTestId", + "findFlashbar", + "findAllFlashbars", + "findFlashbarByTestId", + "findForm", + "findAllForms", + "findFormByTestId", + "findFormField", + "findAllFormFields", + "findFormFieldByTestId", + "findGrid", + "findAllGrids", + "findGridByTestId", + "findHeader", + "findAllHeaders", + "findHeaderByTestId", + "findHelpPanel", + "findAllHelpPanels", + "findHelpPanelByTestId", + "findHotspot", + "findAllHotspots", + "findHotspotByTestId", + "findIcon", + "findAllIcons", + "findIconByTestId", + "findInput", + "findAllInputs", + "findInputByTestId", + "findKeyValuePairs", + "findAllKeyValuePairs", + "findKeyValuePairsByTestId", + "findLineChart", + "findAllLineCharts", + "findLineChartByTestId", + "findLink", + "findAllLinks", + "findLinkByTestId", + "findLiveRegion", + "findAllLiveRegions", + "findLiveRegionByTestId", + "findMixedLineBarChart", + "findAllMixedLineBarCharts", + "findMixedLineBarChartByTestId", + "findModal", + "findAllModals", + "findModalByTestId", + "findMultiselect", + "findAllMultiselects", + "findMultiselectByTestId", + "findPagination", + "findAllPaginations", + "findPaginationByTestId", + "findPieChart", + "findAllPieCharts", + "findPieChartByTestId", + "findPopover", + "findAllPopovers", + "findPopoverByTestId", + "findProgressBar", + "findAllProgressBars", + "findProgressBarByTestId", + "findPromptInput", + "findAllPromptInputs", + "findPromptInputByTestId", + "findPropertyFilter", + "findAllPropertyFilters", + "findPropertyFilterByTestId", + "findRadioGroup", + "findAllRadioGroups", + "findRadioGroupByTestId", + "findS3ResourceSelector", + "findAllS3ResourceSelectors", + "findS3ResourceSelectorByTestId", + "findSegmentedControl", + "findAllSegmentedControls", + "findSegmentedControlByTestId", + "findSelect", + "findAllSelects", + "findSelectByTestId", + "findSideNavigation", + "findAllSideNavigations", + "findSideNavigationByTestId", + "findSlider", + "findAllSliders", + "findSliderByTestId", + "findSpaceBetween", + "findAllSpaceBetweens", + "findSpaceBetweenByTestId", + "findSpinner", + "findAllSpinners", + "findSpinnerByTestId", + "findSplitPanel", + "findAllSplitPanels", + "findSplitPanelByTestId", + "findStatusIndicator", + "findAllStatusIndicators", + "findStatusIndicatorByTestId", + "findSteps", + "findAllSteps", + "findStepsByTestId", + "findTable", + "findAllTables", + "findTableByTestId", + "findTabs", + "findAllTabs", + "findTabsByTestId", + "findTagEditor", + "findAllTagEditors", + "findTagEditorByTestId", + "findTextContent", + "findAllTextContents", + "findTextContentByTestId", + "findTextFilter", + "findAllTextFilters", + "findTextFilterByTestId", + "findTextarea", + "findAllTextareas", + "findTextareaByTestId", + "findTiles", + "findAllTiles", + "findTilesByTestId", + "findTimeInput", + "findAllTimeInputs", + "findTimeInputByTestId", + "findToggle", + "findAllToggles", + "findToggleByTestId", + "findToggleButton", + "findAllToggleButtons", + "findToggleButtonByTestId", + "findTokenGroup", + "findAllTokenGroups", + "findTokenGroupByTestId", + "findTopNavigation", + "findAllTopNavigations", + "findTopNavigationByTestId", + "findTutorialPanel", + "findAllTutorialPanels", + "findTutorialPanelByTestId", + "findWizard", + "findAllWizards", + "findWizardByTestId", +] +`; diff --git a/src/__tests__/test-utils-wrapper.test.tsx b/src/__tests__/test-utils-wrapper.test.tsx new file mode 100644 index 0000000000..3763b59519 --- /dev/null +++ b/src/__tests__/test-utils-wrapper.test.tsx @@ -0,0 +1,16 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +import { ElementWrapper as DomElementWrapper } from '../../lib/components/test-utils/dom'; +import { ElementWrapper as SelectorElementWrapper } from '../../lib/components/test-utils/selectors'; + +describe('Component wrappers', () => { + const cases = [ + { wrapper: DomElementWrapper, name: 'dom wrapper' }, + { wrapper: SelectorElementWrapper, name: 'selector wrapper' }, + ]; + + test.each(cases)('$name', ({ wrapper }) => { + const wrapperSelectors = Object.keys(wrapper.prototype); + expect(wrapperSelectors).toMatchSnapshot(); + }); +});