Skip to content
Merged
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
12 changes: 6 additions & 6 deletions poc/flutter-poc/lib/poc_simulation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ bool isPocSessionDeadStop({
required List<String> sessionDeadAuthIds,
}) {
if (result.status != 'AUTH') return false;
final isSessionDead = sessionDeadAuthIds.any(
(id) => step is PocSimHostStep && step.auth == id,
);
final isSessionDead =
step is PocSimHostStep && sessionDeadAuthIds.contains(step.auth);
final detail = result.detail ?? '';
return isSessionDead &&
(detail.contains('invalid_grant') ||
Expand Down Expand Up @@ -199,10 +198,11 @@ PocSimStep? _parseStep(Map<String, dynamic> m) {
Future<PocSimStepResult> runPocSimStep(
MorphClient morph,
PocSimulationConfig cfg,
PocSimStep step,
) async {
PocSimStep step, [
http.Client? httpClient,
]) async {
return switch (step) {
PocSimFetchStep s => _runFetch(s, cfg.mockApiBaseUrl),
PocSimFetchStep s => _runFetch(s, cfg.mockApiBaseUrl, httpClient),
PocSimHostStep s => _runHost(morph, s),
PocSimLogoutStep s => _runLogout(morph, s),
};
Expand Down
10 changes: 9 additions & 1 deletion poc/flutter-poc/lib/widgets/simulation_panel.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:morph_core/morph_core.dart';

import '../poc_simulation.dart';
Expand All @@ -24,6 +25,13 @@ class _SimulationPanelState extends State<SimulationPanel> {
bool _probe404Enabled = false;
final List<PocSimStepResult> _results = [];
String _sessionDeadMessage = '';
final http.Client _httpClient = http.Client();

@override
void dispose() {
_httpClient.close();
super.dispose();
}

List<PocSimStep> get _autoSteps => widget.cfg.steps
.where((s) =>
Expand All @@ -47,7 +55,7 @@ class _SimulationPanelState extends State<SimulationPanel> {

for (final step in _autoSteps) {
if (!mounted) break;
final result = await runPocSimStep(widget.morph, widget.cfg, step);
final result = await runPocSimStep(widget.morph, widget.cfg, step, _httpClient);

if (!mounted) break;
setState(() => _results.add(result));
Expand Down
Loading