diff --git a/pages/funnel-analytics/mock-funnel.ts b/pages/funnel-analytics/mock-funnel.ts index 3f9144bdfc..b392b205dd 100644 --- a/pages/funnel-analytics/mock-funnel.ts +++ b/pages/funnel-analytics/mock-funnel.ts @@ -8,7 +8,7 @@ const funnelMetricsLog: { action: string; resolvedProps?: any; props: any }[] = export const MockedFunnelMetrics: IFunnelMetrics = { funnelStart(props): string { - const funnelName = document.querySelector(props.funnelNameSelector)?.innerHTML; + const funnelName = document.querySelector(props.funnelNameSelector)?.textContent; funnelMetricsLog.push({ action: 'funnelStart', props, resolvedProps: { funnelName } }); return 'mocked-funnel-id'; }, @@ -34,35 +34,35 @@ export const MockedFunnelMetrics: IFunnelMetrics = { }, funnelStepStart(props): void { - const stepName = document.querySelector(props.stepNameSelector!)?.innerHTML; + const stepName = document.querySelector(props.stepNameSelector!)?.textContent; funnelMetricsLog.push({ action: 'funnelStepStart', props, resolvedProps: { stepName } }); }, funnelStepComplete(props): void { - const stepName = document.querySelector(props.stepNameSelector!)?.innerHTML; + const stepName = document.querySelector(props.stepNameSelector!)?.textContent; funnelMetricsLog.push({ action: 'funnelStepComplete', props, resolvedProps: { stepName } }); }, funnelStepNavigation(props): void { - const stepName = document.querySelector(props.stepNameSelector!)?.innerHTML; + const stepName = document.querySelector(props.stepNameSelector!)?.textContent; // const subStepAllElements = document.querySelectorAll(props.subStepAllSelector); // TODO: Does not work funnelMetricsLog.push({ action: 'funnelStepNavigation', props, resolvedProps: { stepName } }); }, funnelStepError(props): void { - const stepName = document.querySelector(props.stepNameSelector!)?.innerHTML; + const stepName = document.querySelector(props.stepNameSelector!)?.textContent; funnelMetricsLog.push({ action: 'funnelStepError', props, resolvedProps: { stepName } }); }, funnelStepChange(props): void { - const stepName = document.querySelector(props.stepNameSelector!)?.innerHTML; + const stepName = document.querySelector(props.stepNameSelector!)?.textContent; funnelMetricsLog.push({ action: 'funnelStepChange', props, resolvedProps: { stepName } }); }, funnelSubStepStart(props): void { - const stepName = document.querySelector(props.stepNameSelector!)?.innerHTML; - const subStepName = document.querySelector(props.subStepNameSelector)?.innerHTML; + const stepName = document.querySelector(props.stepNameSelector!)?.textContent; + const subStepName = document.querySelector(props.subStepNameSelector)?.textContent; const subStepAllElements = document.querySelectorAll(props.subStepAllSelector); const subStepElement = document.querySelector(props.subStepSelector); @@ -74,8 +74,8 @@ export const MockedFunnelMetrics: IFunnelMetrics = { }, funnelSubStepComplete(props): void { - const stepName = document.querySelector(props.stepNameSelector!)?.innerHTML; - const subStepName = document.querySelector(props.subStepNameSelector)?.innerHTML; + const stepName = document.querySelector(props.stepNameSelector!)?.textContent; + const subStepName = document.querySelector(props.subStepNameSelector)?.textContent; const subStepAllElements = document.querySelectorAll(props.subStepAllSelector); const subStepElement = document.querySelector(props.subStepSelector); @@ -87,10 +87,10 @@ export const MockedFunnelMetrics: IFunnelMetrics = { }, funnelSubStepError(props): void { - const stepName = document.querySelector(props.stepNameSelector!)?.innerHTML; - const subStepName = document.querySelector(props.subStepNameSelector)?.innerHTML; - const fieldLabel = document.querySelector(props.fieldLabelSelector!)?.innerHTML; - const fieldError = document.querySelector(props.fieldErrorSelector!)?.innerHTML; + const stepName = document.querySelector(props.stepNameSelector!)?.textContent; + const subStepName = document.querySelector(props.subStepNameSelector)?.textContent; + const fieldLabel = document.querySelector(props.fieldLabelSelector!)?.textContent; + const fieldError = document.querySelector(props.fieldErrorSelector!)?.textContent; funnelMetricsLog.push({ action: 'funnelSubStepError', @@ -100,8 +100,8 @@ export const MockedFunnelMetrics: IFunnelMetrics = { }, helpPanelInteracted(props): void { - const stepName = document.querySelector(props.stepNameSelector!)?.innerHTML; - const subStepName = document.querySelector(props.subStepNameSelector)?.innerHTML; + const stepName = document.querySelector(props.stepNameSelector!)?.textContent; + const subStepName = document.querySelector(props.subStepNameSelector)?.textContent; const subStepElement = document.querySelectorAll(props.subStepSelector); const subStepAllElements = document.querySelectorAll(props.subStepAllSelector); const element = document.querySelector(props.elementSelector); @@ -114,8 +114,8 @@ export const MockedFunnelMetrics: IFunnelMetrics = { }, externalLinkInteracted(props): void { - const stepName = document.querySelector(props.stepNameSelector!)?.innerHTML; - const subStepName = document.querySelector(props.subStepNameSelector)?.innerHTML; + const stepName = document.querySelector(props.stepNameSelector!)?.textContent; + const subStepName = document.querySelector(props.subStepNameSelector)?.textContent; const subStepElement = document.querySelectorAll(props.subStepSelector); const subStepAllElements = document.querySelectorAll(props.subStepAllSelector); const element = document.querySelector(props.elementSelector); diff --git a/pages/funnel-analytics/static-single-page-flow.page.tsx b/pages/funnel-analytics/static-single-page-flow.page.tsx index 9d22b958a2..c7bb546f9d 100644 --- a/pages/funnel-analytics/static-single-page-flow.page.tsx +++ b/pages/funnel-analytics/static-single-page-flow.page.tsx @@ -7,6 +7,7 @@ import { BreadcrumbGroup, Button, Container, + ExpandableSection, Form, FormField, Header, @@ -32,6 +33,7 @@ export default function StaticSinglePageCreatePage() { const [mounted, setUnmounted] = useState(true); const [modalVisible, setModalVisible] = useState(false); const [value, setValue] = useState(''); + const [value2, setValue2] = useState(''); const [errorText, setErrorText] = useState(''); const [validationError, setValidationError] = useState(); const [fetchError, setFetchError] = useState(null); @@ -188,6 +190,24 @@ export default function StaticSinglePageCreatePage() { + + + + { + setValue2(event.detail.value); + }} + /> + + + ) diff --git a/src/expandable-section/expandable-section-container.tsx b/src/expandable-section/expandable-section-container.tsx index 353cf53364..880af5e821 100644 --- a/src/expandable-section/expandable-section-container.tsx +++ b/src/expandable-section/expandable-section-container.tsx @@ -9,6 +9,7 @@ import { import { InternalContainerAsSubstep } from '../container/internal'; import { AnalyticsFunnelSubStep } from '../internal/analytics/components/analytics-funnel'; +import { BasePropsWithAnalyticsMetadata, getAnalyticsMetadataProps } from '../internal/base-component'; import { InternalBaseComponentProps } from '../internal/hooks/use-base-component'; import { GeneratedAnalyticsMetadataExpandableSectionComponent } from './analytics-metadata/interfaces'; import { InternalVariant } from './interfaces'; @@ -36,6 +37,7 @@ export const ExpandableSectionContainer = ({ __injectAnalyticsComponentMetadata, ...rest }: ExpandableSectionContainerProps) => { + const analyticsMetadata = getAnalyticsMetadataProps(rest as BasePropsWithAnalyticsMetadata); const analyticsComponentMetadata: GeneratedAnalyticsMetadataExpandableSectionComponent = { name: 'awsui.ExpandableSection', label: { root: 'self' }, @@ -48,7 +50,10 @@ export const ExpandableSectionContainer = ({ if (variant === 'container' || variant === 'stacked') { return ( - + { subStepConfiguration: [ { name: 'Container 1 - header', number: 1, subStepIdentifier: 'container-1' }, { name: 'Container 2 - header', number: 2, subStepIdentifier: 'container-2' }, + { name: 'Expandable Section 1 - Header', number: 3, subStepIdentifier: 'expandable-section-1' }, ], stepNumber: 1, - totalSubSteps: 2, + totalSubSteps: 3, }); }) ); @@ -102,7 +103,7 @@ describe.each(['refresh', 'refresh-toolbar'] as Theme[])('%s', theme => { await page.keys('Tab'); // From Input -> S3 Resource selector Info await page.keys('Tab'); // S3 Resource selector Info -> S3 Resource Selector Input await page.keys('Tab'); // S3 Resource selector Input -> S3 Resource selector Browse button - await page.keys('Tab'); // S3 Resource selector Browse button -> Cancel button + await page.keys('Tab'); // S3 Resource selector Browse button -> Additional configuration header const { funnelLog, actions } = await page.getFunnelLog(); expect(actions).toEqual([ 'funnelStart', @@ -111,6 +112,7 @@ describe.each(['refresh', 'refresh-toolbar'] as Theme[])('%s', theme => { 'funnelSubStepComplete', 'funnelSubStepStart', 'funnelSubStepComplete', + 'funnelSubStepStart', ]); // funnelSubStepStart - Container 1 @@ -204,6 +206,29 @@ describe.each(['refresh', 'refresh-toolbar'] as Theme[])('%s', theme => { stepName: 'Form Header', subStepName: 'Container 2 - header', }); + + // funnelSubStepStart - Expandable Section 1 + expect(funnelLog[6].props).toEqual({ + stepNameSelector: expect.any(String), + subStepNameSelector: expect.any(String), + subStepAllSelector: expect.any(String), + subStepSelector: expect.any(String), + funnelInteractionId: FUNNEL_INTERACTION_ID, + funnelIdentifier: FUNNEL_IDENTIFIER, + stepIdentifier: STEP_IDENTIFIER, + subStepIdentifier: 'expandable-section-1', + stepName: 'Form Header', + stepNumber: 1, + subStepName: 'Expandable Section 1 - Header', + subStepNumber: 3, + }); + + expect(funnelLog[6].resolvedProps).toEqual({ + subStepAllElements: expect.any(Object), + subStepElement: expect.any(Object), + stepName: 'Form Header', + subStepName: 'Expandable Section 1 - Header', + }); }) ); @@ -238,7 +263,7 @@ describe.each(['refresh', 'refresh-toolbar'] as Theme[])('%s', theme => { stepIdentifier: STEP_IDENTIFIER, stepName: 'Form Header', stepNumber: 1, - totalSubSteps: 2, + totalSubSteps: 3, }); expect(funnelStepCompleteEvent.resolvedProps).toEqual({ stepName: 'Form Header',