Skip to content

Commit a21a1c5

Browse files
committed
[PANA-6072] add e2e test
1 parent 651371d commit a21a1c5

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

packages/core/src/domain/telemetry/telemetryEvent.types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,11 @@ export type TelemetryConfigurationEvent = CommonTelemetryProperties & {
476476
*/
477477
beta_encode_cookie_options?: boolean
478478
[k: string]: unknown
479+
480+
/**
481+
* Whether the allowed HTML attributes list is used
482+
*/
483+
use_allowed_html_attributes?: boolean
479484
}
480485
[k: string]: unknown
481486
}

packages/rum-core/src/domain/action/trackClickActions.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,14 @@ function computeClickActionBase(
246246
const rect = target.getBoundingClientRect()
247247
const selector = getSelectorFromElement(target, configuration.actionNameAttribute)
248248

249-
const composedPathSelector = isExperimentalFeatureEnabled(ExperimentalFeature.COMPOSED_PATH_SELECTOR) && typeof event.composedPath === 'function'
250-
? getComposedPathSelector(event.composedPath(), configuration.actionNameAttribute, configuration.allowedHtmlAttributes || [])
251-
: undefined
249+
const composedPathSelector =
250+
isExperimentalFeatureEnabled(ExperimentalFeature.COMPOSED_PATH_SELECTOR) && typeof event.composedPath === 'function'
251+
? getComposedPathSelector(
252+
event.composedPath(),
253+
configuration.actionNameAttribute,
254+
configuration.allowedHtmlAttributes || []
255+
)
256+
: undefined
252257

253258
if (selector) {
254259
updateInteractionSelector(event.timeStamp, selector)

test/e2e/scenario/rum/actions.scenario.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,3 +781,42 @@ test.describe('custom actions with startAction/stopAction', () => {
781781
expect(relatedFetch).toBeDefined()
782782
})
783783
})
784+
785+
test.describe('action collection with composed path selector', () => {
786+
createTest('should not return a composed_path_selector if flag is disabled')
787+
.withRum({ trackUserInteractions: true })
788+
.withBody(html`
789+
<button>Click</button>
790+
<button id="my-button" data-test-allowed="test-btn" data-random="secret" class="foo bar baz">Click me</button>
791+
`)
792+
.run(async ({ intakeRegistry, flushEvents, page }) => {
793+
const button = page.locator('#my-button')
794+
await button.click()
795+
await flushEvents()
796+
797+
const actionEvents = intakeRegistry.rumActionEvents
798+
expect(actionEvents).toHaveLength(1)
799+
expect(actionEvents[0]._dd.action?.target?.composed_path_selector).toBeUndefined()
800+
})
801+
createTest('should return a composed_path_selector if flag is enabled')
802+
.withRum({
803+
trackUserInteractions: true,
804+
enableExperimentalFeatures: ['composed_path_selector'],
805+
allowedHtmlAttributes: ['data-test-allowed'],
806+
})
807+
.withBody(html`
808+
<button>Click</button>
809+
<button id="my-button" data-test-allowed="test-btn" data-random="secret" class="foo bar baz">Click me</button>
810+
`)
811+
.run(async ({ intakeRegistry, flushEvents, page }) => {
812+
const button = page.locator('#my-button')
813+
await button.click()
814+
await flushEvents()
815+
816+
const actionEvents = intakeRegistry.rumActionEvents
817+
expect(actionEvents).toHaveLength(1)
818+
expect(actionEvents[0]._dd.action?.target?.composed_path_selector).toBe(
819+
'BUTTON#my-button[data-test-allowed="test-btn"].bar.baz.foo:nth-child(2):nth-of-type(2);'
820+
)
821+
})
822+
})

0 commit comments

Comments
 (0)