Skip to content

Commit

Permalink
Try to make test more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette committed Sep 19, 2023
1 parent bca13c5 commit 0ffa980
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions dwds/test/puppeteer/extension_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ void testAll({
});

tearDown(() async {
await evaluate(
_clearNotifications,
worker: worker,
backgroundPage: backgroundPage,
);
await tearDownHelper(
worker: worker,
backgroundPage: backgroundPage,
Expand Down Expand Up @@ -284,30 +289,38 @@ void testAll({
test(
'[X X] [!] navigating away from the Dart app while debugging closes DevTools',
() async {
print('[debug log] at start of test');
final appUrl = context.appUrl;
final devToolsUrlFragment =
useSse ? 'debugger?uri=sse' : 'debugger?uri=ws';
// Navigate to the Dart app:
print('[debug log] navigating to page');
final appTab =
await navigateToPage(browser, url: appUrl, isNew: true);
// Click on the Dart Debug Extension icon:
print('[debug log] waiting for dart detection');
await _waitForDartDetection(hasServiceWorker: isMV3);
print('[debug log] click extension icon');
await clickOnExtensionIcon(
worker: worker,
backgroundPage: backgroundPage,
);
// Verify that the Dart DevTools tab is open:
print('[debug log] wait for devtools target');
final devToolsTabTarget = await browser.waitForTarget(
(target) => target.url.contains(devToolsUrlFragment),
);
expect(devToolsTabTarget.type, equals('page'));
// Navigate away from the Dart app:
print(' [debug log] navigated away');
await appTab.goto(
'https://dart.dev/',
wait: Until.domContentLoaded,
);
print('[debug log] bring tab to front');
await appTab.bringToFront();
// Verify that the Dart DevTools tab closes:
print('[debug log] verify devtools closes');
await devToolsTabTarget.onClose;
await appTab.close();
});
Expand Down Expand Up @@ -362,7 +375,7 @@ void testAll({
print('[debug log] wait for notifications');
// There should be no warning notifications:
var chromeNotifications = await evaluate(
_getNotifications(),
_getNotifications,
worker: worker,
backgroundPage: backgroundPage,
);
Expand All @@ -379,7 +392,7 @@ void testAll({
await workerEvalDelay();
// There should now be a warning notificiation:
chromeNotifications = await evaluate(
_getNotifications(),
_getNotifications,
worker: worker,
backgroundPage: backgroundPage,
);
Expand All @@ -405,7 +418,7 @@ void testAll({
);
// There should now be a warning notificiation:
final chromeNotifications = await evaluate(
_getNotifications(),
_getNotifications,
worker: worker,
backgroundPage: backgroundPage,
);
Expand Down Expand Up @@ -1129,8 +1142,7 @@ String _fetchStorageObjJs(
''';
}

String _getNotifications() {
return '''
String _getNotifications = '''
async () => {
return new Promise((resolve, reject) => {
chrome.notifications.getAll((notifications) => {
Expand All @@ -1139,7 +1151,12 @@ String _getNotifications() {
});
}
''';
}

String _clearNotifications = '''
chrome.notifications.getAll((notifications) => {
notifications.forEach((notification) => chrome.notifications.clear(notification));
});
''';

String _setMultipleAppsAttributeJs = '''
document.documentElement.setAttribute("data-multiple-dart-apps", true);
Expand Down

0 comments on commit 0ffa980

Please sign in to comment.