Skip to content

fix: e2e CI jobs #549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ jobs:
- setup_flutter
- android/start-emulator-and-run-tests:
run-tests-working-directory: e2e
additional-avd-args: --device 3
additional-avd-args: --device 25
system-image: system-images;android-33;default;x86_64
post-emulator-launch-assemble-command: cd packages/instabug_flutter/example && flutter build apk --debug
test-command: dotnet test
Expand Down
86 changes: 59 additions & 27 deletions e2e/BugReportingTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Drawing;
using E2E.Utils;
using Xunit;
using Instabug.Captain;

using NoSuchElementException = OpenQA.Selenium.NoSuchElementException;
using System.Drawing;

namespace E2E;

Expand Down Expand Up @@ -46,6 +46,9 @@ public void ReportABug()
[Fact]
public void FloatingButtonInvocationEvent()
{

Console.WriteLine("FloatingButtonInvocationEvent");

captain.FindById(
android: "instabug_floating_button",
ios: "IBGFloatingButtonAccessibilityIdentifier"
Expand All @@ -57,11 +60,13 @@ public void FloatingButtonInvocationEvent()
[Fact]
public void ShakeInvocationEvent()
{

Console.WriteLine("ShakeInvocationEvent");

if (!Platform.IsIOS) return;


ScrollUp();
captain.FindByText("Shake").Tap();
captain.FindByTextScroll("Shake").Tap();

captain.Shake();

Expand All @@ -71,10 +76,12 @@ public void ShakeInvocationEvent()
[Fact]
public void TwoFingersSwipeLeftInvocationEvent()
{
if (!Platform.IsIOS){
ScrollUp();
}
captain.FindByText("Two Fingers Swipe Left").Tap();

Console.WriteLine("TwoFingersSwipeLeftInvocationEvent");



captain.FindByTextScroll("Two Fingers Swipe Left").Tap();

Thread.Sleep(500);

Expand All @@ -93,7 +100,11 @@ public void TwoFingersSwipeLeftInvocationEvent()
[Fact]
public void NoneInvocationEvent()
{
captain.FindByText("None").Tap();

Console.WriteLine("NoneInvocationEvent");


captain.FindByTextScroll("None").Tap();

captain.WaitForAssertion(() =>
Assert.Throws<NoSuchElementException>(() =>
Expand All @@ -109,22 +120,38 @@ public void NoneInvocationEvent()
[Fact]
public void ManualInvocation()
{
captain.FindByText("Invoke").Tap();


Console.WriteLine("ManualInvocation");



captain.FindByTextScroll("Invoke").Tap();

AssertOptionsPromptIsDisplayed();
}

[Fact]
public void MultipleScreenshotsInReproSteps()
{
Dispose();
ScrollDownLittle();
captain.FindByText("Enter screen name").Tap();


Console.WriteLine("MultipleScreenshotsInReproSteps");




captain.FindByTextScroll("Enter screen name").Tap();
captain.Type("My Screen");
captain.HideKeyboard();

captain.FindByText("Report Screen Change").Tap();
captain.FindByText("Send Bug Report").Tap();
captain.HideKeyboard();
Thread.Sleep(500);

captain.FindByTextScroll("Report Screen Change")?.Tap();
Thread.Sleep(500);
captain.FindByTextScroll("Send Bug Report")?.Tap();

captain.FindById(
android: "instabug_text_view_repro_steps_disclaimer",
ios: "IBGBugVCReproStepsDisclaimerAccessibilityIdentifier"
Expand All @@ -140,27 +167,30 @@ public void MultipleScreenshotsInReproSteps()
[Fact(Skip = "The test is flaky on iOS so we're skipping it to unblock the v13.2.0 release")]
public void ChangeReportTypes()
{
ScrollUp();
captain.FindByText("Bug", exact: true).Tap();

Console.WriteLine("ChangeReportTypes");


captain.FindByTextScroll("Bug", exact: true).Tap();

if (Platform.IsAndroid)
{
captain.FindByText("Invoke").Tap();
captain.FindByTextScroll("Invoke").Tap();

// Shows bug reporting screen
Assert.True(captain.FindById("ib_bug_scroll_view").Displayed);

// Close bug reporting screen
captain.GoBack();
captain.FindByText("DISCARD").Tap();
captain.FindByTextScroll("DISCARD").Tap();

Thread.Sleep(500);

}

captain.FindByText("Feedback").Tap();
captain.FindByTextScroll("Feedback").Tap();

captain.FindByText("Invoke").Tap();
captain.FindByTextScroll("Invoke").Tap();

// Shows both bug reporting and feature requests in prompt options
AssertOptionsPromptIsDisplayed();
Expand All @@ -173,10 +203,12 @@ public void ChangeReportTypes()
[Fact]
public void ChangeFloatingButtonEdge()
{
ScrollDown();
captain.FindByText("Move Floating Button to Left").Tap();

Thread.Sleep(500);
Console.WriteLine("ChangeFloatingButtonEdge");


captain.FindByTextScroll("Move Floating Button to Left",false,false)?.Tap();


captain.WaitForAssertion(() =>
{
Expand All @@ -193,16 +225,16 @@ public void ChangeFloatingButtonEdge()
[Fact]
public void OnDismissCallbackIsCalled()
{
ScrollDownLittle();

captain.FindByText("Set On Dismiss Callback").Tap();
captain.FindByText("Invoke").Tap();
captain.FindByTextScroll("Set On Dismiss Callback",false,false).Tap();
captain.FindByTextScroll("Invoke",false,false).Tap();

AssertOptionsPromptIsDisplayed();

captain.FindByText("Cancel").Tap();
captain.FindByTextScroll("Cancel").Tap();

var popUpText = captain.FindByText("onDismiss callback called with DismissType.cancel and ReportType.other");
Assert.True(popUpText.Displayed);

}
}
6 changes: 3 additions & 3 deletions e2e/FeatureRequestsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public class FeatureRequestsTests : CaptainTest
[Fact]
public void ShowFeatureRequetsScreen()
{
ScrollDown();
ScrollDown();

captain.FindByText("Show Feature Requests").Tap();
Console.WriteLine("ShowFeatureRequetsScreen");

captain.FindByTextScroll("Show Feature Requests",false,false).Tap();

var screenTitle = captain.FindById(
android: "ib_fr_toolbar_main",
Expand Down
11 changes: 3 additions & 8 deletions e2e/InstabugTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@ public class InstabugTests : CaptainTest
[Fact]
public void ChangePrimaryColor()
{
ScrollUp();
ScrollUp();
ScrollUp();
ScrollUp();
ScrollUp();
ScrollUp();
Console.WriteLine("ChangePrimaryColor");

var color = "#FF0000";
var expected = Color.FromArgb(255, 0, 0);

captain.FindByText("Enter primary color").Tap();
captain.FindByTextScroll("Enter primary color").Tap();
captain.Type(color);
captain.HideKeyboard();

captain.FindByText("Change Primary Color").Tap();
captain.FindByTextScroll("Change Primary Color").Tap();

captain.WaitForAssertion(() =>
{
Expand Down
5 changes: 3 additions & 2 deletions e2e/SurveysTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ public class SurveysTests : CaptainTest
[Fact]
public void ShowManualSurvey()
{
ScrollDownLittle();
captain.FindByText("Show Manual Survey").Tap();
Console.WriteLine("ShowManualSurvey");

captain.FindByTextScroll("Show Manual Survey",false,false).Tap();

captain.WaitForAssertion(() =>
{
Expand Down
26 changes: 3 additions & 23 deletions e2e/Utils/CaptainTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Drawing;
using Instabug.Captain;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.MultiTouch;

namespace E2E.Utils;

Expand All @@ -10,6 +12,7 @@ public class CaptainTest : IDisposable
AndroidApp = Path.GetFullPath("../../../../packages/instabug_flutter/example/build/app/outputs/flutter-apk/app-debug.apk"),
AndroidAppId = "com.instabug.flutter.example",
AndroidVersion = "13",

IosApp = Path.GetFullPath("../../../../packages/instabug_flutter/example/build/ios/iphonesimulator/Runner.app"),
IosAppId = "com.instabug.InstabugSample",
IosVersion = "17.2",
Expand All @@ -28,28 +31,5 @@ public void Dispose()
captain.RestartApp();
}

protected void ScrollDown()
{
captain.Swipe(
start: new Point(captain.Window.Size.Width / 2, captain.Window.Size.Height - 200),
end: new Point(captain.Window.Size.Width / 2, 300)
);
}


protected void ScrollDownLittle()
{
captain.Swipe(
start: new Point(captain.Window.Size.Width / 2, captain.Window.Size.Height - 200),
end: new Point(captain.Window.Size.Width / 2, captain.Window.Size.Height - 250)
);
}

protected void ScrollUp()
{
captain.Swipe(
start: new Point(captain.Window.Size.Width / 2, 300),
end: new Point(captain.Window.Size.Width / 2, captain.Window.Size.Height - 200)
);
}
}
2 changes: 1 addition & 1 deletion packages/instabug_flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ android {
}

dependencies {
api 'com.instabug.library:instabug:14.2.0.6611053-SNAPSHOT'
api 'com.instabug.library:instabug:14.2.0.6611388-SNAPSHOT'

testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-inline:3.12.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = com.instabug.InstabugSample2;
PRODUCT_BUNDLE_IDENTIFIER = com.instabug.InstabugSample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -706,7 +706,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = com.instabug.InstabugSample2;
PRODUCT_BUNDLE_IDENTIFIER = com.instabug.InstabugSample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down Expand Up @@ -738,7 +738,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = com.instabug.InstabugSample2;
PRODUCT_BUNDLE_IDENTIFIER = com.instabug.InstabugSample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
3 changes: 3 additions & 0 deletions packages/instabug_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ void main() {
debugLogsLevel: LogLevel.none,
);

Instabug.setWelcomeMessageMode(WelcomeMessageMode.disabled);


FlutterError.onError = (FlutterErrorDetails details) {
Zone.current.handleUncaughtError(details.exception, details.stack!);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,23 @@ private void processScreenshot(ScreenshotResult result, AtomicReference<List<Dou

@VisibleForTesting
public void maskPrivateViews(ScreenshotResult result, List<Double> privateViews) {
if (privateViews == null || privateViews.isEmpty()) return;

Bitmap bitmap = result.getScreenshot();
float pixelRatio = result.getPixelRatio();
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(); // Default color is black

for (int i = 0; i < privateViews.size(); i += 4) {
float left = privateViews.get(i).floatValue() * pixelRatio;
float top = privateViews.get(i + 1).floatValue() * pixelRatio;
float right = privateViews.get(i + 2).floatValue() * pixelRatio;
float bottom = privateViews.get(i + 3).floatValue() * pixelRatio;
canvas.drawRect(left, top, right, bottom, paint); // Mask private view
try {
if (privateViews == null || privateViews.isEmpty()) return;

Bitmap bitmap = result.getScreenshot();
float pixelRatio = result.getPixelRatio();
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(); // Default color is black

for (int i = 0; i < privateViews.size(); i += 4) {
float left = privateViews.get(i).floatValue() * pixelRatio;
float top = privateViews.get(i + 1).floatValue() * pixelRatio;
float right = privateViews.get(i + 2).floatValue() * pixelRatio;
float bottom = privateViews.get(i + 3).floatValue() * pixelRatio;
canvas.drawRect(left, top, right, bottom, paint); // Mask private view
}
} catch (Exception e){
e.printStackTrace();
}
}
}
2 changes: 1 addition & 1 deletion packages/instabug_private_views/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void main() {
};

enableInstabugMaskingPrivateViews();
runApp(const PrivateViewPage());
runApp(const InstabugUserSteps(child:PrivateViewPage()));
},
CrashReporting.reportCrash,
);
Expand Down
Loading