test: common runner file

This commit is contained in:
DenserMeerkat
2024-08-25 21:04:45 +05:30
parent 3e3ba2a264
commit 4bb5afecb6
7 changed files with 87 additions and 19 deletions

View File

@@ -11,7 +11,11 @@ import 'package:apidash/screens/home_page/editor_pane/url_card.dart';
import '../../test/extensions/widget_tester_extensions.dart';
import '../test_helper.dart';
void main() async {
Future<void> main() async {
await runDesktopEnvIntegrationTest();
}
Future<void> runDesktopEnvIntegrationTest() async {
const environmentName = "test-env-name";
const envVarName = "test-env-var";
const envVarValue = "8700000";

View File

@@ -8,7 +8,11 @@ import 'package:apidash/widgets/widgets.dart';
import '../../test/extensions/widget_tester_extensions.dart';
import '../test_helper.dart';
void main() async {
Future<void> main() async {
await runDesktopHisIntegrationTest();
}
Future<void> runDesktopHisIntegrationTest() async {
await ApidashTestHelper.initialize(
size: Size(kExpandedWindowWidth, kMinWindowSize.height));
apidashWidgetTest("Testing History of Requests in desktop end-to-end",

View File

@@ -7,7 +7,11 @@ import 'package:apidash/widgets/widgets.dart';
import '../../test/extensions/widget_tester_extensions.dart';
import '../test_helper.dart';
void main() async {
Future<void> main() async {
await runDesktopReqIntegrationTest();
}
Future<void> runDesktopReqIntegrationTest() async {
const reqName = "test-req-name";
const testEndpoint = "https://api.apidash.dev/humanize/social";
const paramKey = "num";

View File

@@ -11,7 +11,11 @@ import 'package:apidash/screens/home_page/editor_pane/url_card.dart';
import '../../test/extensions/widget_tester_extensions.dart';
import '../test_helper.dart';
void main() async {
Future<void> main() async {
await runMobileEnvIntegrationTest();
}
Future<void> runMobileEnvIntegrationTest() async {
const environmentName = "test-env-name";
const envVarName = "test-env-var";
const envVarValue = "8700000";
@@ -73,13 +77,26 @@ void main() async {
addTearDown(gesture.removePointer);
await tester.pump();
/// Check if environment variable is shown on hover
await gesture.moveTo(tester.getCenter(find.descendant(
of: find.byType(URLTextField),
matching: find.text('{{$envVarName}}'))));
await tester.pumpAndSettle();
expect(find.text(envVarValue), findsOneWidget);
await gesture.moveBy(const Offset(0, 100));
/// Check if environment variable is shown
if (kIsMobile) {
// TODO: Unable to get Popover to show on mobile
// await tester.tapAt(tester.getCenter(find.descendant(
// of: find.byType(URLTextField),
// matching: find.text('{{$envVarName}}'))));
// await tester.pumpAndSettle();
// expect(find.text(envVarValue), findsOneWidget);
// await tester.tapAt(tester.getCenter(find.descendant(
// of: find.byType(URLTextField),
// matching: find.byType(WidgetSpan))) +
// const Offset(0, 100));
} else {
await gesture.moveTo(tester.getCenter(find.descendant(
of: find.byType(URLTextField),
matching: find.text('{{$envVarName}}'))));
await tester.pumpAndSettle();
expect(find.text(envVarValue), findsOneWidget);
await gesture.moveBy(const Offset(0, 100));
}
await Future.delayed(const Duration(milliseconds: 500));
await helper.navigateToSettings(scaffoldKey: kHomeScaffoldKey);
@@ -111,12 +128,21 @@ void main() async {
await helper.navigateToRequestEditor(scaffoldKey: kEnvScaffoldKey);
await Future.delayed(const Duration(milliseconds: 200));
/// Check if environment variable is now shown on hover
await gesture.moveTo(tester.getCenter(find.descendant(
of: find.byType(URLTextField),
matching: find.text('{{$envVarName}}'))));
await tester.pumpAndSettle();
expect(find.text(unknown), findsNWidgets(2));
/// Check if environment variable is now shown as unknown
if (kIsMobile) {
// TODO: Unable to get Popover to show on mobile
// await tester.tapAt(tester.getCenter(find.descendant(
// of: find.byType(URLTextField),
// matching: find.text('{{$envVarName}}'))));
// await tester.pumpAndSettle();
// expect(find.text(unknown), findsNWidgets(2));
} else {
await gesture.moveTo(tester.getCenter(find.descendant(
of: find.byType(URLTextField),
matching: find.text('{{$envVarName}}'))));
await tester.pumpAndSettle();
expect(find.text(unknown), findsNWidgets(2));
}
await Future.delayed(const Duration(milliseconds: 500));
});

View File

@@ -8,7 +8,11 @@ import 'package:apidash/screens/history/history_widgets/history_widgets.dart';
import '../../test/extensions/widget_tester_extensions.dart';
import '../test_helper.dart';
void main() async {
Future<void> main() async {
await runMobileHisIntegrationTest();
}
Future<void> runMobileHisIntegrationTest() async {
await ApidashTestHelper.initialize(
size: Size(kCompactWindowWidth, kMinWindowSize.height));
apidashWidgetTest("Testing History of Requests in mobile end-to-end",

View File

@@ -7,7 +7,11 @@ import 'package:apidash/widgets/widgets.dart';
import '../../test/extensions/widget_tester_extensions.dart';
import '../test_helper.dart';
void main() async {
Future<void> main() async {
await runMobileReqIntegrationTest();
}
Future<void> runMobileReqIntegrationTest() async {
const reqName = "test-req-name";
const testEndpoint = "https://api.apidash.dev/humanize/social";
const paramKey = "num";

View File

@@ -0,0 +1,22 @@
import 'dart:io';
import 'desktop/env_manager_test.dart';
import 'desktop/his_request_test.dart';
import 'desktop/req_editor_test.dart';
import 'mobile/env_manager_test.dart';
import 'mobile/his_request_test.dart';
import 'mobile/req_editor_test.dart';
Future<void> main() async {
if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) {
await runDesktopReqIntegrationTest();
await runDesktopEnvIntegrationTest();
await runDesktopHisIntegrationTest();
} else if (Platform.isAndroid || Platform.isIOS) {
await runMobileReqIntegrationTest();
await runMobileEnvIntegrationTest();
await runMobileHisIntegrationTest();
} else {
throw Exception("Unsupported Platform");
}
}