Skip to content

Commit

Permalink
Merge pull request #1165 from DataDog/nogorodnikov/fix-some-nightly-t…
Browse files Browse the repository at this point in the history
…ests-flakiness

Fix some nightly tests flakiness
  • Loading branch information
0xnm authored Nov 29, 2022
2 parents 9eb9417 + 84455e3 commit 95f8b91
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ class RumMonitorBackgroundE2ETests {
val testMethodName = "rum_rummonitor_add_background_non_custom_action_with_outcome"
val actionName = forge.anActionName()
val attributes = defaultTestAttributes(testMethodName)
// BACK has no action.name (only action.target.name), so we need to exclude it, because
// assertion is relying on action.name
val actionType = forge.aValueFrom(
RumActionType::class.java,
exclude = listOf(RumActionType.CUSTOM)
exclude = listOf(RumActionType.CUSTOM, RumActionType.BACK)
)
measure(testMethodName) {
GlobalRum.get().addUserAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ class RumMonitorE2ETests {
val viewName = forge.aViewName()
val actionName = forge.anActionName()
val attributes = defaultTestAttributes(testMethodName)
val actionType = forge.aValueFrom(RumActionType::class.java)
// BACK has no action.name (only action.target.name), so we need to exclude it, because
// assertion is relying on action.name
val actionType =
forge.aValueFrom(RumActionType::class.java, exclude = listOf(RumActionType.BACK))
executeInsideView(viewKey, viewName, testMethodName) {
measure(testMethodName) {
GlobalRum.get().startUserAction(
Expand Down Expand Up @@ -342,7 +345,9 @@ class RumMonitorE2ETests {
val viewKey = forge.aViewKey()
val viewName = forge.aViewName()
val actionName = forge.anActionName()
val type = forge.aValueFrom(RumActionType::class.java)
// BACK has no action.name (only action.target.name), so we need to exclude it, because
// assertion is relying on action.name
val type = forge.aValueFrom(RumActionType::class.java, exclude = listOf(RumActionType.BACK))
val stopActionAttributes = forge.exhaustiveAttributes()
executeInsideView(viewKey, viewName, testMethodName) {
GlobalRum.get().startUserAction(
Expand Down Expand Up @@ -419,7 +424,12 @@ class RumMonitorE2ETests {
val viewName = forge.aViewName()
val actionName = forge.anActionName()
val attributes = defaultTestAttributes(testMethodName)
val actionType = forge.aValueFrom(RumActionType::class.java)
// BACK has no action.name (only action.target.name), so we need to exclude it, because
// assertion is relying on action.name
val actionType = forge.aValueFrom(
RumActionType::class.java,
exclude = listOf(RumActionType.BACK)
)
executeInsideView(viewKey, viewName, testMethodName) {
measure(testMethodName) {
GlobalRum.get().addUserAction(
Expand All @@ -444,7 +454,12 @@ class RumMonitorE2ETests {
val viewName = forge.aViewName()
val activeActionName = forge.anActionName(prefix = "rumActiveAction")
val customActionName = forge.anActionName()
val actionType = forge.aValueFrom(RumActionType::class.java)
// BACK has no action.name (only action.target.name), so we need to exclude it, because
// assertion is relying on action.name
val actionType = forge.aValueFrom(
RumActionType::class.java,
exclude = listOf(RumActionType.BACK)
)
val attributes = defaultTestAttributes(testMethodName)
executeInsideView(viewKey, viewName, testMethodName) {
GlobalRum.get().startUserAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.datadog.android.nightly.webview

import androidx.test.core.app.ActivityScenario.launch
import androidx.test.espresso.web.model.Atoms.script
import androidx.test.espresso.web.sugar.Web.onWebView
import androidx.test.espresso.web.webdriver.DriverAtoms.findElement
import androidx.test.espresso.web.webdriver.DriverAtoms.webClick
Expand Down Expand Up @@ -102,7 +103,12 @@ internal class WebViewTrackingE2ETests {
initSdk()
launch(WebViewTrackingActivity::class.java)

onWebView().withElement(findElement(Locator.ID, "display-image")).perform(webClick())
// with https://github.com/DataDog/browser-sdk/pull/1731 pointerdown event is required
// before emitting click event for the RUM action to be registered
with(onWebView().withElement(findElement(Locator.ID, "display-image"))) {
perform(script("arguments[0].dispatchEvent(new PointerEvent('pointerdown'))"))
perform(webClick())
}
}

/**
Expand Down

0 comments on commit 95f8b91

Please sign in to comment.