Skip to content

Commit ed4cfd0

Browse files
authored
Fix flaky debug_extension_test.dart (#1521)
1 parent dcffd01 commit ed4cfd0

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

dwds/test/debug_extension_test.dart

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ final context = TestContext();
3838
final devToolsLoadTime = const Duration(seconds: 4);
3939

4040
void main() async {
41+
Future<void> waitForDartDevToolsWithRetry({
42+
int retryCount = 6,
43+
Duration retryWait = const Duration(seconds: 1),
44+
}) async {
45+
if (retryCount == 0) return;
46+
var windows = await context.webDriver.windows.toList();
47+
await context.webDriver.driver.switchTo.window(windows.last);
48+
final title = await context.webDriver.title;
49+
if (title == 'Dart DevTools') return;
50+
51+
await Future.delayed(retryWait);
52+
return waitForDartDevToolsWithRetry(
53+
retryCount: retryCount--,
54+
retryWait: retryWait,
55+
);
56+
}
57+
4158
for (var useSse in [true, false]) {
4259
group(useSse ? 'SSE' : 'WebSockets', () {
4360
group('Without encoding', () {
@@ -76,11 +93,9 @@ void main() async {
7693
await context.extensionConnection.sendCommand('Runtime.evaluate', {
7794
'expression': 'fakeClick()',
7895
});
79-
await Future.delayed(devToolsLoadTime);
80-
var windows = await context.webDriver.windows.toList();
81-
await context.webDriver.driver.switchTo.window(windows.last);
96+
await waitForDartDevToolsWithRetry();
8297
expect(await context.webDriver.title, 'Dart DevTools');
83-
}, skip: 'https://github.com/dart-lang/webdev/issues/1512');
98+
});
8499
});
85100

86101
group('With a sharded Dart app', () {
@@ -154,11 +169,9 @@ void main() async {
154169
await context.extensionConnection.sendCommand('Runtime.evaluate', {
155170
'expression': 'fakeClick()',
156171
});
157-
await Future.delayed(devToolsLoadTime);
158-
var windows = await context.webDriver.windows.toList();
159-
await context.webDriver.driver.switchTo.window(windows.last);
172+
await waitForDartDevToolsWithRetry();
160173
expect(await context.webDriver.title, 'Dart DevTools');
161-
}, skip: 'https://github.com/dart-lang/webdev/issues/1512');
174+
});
162175
});
163176
});
164177
}

0 commit comments

Comments
 (0)