flutter/packages/flutter_tools/test/web.shard/web_driver_service_test.dart
Srujan Gaddam 9393aae393
Align web terminal messages with the VM (#163268)
- Adds better instructions for hot reload (if using the right flags),
hot restart, quitting, clearing, and more. These were already being
printed when using the VM, so this aligns with that.
- Adds an extra parameter for `CommandHelp` to `ResidentRunner` so
`ResidentWebRunner` can pass a version of it that uses its separate
logger and not `globals`. In order to support this, classes up the stack
also provide a `Terminal`, `Platform`, and `OutputPreferences`.
- Fixes up use of `globals` from an earlier change to implement hot
reload to use the logger instead. Same with `globals.platform`.
- Adds tests to check that only hot restart is printed when not using
the extra front-end flags, and both hot restart and hot reload is
printed when you are.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
2025-02-14 19:57:53 +00:00

47 lines
1.7 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/drive/web_driver_service.dart';
import 'package:package_config/package_config_types.dart';
import '../src/common.dart';
import '../src/fake_process_manager.dart';
void main() {
testWithoutContext(
'WebDriverService catches SocketExceptions cleanly and includes link to documentation',
() async {
final BufferLogger logger = BufferLogger.test();
final WebDriverService service = WebDriverService(
logger: logger,
terminal: Terminal.test(),
platform: FakePlatform(),
outputPreferences: OutputPreferences.test(),
processUtils: ProcessUtils(logger: logger, processManager: FakeProcessManager.empty()),
dartSdkPath: 'dart',
);
const String link = 'https://flutter.dev/to/integration-test-on-web';
try {
await service.startTest(
'foo.test',
<String>[],
PackageConfig(<Package>[Package('test', Uri.base)]),
driverPort: 1,
headless: true,
browserName: 'chrome',
);
fail('WebDriverService did not throw as expected.');
} on ToolExit catch (error) {
expect(error.message, isNot(contains('SocketException')));
expect(error.message, contains(link));
}
},
);
}