Skip to content

Commit

Permalink
[dashboard] Merge columns for luci and cocoon tasks (#1587)
Browse files Browse the repository at this point in the history
  • Loading branch information
Casey Hillers authored Feb 4, 2022
1 parent f2b3126 commit b8130a3
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
14 changes: 13 additions & 1 deletion dashboard/lib/logic/qualified_task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,23 @@ class QualifiedTask {
if (other.runtimeType != runtimeType) {
return false;
}

if (isLuci) {
return other is QualifiedTask && other.task == task;
}

return other is QualifiedTask && other.stage == stage && other.task == task;
}

@override
int get hashCode => stage.hashCode ^ task.hashCode;
int get hashCode {
// Ensure tasks from Cocoon or LUCI share the same columns.
if (isLuci) {
return StageName.cocoon.hashCode ^ task.hashCode;
}

return stage.hashCode ^ task.hashCode;
}
}

/// Get the URL for [Task] to view its log.
Expand Down
57 changes: 57 additions & 0 deletions dashboard/test/widgets/task_grid_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'dart:typed_data';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_dashboard/logic/qualified_task.dart';
import 'package:flutter_dashboard/logic/task_grid_filter.dart';
import 'package:flutter_dashboard/model/commit.pb.dart';
import 'package:flutter_dashboard/model/commit_status.pb.dart';
Expand Down Expand Up @@ -338,6 +339,62 @@ void main() {
await expectGoldenMatches(find.byType(TaskGrid), 'task_grid_test.withSkips.png');
});

testWidgets('Cocoon and LUCI tasks share the same column', (WidgetTester tester) async {
await precacheTaskIcons(tester);
// Matrix Diagram:
//
// ✓
// ✓
//
// To construct the matrix from this diagram, each [CommitStatus] will have a [Task]
// that shares its name, but will have a different stage name.

final List<CommitStatus> statuses = <CommitStatus>[
CommitStatus()
..commit = (Commit()..author = 'Author')
..tasks.addAll(
<Task>[
Task()
..stageName = StageName.cocoon
..name = '1'
..builderName = '1'
..status = TaskBox.statusSucceeded
],
),
CommitStatus()
..commit = (Commit()..author = 'Author')
..tasks.addAll(
<Task>[
Task()
..stageName = StageName.luci
..name = '1'
..builderName = '1'
..status = TaskBox.statusSucceeded
],
),
];

await tester.pumpWidget(
MaterialApp(
home: Material(
child: TaskGrid(
buildState: FakeBuildState(),
commitStatuses: statuses,
),
),
),
);

expect(find.byType(LatticeScrollView), findsOneWidget);
final LatticeScrollView lattice = find.byType(LatticeScrollView).evaluate().first.widget;

// Rows (task icon, two commits, load more row)
expect(lattice.cells.length, 4);
// Columns (commit box, task)
expect(lattice.cells.first.length, 2);
expect(lattice.cells[1].length, 2);
});

testWidgets('TaskGrid creates a task icon row and they line up', (WidgetTester tester) async {
final List<CommitStatus> commitStatuses = <CommitStatus>[
CommitStatus()
Expand Down

0 comments on commit b8130a3

Please sign in to comment.