Skip to content

Commit 25fe8ec

Browse files
authored
properly handle deleting sha from query parameters (#5009)
Fix: flutter/flutter#184372
1 parent 98cdde6 commit 25fe8ec

3 files changed

Lines changed: 56 additions & 1 deletion

File tree

.vscode/launch.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
{
8+
"name": "dashboard",
9+
"cwd": "dashboard",
10+
"request": "launch",
11+
"flutterMode": "debug",
12+
"deviceId": "chrome",
13+
"type": "dart",
14+
"args": [
15+
"--web-port",
16+
"8080",
17+
]
18+
},
719
{
820
"name": "dashboard (fake auth)",
921
"cwd": "dashboard",
@@ -12,7 +24,9 @@
1224
"deviceId": "chrome",
1325
"type": "dart",
1426
"args": [
15-
"--dart-define=FAKE_AUTH=true"
27+
"--dart-define=FAKE_AUTH=true",
28+
"--web-port",
29+
"8080",
1630
]
1731
},
1832
]

dashboard/lib/state/presubmit.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ class PresubmitState extends ChangeNotifier {
336336
_lastFetchedSha = null;
337337
_jobs = null;
338338
_selectedJob = null;
339+
// Reset to force re-fetch of available SHAs and pick the latest one
340+
if (sha == null) {
341+
_lastFetchedPr = null;
342+
}
339343
}
340344

341345
if (changed) {

dashboard/test/state/presubmit_test.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,41 @@ void main() {
367367
),
368368
).called(1);
369369
});
370+
test(
371+
'syncUpdate with null sha resets _lastFetchedPr to force re-fetch when pr is the same',
372+
() async {
373+
const summaries = [
374+
PresubmitGuardSummary(
375+
headSha: 'latest',
376+
creationTime: 123,
377+
guardStatus: GuardStatus.succeeded,
378+
),
379+
];
380+
when(
381+
mockCocoonService.fetchPresubmitGuardSummaries(
382+
pr: '123',
383+
repo: 'flutter',
384+
),
385+
).thenAnswer(
386+
(_) async =>
387+
const CocoonResponse<List<PresubmitGuardSummary>>.data(summaries),
388+
);
389+
390+
presubmitState.update(repo: 'flutter', pr: '123', sha: 'sha1');
391+
expect(presubmitState.sha, 'sha1');
392+
393+
await Future<void>.delayed(Duration.zero);
394+
clearInteractions(mockCocoonService);
395+
396+
presubmitState.update(pr: '123', sha: null);
397+
398+
verify(
399+
mockCocoonService.fetchPresubmitGuardSummaries(
400+
pr: '123',
401+
repo: 'flutter',
402+
),
403+
).called(1);
404+
expect(presubmitState.sha, 'latest');
405+
},
406+
);
370407
}

0 commit comments

Comments
 (0)