Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dashboard] Merge columns for luci and cocoon tasks #1587

Merged
merged 1 commit into from
Feb 4, 2022
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
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