Skip to content

Commit ccfc427

Browse files
authored
fix: error suppressing tests on packages (#4996)
various problems: - dialog widgets aren't mounted and getting dismissed - githubService.getIssue() is odd (Future<Issue>?) - Add fake auth to dashboard for non-prod - Add fake issue response for testing - see flutter/packages
1 parent 4d064c3 commit ccfc427

15 files changed

Lines changed: 509 additions & 39 deletions

File tree

.vscode/launch.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "dashboard (fake auth)",
9+
"cwd": "dashboard",
10+
"request": "launch",
11+
"flutterMode": "debug",
12+
"deviceId": "chrome",
13+
"type": "dart",
14+
"args": [
15+
"--dart-define=FAKE_AUTH=true"
16+
]
17+
},
18+
]
19+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ The dashboard application will use dummy data when it is not connected
106106
to the server, so it can be developed locally without a dev server.
107107

108108
To run the dashboard locally, go into the `dashboard` directory and
109-
run `flutter run -d chrome`. The dashboard will be served from localhost
109+
run `flutter run -d chrome --dart-define=FAKE_AUTH=true`. The dashboard will be served from localhost
110110
(the exact address will be given on the console); copy the URL into
111111
your browser to view the application. (The dashboard should also be
112112
able to run on non-Web platforms, but since the Web is our main target

app_dart/lib/src/request_handlers/update_suppressed_test.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,16 @@ final class UpdateSuppressedTest extends ApiRequestHandler {
108108
}
109109

110110
final githubService = await config.createGithubService(repository);
111-
final issue = await githubService.getIssue(
112-
repository,
113-
issueNumber: issueNumber,
114-
);
111+
final Issue? issue;
112+
try {
113+
issue = await githubService.getIssue(
114+
repository,
115+
issueNumber: issueNumber,
116+
);
117+
} catch (e) {
118+
throw BadRequestException('Error searching for issue: $e');
119+
}
120+
115121
if (issue == null) {
116122
throw const BadRequestException('Issue not found.');
117123
}

app_dart/test/request_handlers/update_suppressed_test_test.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,28 @@ void main() {
142142
);
143143
});
144144

145+
test('throws BadRequestException if issue search fails (SUPPRESS)', () async {
146+
githubService.error = Exception('GitHub error');
147+
148+
tester.request.body = jsonEncode({
149+
'testName': 'my_test',
150+
'repository': 'flutter/flutter',
151+
'action': 'SUPPRESS',
152+
'issueLink': 'https://github.com/flutter/flutter/issues/123',
153+
});
154+
155+
await expectLater(
156+
tester.post(handler),
157+
throwsA(
158+
isA<BadRequestException>().having(
159+
(e) => e.message,
160+
'message',
161+
contains('Error searching for issue'),
162+
),
163+
),
164+
);
165+
});
166+
145167
test('throws BadRequestException if issue not found (SUPPRESS)', () async {
146168
githubService.issueResponse = null; // Issue not found
147169

@@ -410,9 +432,13 @@ void main() {
410432

411433
class FakeGithubServiceWithIssue extends FakeGithubService {
412434
Issue? issueResponse;
435+
Object? error;
413436

414437
@override
415438
Future<Issue>? getIssue(RepositorySlug slug, {int? issueNumber}) {
439+
if (error != null) {
440+
throw error!;
441+
}
416442
if (issueResponse == null) {
417443
return null;
418444
}

dashboard/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ It is possible to run a simulation of the UI locally with fake data:
1313

1414
```sh
1515
# Launches Chrome
16-
flutter run -d chrome --web-port=8080 --web-define=description=Dashboard --web-define=projectName=Dashboard
16+
flutter run -d chrome --web-port=8080 --dart-define=FAKE_AUTH=true
1717

1818
# Starts a web server, bring your own browser instance
19-
flutter run -d web-server --web-port=8080 --web-define=description=Dashboard --web-define=projectName=Dashboard
19+
flutter run -d web-server --web-port=8080 --dart-define=FAKE_AUTH=true
2020
```
2121

2222
NOTE: Must run on port 8080[^8080] for authentication to work.

dashboard/lib/main.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:flutter/services.dart';
1212

1313
import 'firebase_options.dart';
1414
import 'service/cocoon.dart';
15+
import 'service/fake_firebase_auth.dart';
1516
import 'service/firebase_auth.dart';
1617
import 'state/build.dart';
1718
import 'state/presubmit.dart';
@@ -62,7 +63,12 @@ void main([List<String> args = const <String>[]]) async {
6263
};
6364
}
6465

65-
final authService = FirebaseAuthService();
66+
final FirebaseAuthService authService;
67+
if (const bool.fromEnvironment('FAKE_AUTH', defaultValue: false)) {
68+
authService = FakeFirebaseAuthService();
69+
} else {
70+
authService = FirebaseAuthService();
71+
}
6672

6773
final cocoonService = CocoonService(
6874
useProductionService: useProductionService,

dashboard/lib/service/appengine_cocoon.dart

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -271,25 +271,36 @@ class AppEngineCocoonService implements CocoonService {
271271
String? issueLink,
272272
String? note,
273273
}) async {
274-
final updateTestSuppressionUrl = apiEndpoint('/api/update-suppressed-test');
275-
final response = await _client.post(
276-
updateTestSuppressionUrl,
277-
headers: {'X-Flutter-IdToken': idToken},
278-
body: jsonEncode({
279-
'repository': repo,
280-
'testName': testName,
281-
'action': suppress ? 'SUPPRESS' : 'UNSUPPRESS',
282-
'issueLink': ?issueLink,
283-
'note': ?note,
284-
}),
285-
);
286-
if (response.statusCode == HttpStatus.ok) {
287-
return const CocoonResponse.data(null);
274+
final action = suppress ? 'SUPPRESS' : 'UNSUPPRESS';
275+
try {
276+
final updateTestSuppressionUrl = apiEndpoint(
277+
'/api/update-suppressed-test',
278+
);
279+
final response = await _client.post(
280+
updateTestSuppressionUrl,
281+
headers: {'X-Flutter-IdToken': idToken},
282+
body: jsonEncode({
283+
'repository': repo,
284+
'testName': testName,
285+
'action': action,
286+
'issueLink': ?issueLink,
287+
'note': ?note,
288+
}),
289+
);
290+
if (response.statusCode == HttpStatus.ok) {
291+
return const CocoonResponse.data(null);
292+
}
293+
return CocoonResponse.error(
294+
'HTTP Code: ${response.statusCode}, ${response.body}',
295+
statusCode: response.statusCode,
296+
);
297+
} catch (e, s) {
298+
print(
299+
'Error calling update-suppressed-test('
300+
'${(repo: repo, testName: testName, action: action, issueLink: issueLink, note: note)}); $e\n$s',
301+
);
302+
return CocoonResponse.error('Error: $e, $s', statusCode: 500);
288303
}
289-
return CocoonResponse.error(
290-
'HTTP Code: ${response.statusCode}, ${response.body}',
291-
statusCode: response.statusCode,
292-
);
293304
}
294305

295306
@override

dashboard/lib/service/data_seeder.dart

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DataSeeder {
3333
final random = math.Random(now.millisecondsSinceEpoch);
3434

3535
// Seed Commits and Tasks
36-
for (final repo in ['flutter', 'cocoon']) {
36+
for (final repo in ['flutter', 'cocoon', 'packages']) {
3737
final branch = defaultBranches[repo]!;
3838
_seedCommitStatuses(now, random, repo, branch);
3939
}
@@ -659,7 +659,12 @@ class DataSeeder {
659659
);
660660
commits.add(commit);
661661

662-
final taskCount = repo == 'flutter' ? 100 : 3;
662+
final taskCount = switch (repo) {
663+
'flutter' => 100,
664+
'packages' => 42,
665+
'cocoon' => 13,
666+
_ => 3,
667+
};
663668
for (var i = 0; i < taskCount; i++) {
664669
tasks.add(
665670
_createFakeTask(
@@ -829,6 +834,7 @@ class DataSeeder {
829834
static const _commitsSha = {
830835
'cocoon': _commitsCocoon,
831836
'flutter': _commitsFlutter,
837+
'packages': _commitsPackages,
832838
};
833839

834840
// These commits from from flutter/cocoon
@@ -1037,4 +1043,107 @@ class DataSeeder {
10371043
'9fa7f81be038464d2aabef4752d2f50ea60ce561',
10381044
'aba16bc2db714ba438f5480fd328c14ca92c42db',
10391045
];
1046+
1047+
static const _commitsPackages = [
1048+
'8dcfd1186ef968be1398f80432f94bb0a36e6d9e',
1049+
'c1f116788a9c0187ac566517eecaf31a49c2bbf7',
1050+
'99155a84f372cef1c5fc2d03c54d6980fb9df808',
1051+
'b3a69599c7b8d2f97dc7f601df59b09f6a47a8ed',
1052+
'43de301d0901cac145b39a994fe3b58889e00b85',
1053+
'ca60bd020f339b5538423b3e60463717a702ddc7',
1054+
'09ddfca4fe95c5aa90015ce4ecb31485eb7cf3d7',
1055+
'94b93d4cd52af75b3298c1966394759a9e611f61',
1056+
'071ed5b454e05b071ffb9113c33e7a423ca344b0',
1057+
'3c0cdab2bbb0e98e5e5871f5949e38f21cff6385',
1058+
'b3280ae0d8ed70ec2e354e000354099b8abcc448',
1059+
'afa1a1c3564e5be4795193600b1c2f0e58d80bee',
1060+
'2fbf78d1099c2ec04578c0db2737b81632f573da',
1061+
'90a2dc1245d7a3e370230bcd2f308a35da67851f',
1062+
'70049bdd9b88609b4485cc2cf71ccb60da57031c',
1063+
'b2e421bc176c488730567e4edbdee6ed48d00473',
1064+
'dd634a2186cfe9e5b57fca2c8cceae7b4fa41790',
1065+
'1802599d43eb93a1ada0dfb294d3f030bdacc2a2',
1066+
'a9d36fb7b9021b6e980156097fa8c0f8392273f3',
1067+
'88afc6863149dfa1a26170a17789a1b711ddbe5a',
1068+
'0f2eeaecde3f34322f9e9980177d15beaeb2b871',
1069+
'409793bcb784b9464def8698557005fb8851a9e6',
1070+
'1ad1a084c057b6c0383f6cf0ba9df70d5d4b0fc6',
1071+
'392d771dac6e7956d30fe93ef2595df787f5a287',
1072+
'ea9b53ba608a8aa6d0d243832fdcee37928e1614',
1073+
'd809b4f2e1cb8381b0328234204c5423a0580999',
1074+
'91f7c339b29af157db001e487e14274487f41688',
1075+
'86543faf4d5634bdaf5d60661630ddf81ad0617f',
1076+
'02f231f376761cc04610e8c566b0ba759db0bda7',
1077+
'61b4096307bf8a20786716522a0f5ce55a577d82',
1078+
'bba1da378c820040d57cf8cb01ca27c85728fe61',
1079+
'14cbff2f7383a1563aef4efd29d92f65d8ddef2a',
1080+
'ecace66e92c2f9235e0d811b064d9f0e97f6175e',
1081+
'1ea3725c4396e1708571082a635f6132c059fd18',
1082+
'a6542ceef278cf10bd82bc0c4c2feca611c582a2',
1083+
'44980b66496ec338ed1ed256e40e161c5bb6d09b',
1084+
'295819c44093d6fed1fe48c28b3ac01268154387',
1085+
'77796111ab5f3d0a63d0f594d9499dc7dcc58c50',
1086+
'406a9821eb084426e0264fca36e0afbc3acd5227',
1087+
'a643267e6bf368f0ae83a17caf0a369c095ab0df',
1088+
'37827fc0a5588f40ea5dba1a70383ae86e8265b6',
1089+
'349d8853cab54514b15173337f3203093ccda106',
1090+
'ee460d6a01fee815ffbe1dc169f851bd682addd6',
1091+
'5bee35271f19d5bd039c5bd460a62e60b426ebca',
1092+
'c7170181ffebd5efcc06bf78734c5820a27f7cfd',
1093+
'9139f6c6bef51edf08dc587b43b06e359fb5c7de',
1094+
'2673dcdf47156efdfae783bb389234df81ac9da7',
1095+
'edc45c5f31a12875352048545bed57820e970edd',
1096+
'79b53f3424dc889dd0d257c83461644dab46278e',
1097+
'1e0338bfd3c6799713fe89c26a55a64521416e16',
1098+
'4d0dfb290e773d4bf68d046f797584a172694966',
1099+
'27b12509e5203fea3aa2ed3cc4a4c38cf3349634',
1100+
'ff15dfdb36837e099424a4590ebf202472029f49',
1101+
'e774c2a3f03b2c551506508f813c91d25c297d22',
1102+
'fe3de646912443c073773acea83c783be6c2275c',
1103+
'bf3a29cfccf105d652b03d2cb681081e6854eddd',
1104+
'8d5c5cd0fa83b786429a5c7ce9f93a5f2f132648',
1105+
'888ef055975de366031e514317ba8bc39f9c11d5',
1106+
'82baf937218655b8befc2a391c955ae8eb7aa674',
1107+
'3c04d2df64a497e646d344bf384049c0bcbccdf9',
1108+
'03ed07755ce0761fee7ecd8b0a46cf3bfa85c667',
1109+
'e5ef6e87e51bd3213e60ae060a48273a5384f855',
1110+
'8212bdb4a2c8b5911b3ba33cbf85942917c9dcd9',
1111+
'9083bc9bed1d399f54952848c85c54dc6cba8645',
1112+
'7293eee6ac127b7c34185a56064f75bf46dcd892',
1113+
'173a344964f6426579cb2b9578108d014585c79b',
1114+
'12279ffac3cee623e51667e62dd720046f05fa03',
1115+
'faa4e22db67cc5e6d6af84ebc85603330fff7353',
1116+
'678f033811377ce039a491ad1beae56ac7ba87ed',
1117+
'7f9860a70d20bc77166eba1a56f4e9c2d2680db3',
1118+
'32a8a23e9be049c0da892e08e36e43cfe76799a1',
1119+
'a27d7c50b3ac66cdcc9e774d2a5310793277ed34',
1120+
'7026f1a62c30509b40023c67969c5d0eeb7c0f24',
1121+
'6301571e051a814d6610ab199484d94f4aa0d795',
1122+
'f3ce6cbfa7677fa6ea093982c5c7c4194976d339',
1123+
'6d8b19d5fd7ae2f1905885f2b323af1cb2f0ad57',
1124+
'3bef3cf3da7603393ed969e5cb1f814322c46058',
1125+
'79c529a6bf794cca23ff33299e893a2b118cb19b',
1126+
'f234c1f626d56f05eaeb0bd5f1094e5354ed2518',
1127+
'e1d01695273f692c6a67848e72bd58b255837f7c',
1128+
'f84c6e71882fd6af96fafec34c8fbced81016a0a',
1129+
'40bb258f277522f87dc8c01a62293828116bb16a',
1130+
'6c20ef3136acf476b3923dc9bdc74a1d512f3849',
1131+
'b9ee0b3caffce7a33cac1e72cded5777865c6f79',
1132+
'546d3542df2d017142bb9dcb1f142060f319e631',
1133+
'7fe183f964b312cc51985067ac54f1ff292236b3',
1134+
'd8970b12d60a31e9bae5521142f9881895244f88',
1135+
'acd9adbe46762bc305c7502d17527accf184c3a6',
1136+
'0b2baeb4fbf3e565f87cb2f7a28394a1d9c0e77d',
1137+
'062c8d4f8dd51004a87b0abebb88c1986c5a73a5',
1138+
'12013c49611994d08759f056294e347e5b5fa236',
1139+
'9fa0fdce48a2b730da20c2d2228b75f819b1cbdd',
1140+
'8f2fd365ea7b30762f4e67357b299954f9b4a996',
1141+
'76183f418542218f3bb49a7ecfe5e2e1406ed126',
1142+
'12b43a192e1f5fa5141181a72d681a15abd003c1',
1143+
'df8be18fb5083a0baee0f9612b6488ef7c375d71',
1144+
'de38ee1e9da563cbf70436db7f7b2e95595c07d8',
1145+
'54b6834b2a74aa1165dd7fba3558edb6e71d1112',
1146+
'bf37517977ffaa46c76dfbc1d30e3ef874cd9729',
1147+
'673c2ac4b464aacb2b320ffc30eca0ab953e6212',
1148+
];
10401149
}

0 commit comments

Comments
 (0)