Skip to content

Re-enable most test cases in devtools_test #1881

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

Merged
merged 2 commits into from
Jan 13, 2023
Merged
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
99 changes: 45 additions & 54 deletions dwds/test/devtools_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

@Skip('https://github.com/dart-lang/webdev/issues/1845 - Move to cron job.')
@Timeout(Duration(minutes: 5))
@TestOn('vm')
import 'dart:io';
Expand All @@ -19,7 +18,7 @@ Future<void> _waitForPageReady(TestContext context) async {
var attempt = 100;
while (attempt-- > 0) {
final content = await context.webDriver.pageSource;
if (content.contains('Hello World!')) return;
if (content.contains('hello_world')) return;
await Future.delayed(const Duration(milliseconds: 100));
}
throw StateError('Page never initialized');
Expand All @@ -43,58 +42,48 @@ void main() {
test('can launch devtools', () async {
final windows = await context.webDriver.windows.toList();
await context.webDriver.driver.switchTo.window(windows.last);
// TODO(grouma): switch back to `fixture.webdriver.title` when
// https://github.com/flutter/devtools/issues/2045 is fixed.
expect(await context.webDriver.pageSource, contains('Flutter'));
expect(await context.webDriver.title, equals('Dart DevTools'));
expect(await context.webDriver.currentUrl, contains('ide=Dwds'));
// TODO(elliette): Re-enable and fix flakes.
}, skip: true);

test(
'can not launch devtools for the same app in multiple tabs',
() async {
final appUrl = await context.webDriver.currentUrl;
// Open a new tab, select it, and navigate to the app
await context.webDriver.driver
.execute("window.open('$appUrl', '_blank');", []);
await Future.delayed(const Duration(seconds: 2));
var windows = await context.webDriver.windows.toList();
final oldAppWindow = windows[0];
final newAppWindow = windows[1];
var devToolsWindow = windows[2];
await newAppWindow.setAsActive();

// Wait for the page to be ready before trying to open DevTools again.
await _waitForPageReady(context);

// Try to open devtools and check for the alert.
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
await Future.delayed(const Duration(seconds: 2));
final alert = context.webDriver.driver.switchTo.alert;
expect(alert, isNotNull);
expect(await alert.text,
contains('This app is already being debugged in a different tab'));
await alert.accept();

// Now close the old app and try to re-open devtools.
await oldAppWindow.setAsActive();
await oldAppWindow.close();
await devToolsWindow.setAsActive();
await devToolsWindow.close();
await newAppWindow.setAsActive();
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
await Future.delayed(const Duration(seconds: 2));
windows = await context.webDriver.windows.toList();
devToolsWindow = windows.firstWhere((window) => window != newAppWindow);
await devToolsWindow.setAsActive();
// TODO(grouma): switch back to `fixture.webdriver.title` when
// https://github.com/flutter/devtools/issues/2045 is fixed.
expect(await context.webDriver.pageSource, contains('Flutter'));
},
// TODO(elliette): Enable this test once
// https://github.com/dart-lang/webdev/issues/1504 is resolved.
skip: true,
);
});

test('can not launch devtools for the same app in multiple tabs', () async {
final appUrl = await context.webDriver.currentUrl;
// Open a new tab, select it, and navigate to the app
await context.webDriver.driver
.execute("window.open('$appUrl', '_blank');", []);
await Future.delayed(const Duration(seconds: 2));
final newAppWindow = await context.webDriver.windows.last;
await newAppWindow.setAsActive();

// Wait for the page to be ready before trying to open DevTools again.
await _waitForPageReady(context);

// Try to open devtools and check for the alert.
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
await Future.delayed(const Duration(seconds: 2));
final alert = context.webDriver.driver.switchTo.alert;
expect(alert, isNotNull);
expect(await alert.text,
contains('This app is already being debugged in a different tab'));
await alert.accept();

var windows = await context.webDriver.windows.toList();
for (final window in windows) {
if (window.id != newAppWindow.id) {
await window.setAsActive();
await window.close();
}
}

await newAppWindow.setAsActive();
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
await Future.delayed(const Duration(seconds: 2));
windows = await context.webDriver.windows.toList();
final devToolsWindow =
windows.firstWhere((window) => window != newAppWindow);
await devToolsWindow.setAsActive();
expect(await context.webDriver.title, equals('Dart DevTools'));
});

test('destroys and recreates the isolate during a page refresh', () async {
// This test is the same as one in reload_test, but runs here when there
Expand Down Expand Up @@ -124,7 +113,7 @@ void main() {
toReplace: 'Bonjour le monde!',
replaceWith: 'Hello World!',
);
});
}, skip: 'https://github.com/dart-lang/webdev/issues/1888');
});

group('Injected client without DevTools', () {
Expand Down Expand Up @@ -169,6 +158,8 @@ void main() {
expect(await alert.text, contains('--debug'));
await alert.accept();
});
// TODO(https://github.com/dart-lang/webdev/issues/1724): Re-enable debug
// extension tests on Windows.
}, tags: ['extension'], skip: Platform.isWindows);
}

Expand Down