mirror of
https://github.com/foss42/apidash.git
synced 2025-05-29 04:50:36 +08:00
test: his_request_test mobile
This commit is contained in:
@ -1,20 +1,19 @@
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:apidash/screens/history/history_pane.dart';
|
|
||||||
import 'package:apidash/screens/history/history_requests.dart';
|
|
||||||
import 'package:apidash/widgets/widgets.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
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';
|
||||||
import 'package:apidash/consts.dart';
|
import 'package:apidash/consts.dart';
|
||||||
|
import 'package:apidash/widgets/widgets.dart';
|
||||||
|
import 'package:apidash/screens/history/history_pane.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 {
|
void main() async {
|
||||||
await ApidashTestHelper.initialize(
|
await ApidashTestHelper.initialize(
|
||||||
size: Size(kExpandedWindowWidth, kMinWindowSize.height));
|
size: Size(kExpandedWindowWidth, kMinWindowSize.height));
|
||||||
apidashWidgetTest("Testing Environment Manager in desktop end-to-end",
|
apidashWidgetTest("Testing History of Requests 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));
|
||||||
@ -22,7 +21,7 @@ void main() async {
|
|||||||
/// Create New Request
|
/// Create New Request
|
||||||
await helper.reqHelper.addRequest(
|
await helper.reqHelper.addRequest(
|
||||||
"https://api.apidash.dev/humanize/social",
|
"https://api.apidash.dev/humanize/social",
|
||||||
name: "Social",
|
name: "test-his-name",
|
||||||
params: [("num", "870000")],
|
params: [("num", "870000")],
|
||||||
);
|
);
|
||||||
await Future.delayed(const Duration(milliseconds: 200));
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
@ -33,8 +32,7 @@ void main() async {
|
|||||||
var sidebarCards = spot<HistoryPane>().spot<SidebarHistoryCard>().finder;
|
var sidebarCards = spot<HistoryPane>().spot<SidebarHistoryCard>().finder;
|
||||||
final initSidebarCardCount =
|
final initSidebarCardCount =
|
||||||
tester.widgetList<SidebarHistoryCard>(sidebarCards).length;
|
tester.widgetList<SidebarHistoryCard>(sidebarCards).length;
|
||||||
var historyCards =
|
var historyCards = find.byType(HistoryRequestCard, skipOffstage: false);
|
||||||
spot<HistoryRequests>().spot<HistoryRequestCard>().finder;
|
|
||||||
final initHistoryCardCount =
|
final initHistoryCardCount =
|
||||||
tester.widgetList<HistoryRequestCard>(historyCards).length;
|
tester.widgetList<HistoryRequestCard>(historyCards).length;
|
||||||
|
|
||||||
@ -43,8 +41,8 @@ void main() async {
|
|||||||
await Future.delayed(const Duration(milliseconds: 200));
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
await helper.reqHelper.addRequest(
|
await helper.reqHelper.addRequest(
|
||||||
"https://api.apidash.dev/convert/leet",
|
"https://api.apidash.dev/convert/leet",
|
||||||
name: "Social",
|
name: "test-his-name",
|
||||||
params: [("text", "870000")],
|
params: [("text", "apidash")],
|
||||||
);
|
);
|
||||||
await Future.delayed(const Duration(milliseconds: 200));
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
await helper.reqHelper.sendRequest();
|
await helper.reqHelper.sendRequest();
|
||||||
@ -54,7 +52,7 @@ void main() async {
|
|||||||
sidebarCards = spot<HistoryPane>().spot<SidebarHistoryCard>().finder;
|
sidebarCards = spot<HistoryPane>().spot<SidebarHistoryCard>().finder;
|
||||||
final newSidebarCardCount =
|
final newSidebarCardCount =
|
||||||
tester.widgetList<SidebarHistoryCard>(sidebarCards).length;
|
tester.widgetList<SidebarHistoryCard>(sidebarCards).length;
|
||||||
historyCards = spot<HistoryRequests>().spot<HistoryRequestCard>().finder;
|
historyCards = find.byType(HistoryRequestCard, skipOffstage: false);
|
||||||
final newHistoryCardCount =
|
final newHistoryCardCount =
|
||||||
tester.widgetList<HistoryRequestCard>(historyCards).length;
|
tester.widgetList<HistoryRequestCard>(historyCards).length;
|
||||||
expect(newSidebarCardCount, initSidebarCardCount);
|
expect(newSidebarCardCount, initSidebarCardCount);
|
||||||
|
@ -22,7 +22,7 @@ void main() async {
|
|||||||
|
|
||||||
await ApidashTestHelper.initialize(
|
await ApidashTestHelper.initialize(
|
||||||
size: Size(kCompactWindowWidth, kMinWindowSize.height));
|
size: Size(kCompactWindowWidth, kMinWindowSize.height));
|
||||||
apidashWidgetTest("Testing Environment Manager in desktop end-to-end",
|
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));
|
||||||
|
78
integration_test/mobile/his_request_test.dart
Normal file
78
integration_test/mobile/his_request_test.dart
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:spot/spot.dart';
|
||||||
|
import 'package:apidash/app.dart';
|
||||||
|
import 'package:apidash/consts.dart';
|
||||||
|
import 'package:apidash/widgets/widgets.dart';
|
||||||
|
import 'package:apidash/screens/history/history_pane.dart';
|
||||||
|
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",
|
||||||
|
(WidgetTester tester, helper) async {
|
||||||
|
await tester.pumpUntilFound(find.byType(DashApp));
|
||||||
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
|
||||||
|
/// Create New Request
|
||||||
|
await helper.reqHelper.addRequest(
|
||||||
|
"https://api.apidash.dev/humanize/social",
|
||||||
|
name: "test-his-name",
|
||||||
|
params: [("num", "870000")],
|
||||||
|
isMobile: true,
|
||||||
|
);
|
||||||
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
|
await helper.reqHelper.sendRequest();
|
||||||
|
await helper.reqHelper.sendRequest();
|
||||||
|
|
||||||
|
/// Navigate to History
|
||||||
|
await helper.navigateToHistory(scaffoldKey: kHomeScaffoldKey);
|
||||||
|
kHisScaffoldKey.currentState!.openDrawer();
|
||||||
|
var sidebarCards = spot<HistoryPane>().spot<SidebarHistoryCard>().finder;
|
||||||
|
final initSidebarCardCount =
|
||||||
|
tester.widgetList<SidebarHistoryCard>(sidebarCards).length;
|
||||||
|
kHisScaffoldKey.currentState!.closeDrawer();
|
||||||
|
|
||||||
|
await act.tap(
|
||||||
|
spot<HistorySheetButton>().spotIcon(Icons.keyboard_arrow_up_rounded));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
var historyCards = find.byType(HistoryRequestCard, skipOffstage: false);
|
||||||
|
final initHistoryCardCount =
|
||||||
|
tester.widgetList<HistoryRequestCard>(historyCards).length;
|
||||||
|
await tester.tapAt(const Offset(100, 100));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
/// Send another request with same name
|
||||||
|
await helper.navigateToRequestEditor(scaffoldKey: kHisScaffoldKey);
|
||||||
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
|
await helper.reqHelper.addRequest(
|
||||||
|
"https://api.apidash.dev/convert/leet",
|
||||||
|
name: "test-his-name",
|
||||||
|
params: [("text", "apidash")],
|
||||||
|
isMobile: true,
|
||||||
|
);
|
||||||
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
|
await helper.reqHelper.sendRequest();
|
||||||
|
|
||||||
|
/// Check history Card counts
|
||||||
|
await helper.navigateToHistory(scaffoldKey: kHomeScaffoldKey);
|
||||||
|
sidebarCards = spot<HistoryPane>().spot<SidebarHistoryCard>().finder;
|
||||||
|
final newSidebarCardCount =
|
||||||
|
tester.widgetList<SidebarHistoryCard>(sidebarCards).length;
|
||||||
|
kHisScaffoldKey.currentState!.closeDrawer();
|
||||||
|
|
||||||
|
await act.tap(
|
||||||
|
spot<HistorySheetButton>().spotIcon(Icons.keyboard_arrow_up_rounded));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
historyCards = find.byType(HistoryRequestCard, skipOffstage: false);
|
||||||
|
final newHistoryCardCount =
|
||||||
|
tester.widgetList<HistoryRequestCard>(historyCards).length;
|
||||||
|
await tester.tapAt(const Offset(100, 100));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(newSidebarCardCount, initSidebarCardCount);
|
||||||
|
expect(newHistoryCardCount, initHistoryCardCount + 1);
|
||||||
|
});
|
||||||
|
}
|
@ -120,8 +120,8 @@ class ApidashTestRequestHelper {
|
|||||||
await setRequestMethod(method);
|
await setRequestMethod(method);
|
||||||
}
|
}
|
||||||
await addRequestURL(url);
|
await addRequestURL(url);
|
||||||
await addRequestParams(params);
|
if (params.isNotEmpty) await addRequestParams(params);
|
||||||
await addRequestHeaders(headers);
|
if (headers.isNotEmpty) await addRequestHeaders(headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> sendRequest(
|
Future<void> sendRequest(
|
||||||
|
@ -87,5 +87,6 @@ class HistoryMetaStateNotifier
|
|||||||
hiveHandler.setHistoryIds(updatedHistoryKeys);
|
hiveHandler.setHistoryIds(updatedHistoryKeys);
|
||||||
hiveHandler.setHistoryMeta(id, model.metaData.toJson());
|
hiveHandler.setHistoryMeta(id, model.metaData.toJson());
|
||||||
await hiveHandler.setHistoryRequest(id, model.toJson());
|
await hiveHandler.setHistoryRequest(id, model.toJson());
|
||||||
|
await loadHistoryRequest(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ class _HistoryDetailsState extends ConsumerState<HistoryDetails>
|
|||||||
with TickerProviderStateMixin {
|
with TickerProviderStateMixin {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
ref.watch(historySequenceProvider);
|
||||||
final selectedHistoryRequest =
|
final selectedHistoryRequest =
|
||||||
ref.watch(selectedHistoryRequestModelProvider);
|
ref.watch(selectedHistoryRequestModelProvider);
|
||||||
final codePaneVisible = ref.watch(historyCodePaneVisibleStateProvider);
|
final codePaneVisible = ref.watch(historyCodePaneVisibleStateProvider);
|
||||||
|
Reference in New Issue
Block a user