Skip to content
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

allow-custom-id #5

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion lib/src/integration_test/browser_stack_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class BrowserStackApi {
required String url,
required File file,
required String basicAuthHeader,
Map<String, String> fields = const <String, String>{},
}) async {
final filename = file.path.split("/").last;

Expand Down Expand Up @@ -39,7 +40,8 @@ class BrowserStackApi {
},
)
..headers[HttpHeaders.authorizationHeader] = basicAuthHeader
..files.add(await http.MultipartFile.fromPath("file", file.path));
..files.add(await http.MultipartFile.fromPath("file", file.path))
..fields.addAll(fields);

final response = await http.Response.fromStream(await request.send());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class IntegrationTestAndroidOption with _$IntegrationTestAndroidOption {
required String browserstackAccessKey,
required File apk,
required File testSuite,
String? customId,
required List<String> devices,
@Default(true) bool networkLogs,
@Default(true) bool deviceLogs,
Expand All @@ -33,7 +34,8 @@ class IntegrationTestAndroidOption with _$IntegrationTestAndroidOption {
..addOption(
IntegrationTestParameter.devicesParam,
defaultsTo: "Samsung Galaxy S22-12.0",
);
)
..addOption(IntegrationTestParameter.customIdParam);

final argResults = parser.parse(arguments);

Expand All @@ -57,6 +59,7 @@ class IntegrationTestAndroidOption with _$IntegrationTestAndroidOption {
browserstackAccessKey:
argResults[IntegrationTestParameter.browserstackAccessKeyParam]
as String,
customId: argResults[IntegrationTestParameter.customIdParam],
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mixin _$IntegrationTestAndroidOption {
String get browserstackAccessKey => throw _privateConstructorUsedError;
File get apk => throw _privateConstructorUsedError;
File get testSuite => throw _privateConstructorUsedError;
String? get customId => throw _privateConstructorUsedError;
List<String> get devices => throw _privateConstructorUsedError;
bool get networkLogs => throw _privateConstructorUsedError;
bool get deviceLogs => throw _privateConstructorUsedError;
Expand All @@ -42,6 +43,7 @@ abstract class $IntegrationTestAndroidOptionCopyWith<$Res> {
String browserstackAccessKey,
File apk,
File testSuite,
String? customId,
List<String> devices,
bool networkLogs,
bool deviceLogs});
Expand All @@ -65,6 +67,7 @@ class _$IntegrationTestAndroidOptionCopyWithImpl<$Res,
Object? browserstackAccessKey = null,
Object? apk = null,
Object? testSuite = null,
Object? customId = freezed,
Object? devices = null,
Object? networkLogs = null,
Object? deviceLogs = null,
Expand All @@ -86,6 +89,10 @@ class _$IntegrationTestAndroidOptionCopyWithImpl<$Res,
? _value.testSuite
: testSuite // ignore: cast_nullable_to_non_nullable
as File,
customId: freezed == customId
? _value.customId
: customId // ignore: cast_nullable_to_non_nullable
as String?,
devices: null == devices
? _value.devices
: devices // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -116,6 +123,7 @@ abstract class _$$IntegrationTestAndroidOptionImplCopyWith<$Res>
String browserstackAccessKey,
File apk,
File testSuite,
String? customId,
List<String> devices,
bool networkLogs,
bool deviceLogs});
Expand All @@ -138,6 +146,7 @@ class __$$IntegrationTestAndroidOptionImplCopyWithImpl<$Res>
Object? browserstackAccessKey = null,
Object? apk = null,
Object? testSuite = null,
Object? customId = freezed,
Object? devices = null,
Object? networkLogs = null,
Object? deviceLogs = null,
Expand All @@ -159,6 +168,10 @@ class __$$IntegrationTestAndroidOptionImplCopyWithImpl<$Res>
? _value.testSuite
: testSuite // ignore: cast_nullable_to_non_nullable
as File,
customId: freezed == customId
? _value.customId
: customId // ignore: cast_nullable_to_non_nullable
as String?,
devices: null == devices
? _value._devices
: devices // ignore: cast_nullable_to_non_nullable
Expand All @@ -183,6 +196,7 @@ class _$IntegrationTestAndroidOptionImpl extends _IntegrationTestAndroidOption {
required this.browserstackAccessKey,
required this.apk,
required this.testSuite,
this.customId,
required final List<String> devices,
this.networkLogs = true,
this.deviceLogs = true})
Expand All @@ -197,6 +211,8 @@ class _$IntegrationTestAndroidOptionImpl extends _IntegrationTestAndroidOption {
final File apk;
@override
final File testSuite;
@override
final String? customId;
final List<String> _devices;
@override
List<String> get devices {
Expand All @@ -214,7 +230,7 @@ class _$IntegrationTestAndroidOptionImpl extends _IntegrationTestAndroidOption {

@override
String toString() {
return 'IntegrationTestAndroidOption(browserstackUsername: $browserstackUsername, browserstackAccessKey: $browserstackAccessKey, apk: $apk, testSuite: $testSuite, devices: $devices, networkLogs: $networkLogs, deviceLogs: $deviceLogs)';
return 'IntegrationTestAndroidOption(browserstackUsername: $browserstackUsername, browserstackAccessKey: $browserstackAccessKey, apk: $apk, testSuite: $testSuite, customId: $customId, devices: $devices, networkLogs: $networkLogs, deviceLogs: $deviceLogs)';
}

@override
Expand All @@ -229,6 +245,8 @@ class _$IntegrationTestAndroidOptionImpl extends _IntegrationTestAndroidOption {
(identical(other.apk, apk) || other.apk == apk) &&
(identical(other.testSuite, testSuite) ||
other.testSuite == testSuite) &&
(identical(other.customId, customId) ||
other.customId == customId) &&
const DeepCollectionEquality().equals(other._devices, _devices) &&
(identical(other.networkLogs, networkLogs) ||
other.networkLogs == networkLogs) &&
Expand All @@ -243,6 +261,7 @@ class _$IntegrationTestAndroidOptionImpl extends _IntegrationTestAndroidOption {
browserstackAccessKey,
apk,
testSuite,
customId,
const DeepCollectionEquality().hash(_devices),
networkLogs,
deviceLogs);
Expand All @@ -263,6 +282,7 @@ abstract class _IntegrationTestAndroidOption
required final String browserstackAccessKey,
required final File apk,
required final File testSuite,
final String? customId,
required final List<String> devices,
final bool networkLogs,
final bool deviceLogs}) = _$IntegrationTestAndroidOptionImpl;
Expand All @@ -277,6 +297,8 @@ abstract class _IntegrationTestAndroidOption
@override
File get testSuite;
@override
String? get customId;
@override
List<String> get devices;
@override
bool get networkLogs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class IntegrationTestIosOption with _$IntegrationTestIosOption {
required String browserstackUsername,
required String browserstackAccessKey,
required File testPackage,
String? customId,
required List<String> devices,
@Default(true) bool networkLogs,
@Default(true) bool deviceLogs,
Expand All @@ -30,7 +31,8 @@ class IntegrationTestIosOption with _$IntegrationTestIosOption {
..addOption(
IntegrationTestParameter.devicesParam,
defaultsTo: "iPhone 14 Plus-16",
);
)
..addOption(IntegrationTestParameter.customIdParam);

final argResults = parser.parse(arguments);

Expand All @@ -51,6 +53,7 @@ class IntegrationTestIosOption with _$IntegrationTestIosOption {
argResults[IntegrationTestParameter.browserstackAccessKeyParam]
as String,
testPackage: await fileFromRelativePath(testPackagePath),
customId: argResults[IntegrationTestParameter.customIdParam],
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mixin _$IntegrationTestIosOption {
String get browserstackUsername => throw _privateConstructorUsedError;
String get browserstackAccessKey => throw _privateConstructorUsedError;
File get testPackage => throw _privateConstructorUsedError;
String? get customId => throw _privateConstructorUsedError;
List<String> get devices => throw _privateConstructorUsedError;
bool get networkLogs => throw _privateConstructorUsedError;
bool get deviceLogs => throw _privateConstructorUsedError;
Expand All @@ -38,6 +39,7 @@ abstract class $IntegrationTestIosOptionCopyWith<$Res> {
{String browserstackUsername,
String browserstackAccessKey,
File testPackage,
String? customId,
List<String> devices,
bool networkLogs,
bool deviceLogs});
Expand All @@ -60,6 +62,7 @@ class _$IntegrationTestIosOptionCopyWithImpl<$Res,
Object? browserstackUsername = null,
Object? browserstackAccessKey = null,
Object? testPackage = null,
Object? customId = freezed,
Object? devices = null,
Object? networkLogs = null,
Object? deviceLogs = null,
Expand All @@ -77,6 +80,10 @@ class _$IntegrationTestIosOptionCopyWithImpl<$Res,
? _value.testPackage
: testPackage // ignore: cast_nullable_to_non_nullable
as File,
customId: freezed == customId
? _value.customId
: customId // ignore: cast_nullable_to_non_nullable
as String?,
devices: null == devices
? _value.devices
: devices // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -106,6 +113,7 @@ abstract class _$$IntegrationTestIosOptionImplCopyWith<$Res>
{String browserstackUsername,
String browserstackAccessKey,
File testPackage,
String? customId,
List<String> devices,
bool networkLogs,
bool deviceLogs});
Expand All @@ -127,6 +135,7 @@ class __$$IntegrationTestIosOptionImplCopyWithImpl<$Res>
Object? browserstackUsername = null,
Object? browserstackAccessKey = null,
Object? testPackage = null,
Object? customId = freezed,
Object? devices = null,
Object? networkLogs = null,
Object? deviceLogs = null,
Expand All @@ -144,6 +153,10 @@ class __$$IntegrationTestIosOptionImplCopyWithImpl<$Res>
? _value.testPackage
: testPackage // ignore: cast_nullable_to_non_nullable
as File,
customId: freezed == customId
? _value.customId
: customId // ignore: cast_nullable_to_non_nullable
as String?,
devices: null == devices
? _value._devices
: devices // ignore: cast_nullable_to_non_nullable
Expand All @@ -167,6 +180,7 @@ class _$IntegrationTestIosOptionImpl extends _IntegrationTestIosOption {
{required this.browserstackUsername,
required this.browserstackAccessKey,
required this.testPackage,
this.customId,
required final List<String> devices,
this.networkLogs = true,
this.deviceLogs = true})
Expand All @@ -179,6 +193,8 @@ class _$IntegrationTestIosOptionImpl extends _IntegrationTestIosOption {
final String browserstackAccessKey;
@override
final File testPackage;
@override
final String? customId;
final List<String> _devices;
@override
List<String> get devices {
Expand All @@ -196,7 +212,7 @@ class _$IntegrationTestIosOptionImpl extends _IntegrationTestIosOption {

@override
String toString() {
return 'IntegrationTestIosOption(browserstackUsername: $browserstackUsername, browserstackAccessKey: $browserstackAccessKey, testPackage: $testPackage, devices: $devices, networkLogs: $networkLogs, deviceLogs: $deviceLogs)';
return 'IntegrationTestIosOption(browserstackUsername: $browserstackUsername, browserstackAccessKey: $browserstackAccessKey, testPackage: $testPackage, customId: $customId, devices: $devices, networkLogs: $networkLogs, deviceLogs: $deviceLogs)';
}

@override
Expand All @@ -210,6 +226,8 @@ class _$IntegrationTestIosOptionImpl extends _IntegrationTestIosOption {
other.browserstackAccessKey == browserstackAccessKey) &&
(identical(other.testPackage, testPackage) ||
other.testPackage == testPackage) &&
(identical(other.customId, customId) ||
other.customId == customId) &&
const DeepCollectionEquality().equals(other._devices, _devices) &&
(identical(other.networkLogs, networkLogs) ||
other.networkLogs == networkLogs) &&
Expand All @@ -223,6 +241,7 @@ class _$IntegrationTestIosOptionImpl extends _IntegrationTestIosOption {
browserstackUsername,
browserstackAccessKey,
testPackage,
customId,
const DeepCollectionEquality().hash(_devices),
networkLogs,
deviceLogs);
Expand All @@ -240,6 +259,7 @@ abstract class _IntegrationTestIosOption extends IntegrationTestIosOption {
{required final String browserstackUsername,
required final String browserstackAccessKey,
required final File testPackage,
final String? customId,
required final List<String> devices,
final bool networkLogs,
final bool deviceLogs}) = _$IntegrationTestIosOptionImpl;
Expand All @@ -252,6 +272,8 @@ abstract class _IntegrationTestIosOption extends IntegrationTestIosOption {
@override
File get testPackage;
@override
String? get customId;
@override
List<String> get devices;
@override
bool get networkLogs;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class IntegrationTestParameter {
static const String browserstackAccessKeyParam = "accessKey";
static const String browserstackUserParam = "user";
static const String customIdParam = "customId";

// region android

Expand Down
3 changes: 3 additions & 0 deletions lib/src/integration_test/run_android_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Future<void> runAndroidIntegrationTest(List<String> arguments) async {
file: option.testSuite,
url:
"https://api-cloud.browserstack.com/app-automate/flutter-integration-tests/v2/android/test-suite",
fields: {
if (option.customId != null) "custom_id": option.customId!,
},
);

final testSuiteUrl = uploadTestSuiteResponse.getRequiredKey("test_suite_url");
Expand Down
3 changes: 3 additions & 0 deletions lib/src/integration_test/run_ios_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Future<void> runIosIntegrationTest(List<String> arguments) async {
"https://api-cloud.browserstack.com/app-automate/flutter-integration-tests/v2/ios/test-package",
file: option.testPackage,
basicAuthHeader: option.basicAuthValue,
fields: {
if (option.customId != null) "custom_id": option.customId!,
},
);

final testPackageUrl = uploadPackageResult.getRequiredKey("test_package_url");
Expand Down
Loading