mirror of
https://github.com/foss42/apidash.git
synced 2025-12-10 07:08:08 +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_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";
|
||||
@@ -19,9 +23,8 @@ void main() async {
|
||||
const unknown = "unknown";
|
||||
const expectedCurlCode = "curl --url '$testEndpoint$envVarValue'";
|
||||
|
||||
await ApidashTestHelper.initialize(
|
||||
size: Size(kExpandedWindowWidth, kMinWindowSize.height));
|
||||
apidashWidgetTest("Testing Environment Manager in desktop end-to-end",
|
||||
apidashWidgetTest(
|
||||
"Testing Environment Manager in desktop end-to-end", kExpandedWindowWidth,
|
||||
(WidgetTester tester, helper) async {
|
||||
await tester.pumpUntilFound(find.byType(DashApp));
|
||||
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:apidash/app.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_helper.dart';
|
||||
|
||||
void main() async {
|
||||
await ApidashTestHelper.initialize(
|
||||
size: Size(kExpandedWindowWidth, kMinWindowSize.height));
|
||||
apidashWidgetTest("Testing History of Requests in desktop end-to-end",
|
||||
Future<void> main() async {
|
||||
await runDesktopHisIntegrationTest();
|
||||
}
|
||||
|
||||
Future<void> runDesktopHisIntegrationTest() async {
|
||||
apidashWidgetTest(
|
||||
"Testing History of Requests in desktop end-to-end", kExpandedWindowWidth,
|
||||
(WidgetTester tester, helper) async {
|
||||
await tester.pumpUntilFound(find.byType(DashApp));
|
||||
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:spot/spot.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_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";
|
||||
@@ -19,9 +22,8 @@ void main() async {
|
||||
"data": "870K"
|
||||
}''';
|
||||
|
||||
await ApidashTestHelper.initialize(
|
||||
size: Size(kExpandedWindowWidth, kMinWindowSize.height));
|
||||
apidashWidgetTest("Testing Request Editor in desktop end-to-end",
|
||||
apidashWidgetTest(
|
||||
"Testing Request Editor in desktop end-to-end", kExpandedWindowWidth,
|
||||
(WidgetTester tester, helper) async {
|
||||
await tester.pumpUntilFound(find.byType(DashApp));
|
||||
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_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";
|
||||
@@ -20,9 +24,8 @@ void main() async {
|
||||
const unknown = "unknown";
|
||||
const expectedCurlCode = "curl --url '$testEndpoint$envVarValue'";
|
||||
|
||||
await ApidashTestHelper.initialize(
|
||||
size: Size(kCompactWindowWidth, kMinWindowSize.height));
|
||||
apidashWidgetTest("Testing Environment Manager in mobile end-to-end",
|
||||
apidashWidgetTest(
|
||||
"Testing Environment Manager in mobile end-to-end", kCompactWindowWidth,
|
||||
(WidgetTester tester, helper) async {
|
||||
await tester.pumpUntilFound(find.byType(DashApp));
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
@@ -73,13 +76,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 +127,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));
|
||||
});
|
||||
|
||||
@@ -8,10 +8,13 @@ import 'package:apidash/screens/history/history_widgets/history_widgets.dart';
|
||||
import '../../test/extensions/widget_tester_extensions.dart';
|
||||
import '../test_helper.dart';
|
||||
|
||||
void main() async {
|
||||
await ApidashTestHelper.initialize(
|
||||
size: Size(kCompactWindowWidth, kMinWindowSize.height));
|
||||
apidashWidgetTest("Testing History of Requests in mobile end-to-end",
|
||||
Future<void> main() async {
|
||||
await runMobileHisIntegrationTest();
|
||||
}
|
||||
|
||||
Future<void> runMobileHisIntegrationTest() async {
|
||||
apidashWidgetTest(
|
||||
"Testing History of Requests in mobile end-to-end", kCompactWindowWidth,
|
||||
(WidgetTester tester, helper) async {
|
||||
await tester.pumpUntilFound(find.byType(DashApp));
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
@@ -25,7 +28,6 @@ void main() async {
|
||||
);
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
await helper.reqHelper.sendRequest();
|
||||
await helper.reqHelper.sendRequest();
|
||||
|
||||
/// Navigate to History
|
||||
await helper.navigateToHistory(scaffoldKey: kHomeScaffoldKey);
|
||||
|
||||
@@ -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";
|
||||
@@ -19,9 +23,8 @@ void main() async {
|
||||
"data": "870K"
|
||||
}''';
|
||||
|
||||
await ApidashTestHelper.initialize(
|
||||
size: Size(kCompactWindowWidth, kMinWindowSize.height));
|
||||
apidashWidgetTest("Testing Request Editor in mobile end-to-end",
|
||||
apidashWidgetTest(
|
||||
"Testing Request Editor in mobile end-to-end", kCompactWindowWidth,
|
||||
(WidgetTester tester, helper) async {
|
||||
await tester.pumpUntilFound(find.byType(DashApp));
|
||||
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
|
||||
void apidashWidgetTest(
|
||||
String description,
|
||||
double? width,
|
||||
Future<void> Function(WidgetTester, ApidashTestHelper) test,
|
||||
) {
|
||||
testWidgets(
|
||||
description,
|
||||
(widgetTester) async {
|
||||
await ApidashTestHelper.initialize(
|
||||
size: width != null ? Size(width, kMinWindowSize.height) : null);
|
||||
await ApidashTestHelper.loadApp(widgetTester);
|
||||
await test(widgetTester, ApidashTestHelper(widgetTester));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user