Skip to content

Commit

Permalink
Fix test events not being loaded (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-selo authored Aug 9, 2024
1 parent 7eb4eef commit 2395b39
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 98 deletions.
89 changes: 47 additions & 42 deletions frontend/lib/ui/artefact_page/test_event_log_expandable.dart
Original file line number Diff line number Diff line change
@@ -1,74 +1,79 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:yaru/yaru.dart';

import '../../models/test_event.dart';
import '../../providers/test_events.dart';
import '../expandable.dart';

class TestEventLogExpandable extends ConsumerWidget {
const TestEventLogExpandable({
super.key,
required this.testExecutionId,
required this.initiallyExpanded,
required this.testEvents,
});

final int testExecutionId;
final bool initiallyExpanded;
final List<TestEvent> testEvents;

@override
Widget build(BuildContext context, WidgetRef ref) {
final testEvents = ref.watch(testEventsProvider(testExecutionId));

return Expandable(
title: const Text('Event Log'),
initiallyExpanded: initiallyExpanded,
children: <Widget>[
DataTable(
columns: const <DataColumn>[
DataColumn(
label: Expanded(
child: Text(
'Event Name',
style: TextStyle(fontStyle: FontStyle.italic),
testEvents.when(
loading: () => const Center(child: YaruCircularProgressIndicator()),
error: (error, stackTrace) => Center(child: Text('Error: $error')),
data: (testEvents) => DataTable(
columns: const <DataColumn>[
DataColumn(
label: Expanded(
child: Text(
'Event Name',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
),
),
DataColumn(
label: Expanded(
child: Text(
'Timestamp',
style: TextStyle(fontStyle: FontStyle.italic),
DataColumn(
label: Expanded(
child: Text(
'Timestamp',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
),
),
DataColumn(
label: Expanded(
child: Text(
'Detail',
style: TextStyle(fontStyle: FontStyle.italic),
DataColumn(
label: Expanded(
child: Text(
'Detail',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
),
),
],
rows: testEvents
.map(
(testEvent) => DataRow(
cells: <DataCell>[
DataCell(Text(testEvent.eventName)),
DataCell(Text(testEvent.timestamp)),
DataCell(
Tooltip(
message: testEvent.detail,
child: Text(
testEvent.detail,
overflow: TextOverflow.ellipsis,
maxLines: 1,
],
rows: testEvents
.map(
(testEvent) => DataRow(
cells: <DataCell>[
DataCell(Text(testEvent.eventName)),
DataCell(Text(testEvent.timestamp)),
DataCell(
Tooltip(
message: testEvent.detail,
child: Text(
testEvent.detail,
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
),
),
),
],
),
)
.toList(),
],
),
)
.toList(),
),
),
],
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../../models/test_event.dart';
import '../../../models/test_execution.dart';
import '../../../models/test_result.dart';
// import '../../../providers/test_events.dart';
// import '../../../providers/test_results.dart';
import '../../expandable.dart';
import '../../inline_url_text.dart';
import '../../spacing.dart';
Expand All @@ -21,53 +18,37 @@ class TestExecutionExpandable extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final testEvents = <TestEvent>[];
// disabled until TO can handle the load
// final testEvents =
// ref.watch(testEventsProvider(testExecution.id)).value ?? [];

return _TestResultsLoader(
testExecutionId: testExecution.id,
child: Expandable(
title: _TestExecutionTileTitle(
testExecution: testExecution,
titleAdditions: testEvents.isNotEmpty
? ' (${testEvents[testEvents.length - 1].eventName})'
: '',
return Expandable(
title: _TestExecutionTileTitle(testExecution: testExecution),
children: <Widget>[
TestEventLogExpandable(
testExecutionId: testExecution.id,
initiallyExpanded: !testExecution.status.isCompleted,
),
children: <Widget>[
TestEventLogExpandable(
testExecutionId: testExecution.id,
initiallyExpanded: !testExecution.status.isCompleted,
testEvents: testEvents,
if (testExecution.status.isCompleted)
Expandable(
title: const Text('Test Results'),
initiallyExpanded: true,
children: TestResultStatus.values
.map(
(status) => TestResultsFilterExpandable(
statusToFilterBy: status,
testExecutionId: testExecution.id,
),
)
.toList(),
),
if (testExecution.status.isCompleted)
Expandable(
title: const Text('Test Results'),
initiallyExpanded: true,
children: TestResultStatus.values
.map(
(status) => TestResultsFilterExpandable(
statusToFilterBy: status,
testExecutionId: testExecution.id,
),
)
.toList(),
),
],
),
],
);
}
}

class _TestExecutionTileTitle extends StatelessWidget {
const _TestExecutionTileTitle({
required this.testExecution,
required this.titleAdditions,
});

final TestExecution testExecution;
final String titleAdditions;

@override
Widget build(BuildContext context) {
Expand All @@ -84,7 +65,7 @@ class _TestExecutionTileTitle extends StatelessWidget {
),
const SizedBox(width: Spacing.level4),
Text(
testExecution.environment.name + titleAdditions,
testExecution.environment.name,
style: Theme.of(context).textTheme.titleLarge,
),
const Spacer(),
Expand All @@ -107,20 +88,3 @@ class _TestExecutionTileTitle extends StatelessWidget {
);
}
}

class _TestResultsLoader extends ConsumerWidget {
const _TestResultsLoader({
required this.testExecutionId,
required this.child,
});

final int testExecutionId;
final Widget child;

@override
Widget build(BuildContext context, WidgetRef ref) {
// disabled until TO api can handle the load
// ref.watch(testResultsProvider(testExecutionId));
return child;
}
}

0 comments on commit 2395b39

Please sign in to comment.