mirror of
https://github.com/foss42/apidash.git
synced 2025-12-10 15:23:19 +08:00
Merge pull request #455 from DenserMeerkat/resolve-issue-integration-test-runner
test: common runner file for integration test
This commit is contained in:
@@ -11,7 +11,11 @@ import 'package:apidash/screens/home_page/editor_pane/url_card.dart';
|
|||||||
import '../../test/extensions/widget_tester_extensions.dart';
|
import '../../test/extensions/widget_tester_extensions.dart';
|
||||||
import '../test_helper.dart';
|
import '../test_helper.dart';
|
||||||
|
|
||||||
void main() async {
|
Future<void> main() async {
|
||||||
|
await runDesktopEnvIntegrationTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> runDesktopEnvIntegrationTest() async {
|
||||||
const environmentName = "test-env-name";
|
const environmentName = "test-env-name";
|
||||||
const envVarName = "test-env-var";
|
const envVarName = "test-env-var";
|
||||||
const envVarValue = "8700000";
|
const envVarValue = "8700000";
|
||||||
@@ -19,9 +23,8 @@ void main() async {
|
|||||||
const unknown = "unknown";
|
const unknown = "unknown";
|
||||||
const expectedCurlCode = "curl --url '$testEndpoint$envVarValue'";
|
const expectedCurlCode = "curl --url '$testEndpoint$envVarValue'";
|
||||||
|
|
||||||
await ApidashTestHelper.initialize(
|
apidashWidgetTest(
|
||||||
size: Size(kExpandedWindowWidth, kMinWindowSize.height));
|
"Testing Environment Manager in desktop end-to-end", kExpandedWindowWidth,
|
||||||
apidashWidgetTest("Testing Environment Manager in desktop end-to-end",
|
|
||||||
(WidgetTester tester, helper) async {
|
(WidgetTester tester, helper) async {
|
||||||
await tester.pumpUntilFound(find.byType(DashApp));
|
await tester.pumpUntilFound(find.byType(DashApp));
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
import 'dart:ui';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:apidash/app.dart';
|
import 'package:apidash/app.dart';
|
||||||
import 'package:apidash/consts.dart';
|
import 'package:apidash/consts.dart';
|
||||||
@@ -8,10 +5,13 @@ import 'package:apidash/widgets/widgets.dart';
|
|||||||
import '../../test/extensions/widget_tester_extensions.dart';
|
import '../../test/extensions/widget_tester_extensions.dart';
|
||||||
import '../test_helper.dart';
|
import '../test_helper.dart';
|
||||||
|
|
||||||
void main() async {
|
Future<void> main() async {
|
||||||
await ApidashTestHelper.initialize(
|
await runDesktopHisIntegrationTest();
|
||||||
size: Size(kExpandedWindowWidth, kMinWindowSize.height));
|
}
|
||||||
apidashWidgetTest("Testing History of Requests in desktop end-to-end",
|
|
||||||
|
Future<void> runDesktopHisIntegrationTest() async {
|
||||||
|
apidashWidgetTest(
|
||||||
|
"Testing History of Requests in desktop end-to-end", kExpandedWindowWidth,
|
||||||
(WidgetTester tester, helper) async {
|
(WidgetTester tester, helper) async {
|
||||||
await tester.pumpUntilFound(find.byType(DashApp));
|
await tester.pumpUntilFound(find.byType(DashApp));
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:spot/spot.dart';
|
import 'package:spot/spot.dart';
|
||||||
import 'package:apidash/app.dart';
|
import 'package:apidash/app.dart';
|
||||||
@@ -7,7 +6,11 @@ import 'package:apidash/widgets/widgets.dart';
|
|||||||
import '../../test/extensions/widget_tester_extensions.dart';
|
import '../../test/extensions/widget_tester_extensions.dart';
|
||||||
import '../test_helper.dart';
|
import '../test_helper.dart';
|
||||||
|
|
||||||
void main() async {
|
Future<void> main() async {
|
||||||
|
await runDesktopReqIntegrationTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> runDesktopReqIntegrationTest() async {
|
||||||
const reqName = "test-req-name";
|
const reqName = "test-req-name";
|
||||||
const testEndpoint = "https://api.apidash.dev/humanize/social";
|
const testEndpoint = "https://api.apidash.dev/humanize/social";
|
||||||
const paramKey = "num";
|
const paramKey = "num";
|
||||||
@@ -19,9 +22,8 @@ void main() async {
|
|||||||
"data": "870K"
|
"data": "870K"
|
||||||
}''';
|
}''';
|
||||||
|
|
||||||
await ApidashTestHelper.initialize(
|
apidashWidgetTest(
|
||||||
size: Size(kExpandedWindowWidth, kMinWindowSize.height));
|
"Testing Request Editor in desktop end-to-end", kExpandedWindowWidth,
|
||||||
apidashWidgetTest("Testing Request Editor in desktop end-to-end",
|
|
||||||
(WidgetTester tester, helper) async {
|
(WidgetTester tester, helper) async {
|
||||||
await tester.pumpUntilFound(find.byType(DashApp));
|
await tester.pumpUntilFound(find.byType(DashApp));
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
|||||||
@@ -11,7 +11,11 @@ import 'package:apidash/screens/home_page/editor_pane/url_card.dart';
|
|||||||
import '../../test/extensions/widget_tester_extensions.dart';
|
import '../../test/extensions/widget_tester_extensions.dart';
|
||||||
import '../test_helper.dart';
|
import '../test_helper.dart';
|
||||||
|
|
||||||
void main() async {
|
Future<void> main() async {
|
||||||
|
await runMobileEnvIntegrationTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> runMobileEnvIntegrationTest() async {
|
||||||
const environmentName = "test-env-name";
|
const environmentName = "test-env-name";
|
||||||
const envVarName = "test-env-var";
|
const envVarName = "test-env-var";
|
||||||
const envVarValue = "8700000";
|
const envVarValue = "8700000";
|
||||||
@@ -20,9 +24,8 @@ void main() async {
|
|||||||
const unknown = "unknown";
|
const unknown = "unknown";
|
||||||
const expectedCurlCode = "curl --url '$testEndpoint$envVarValue'";
|
const expectedCurlCode = "curl --url '$testEndpoint$envVarValue'";
|
||||||
|
|
||||||
await ApidashTestHelper.initialize(
|
apidashWidgetTest(
|
||||||
size: Size(kCompactWindowWidth, kMinWindowSize.height));
|
"Testing Environment Manager in mobile end-to-end", kCompactWindowWidth,
|
||||||
apidashWidgetTest("Testing Environment Manager in mobile end-to-end",
|
|
||||||
(WidgetTester tester, helper) async {
|
(WidgetTester tester, helper) async {
|
||||||
await tester.pumpUntilFound(find.byType(DashApp));
|
await tester.pumpUntilFound(find.byType(DashApp));
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
@@ -73,13 +76,26 @@ void main() async {
|
|||||||
addTearDown(gesture.removePointer);
|
addTearDown(gesture.removePointer);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
/// Check if environment variable is shown on hover
|
/// Check if environment variable is shown
|
||||||
await gesture.moveTo(tester.getCenter(find.descendant(
|
if (kIsMobile) {
|
||||||
of: find.byType(URLTextField),
|
// TODO: Unable to get Popover to show on mobile
|
||||||
matching: find.text('{{$envVarName}}'))));
|
// await tester.tapAt(tester.getCenter(find.descendant(
|
||||||
await tester.pumpAndSettle();
|
// of: find.byType(URLTextField),
|
||||||
expect(find.text(envVarValue), findsOneWidget);
|
// matching: find.text('{{$envVarName}}'))));
|
||||||
await gesture.moveBy(const Offset(0, 100));
|
// 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 Future.delayed(const Duration(milliseconds: 500));
|
||||||
|
|
||||||
await helper.navigateToSettings(scaffoldKey: kHomeScaffoldKey);
|
await helper.navigateToSettings(scaffoldKey: kHomeScaffoldKey);
|
||||||
@@ -111,12 +127,21 @@ void main() async {
|
|||||||
await helper.navigateToRequestEditor(scaffoldKey: kEnvScaffoldKey);
|
await helper.navigateToRequestEditor(scaffoldKey: kEnvScaffoldKey);
|
||||||
await Future.delayed(const Duration(milliseconds: 200));
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
|
|
||||||
/// Check if environment variable is now shown on hover
|
/// Check if environment variable is now shown as unknown
|
||||||
await gesture.moveTo(tester.getCenter(find.descendant(
|
if (kIsMobile) {
|
||||||
of: find.byType(URLTextField),
|
// TODO: Unable to get Popover to show on mobile
|
||||||
matching: find.text('{{$envVarName}}'))));
|
// await tester.tapAt(tester.getCenter(find.descendant(
|
||||||
await tester.pumpAndSettle();
|
// of: find.byType(URLTextField),
|
||||||
expect(find.text(unknown), findsNWidgets(2));
|
// 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));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,10 +8,13 @@ import 'package:apidash/screens/history/history_widgets/history_widgets.dart';
|
|||||||
import '../../test/extensions/widget_tester_extensions.dart';
|
import '../../test/extensions/widget_tester_extensions.dart';
|
||||||
import '../test_helper.dart';
|
import '../test_helper.dart';
|
||||||
|
|
||||||
void main() async {
|
Future<void> main() async {
|
||||||
await ApidashTestHelper.initialize(
|
await runMobileHisIntegrationTest();
|
||||||
size: Size(kCompactWindowWidth, kMinWindowSize.height));
|
}
|
||||||
apidashWidgetTest("Testing History of Requests in mobile end-to-end",
|
|
||||||
|
Future<void> runMobileHisIntegrationTest() async {
|
||||||
|
apidashWidgetTest(
|
||||||
|
"Testing History of Requests in mobile end-to-end", kCompactWindowWidth,
|
||||||
(WidgetTester tester, helper) async {
|
(WidgetTester tester, helper) async {
|
||||||
await tester.pumpUntilFound(find.byType(DashApp));
|
await tester.pumpUntilFound(find.byType(DashApp));
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
@@ -25,7 +28,6 @@ void main() async {
|
|||||||
);
|
);
|
||||||
await Future.delayed(const Duration(milliseconds: 200));
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
await helper.reqHelper.sendRequest();
|
await helper.reqHelper.sendRequest();
|
||||||
await helper.reqHelper.sendRequest();
|
|
||||||
|
|
||||||
/// Navigate to History
|
/// Navigate to History
|
||||||
await helper.navigateToHistory(scaffoldKey: kHomeScaffoldKey);
|
await helper.navigateToHistory(scaffoldKey: kHomeScaffoldKey);
|
||||||
|
|||||||
@@ -7,7 +7,11 @@ import 'package:apidash/widgets/widgets.dart';
|
|||||||
import '../../test/extensions/widget_tester_extensions.dart';
|
import '../../test/extensions/widget_tester_extensions.dart';
|
||||||
import '../test_helper.dart';
|
import '../test_helper.dart';
|
||||||
|
|
||||||
void main() async {
|
Future<void> main() async {
|
||||||
|
await runMobileReqIntegrationTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> runMobileReqIntegrationTest() async {
|
||||||
const reqName = "test-req-name";
|
const reqName = "test-req-name";
|
||||||
const testEndpoint = "https://api.apidash.dev/humanize/social";
|
const testEndpoint = "https://api.apidash.dev/humanize/social";
|
||||||
const paramKey = "num";
|
const paramKey = "num";
|
||||||
@@ -19,9 +23,8 @@ void main() async {
|
|||||||
"data": "870K"
|
"data": "870K"
|
||||||
}''';
|
}''';
|
||||||
|
|
||||||
await ApidashTestHelper.initialize(
|
apidashWidgetTest(
|
||||||
size: Size(kCompactWindowWidth, kMinWindowSize.height));
|
"Testing Request Editor in mobile end-to-end", kCompactWindowWidth,
|
||||||
apidashWidgetTest("Testing Request Editor in mobile end-to-end",
|
|
||||||
(WidgetTester tester, helper) async {
|
(WidgetTester tester, helper) async {
|
||||||
await tester.pumpUntilFound(find.byType(DashApp));
|
await tester.pumpUntilFound(find.byType(DashApp));
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
|||||||
24
integration_test/runner.dart
Normal file
24
integration_test/runner.dart
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import 'package:apidash/consts.dart';
|
||||||
|
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 (kIsMobile) {
|
||||||
|
await runMobileReqIntegrationTest();
|
||||||
|
await runMobileEnvIntegrationTest();
|
||||||
|
await runMobileHisIntegrationTest();
|
||||||
|
} else if (kIsMobile || kIsDesktop) {
|
||||||
|
await runDesktopReqIntegrationTest();
|
||||||
|
await runDesktopEnvIntegrationTest();
|
||||||
|
await runDesktopHisIntegrationTest();
|
||||||
|
await runMobileReqIntegrationTest();
|
||||||
|
await runMobileEnvIntegrationTest();
|
||||||
|
await runMobileHisIntegrationTest();
|
||||||
|
} else {
|
||||||
|
throw Exception("Unsupported Platform");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -113,11 +113,14 @@ class ApidashTestHelper {
|
|||||||
@isTest
|
@isTest
|
||||||
void apidashWidgetTest(
|
void apidashWidgetTest(
|
||||||
String description,
|
String description,
|
||||||
|
double? width,
|
||||||
Future<void> Function(WidgetTester, ApidashTestHelper) test,
|
Future<void> Function(WidgetTester, ApidashTestHelper) test,
|
||||||
) {
|
) {
|
||||||
testWidgets(
|
testWidgets(
|
||||||
description,
|
description,
|
||||||
(widgetTester) async {
|
(widgetTester) async {
|
||||||
|
await ApidashTestHelper.initialize(
|
||||||
|
size: width != null ? Size(width, kMinWindowSize.height) : null);
|
||||||
await ApidashTestHelper.loadApp(widgetTester);
|
await ApidashTestHelper.loadApp(widgetTester);
|
||||||
await test(widgetTester, ApidashTestHelper(widgetTester));
|
await test(widgetTester, ApidashTestHelper(widgetTester));
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user