mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-27 08:25:20 +08:00
This CL simplifies the implementation of the test runner for e2e and interaction tests by moving the test helpers previously found in mocha-extensions.ts to a new mocha interface in mocha-interface.ts. The interface file is provided to mocha using the `-u` option and it will be used by the test runner to process test files. This allows more easily to control the test interface exposed to tests and implementing custom logic before the test is executed without resorting to interception and re-definition of built-in mocha interfaces. This change also eliminates the need to import mocha-extensions.js in every test file. The following features are now exposed to tests: 1) it/it.skip/it.only/it.skipOnPlatforms 2) describe/describe.skip/describe.only/describe.skipOnPlatforms 3) itScreenshot/itScreenshot.only/itScreenshot.skip/itScreenshot.skipOnPlatforms 4) AbortSignal to abort test operations is added to AsyncScope.abortSignal. 5) AsyncScope and screenshots are taken on timeout or error as previously. Cq-Include-Trybots: luci.devtools-frontend.try:cpp_debug_extension_e2e_dbg,cpp_debug_extension_e2e_rel Bug: none Change-Id: I03e3ef145a9bf527631ae99c03384b8ef0179c98 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5804334 Reviewed-by: Simon Zünd <szuend@chromium.org> Reviewed-by: Philip Pfaffe <pfaffe@chromium.org> Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
106 lines
4.0 KiB
TypeScript
106 lines
4.0 KiB
TypeScript
// Copyright 2021 The Chromium 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 {assert} from 'chai';
|
|
|
|
import {clickElement, enableExperiment, goToResource, step, waitFor} from '../../shared/helper.js';
|
|
|
|
import {navigateToElementsTab} from '../helpers/elements-helpers.js';
|
|
import {
|
|
getMenuItemAtPosition,
|
|
getMenuItemTitleAtPosition,
|
|
openFileQuickOpen,
|
|
readQuickOpenResults,
|
|
typeIntoQuickOpen,
|
|
} from '../helpers/quick_open-helpers.js';
|
|
import {setIgnoreListPattern, togglePreferenceInSettingsTab} from '../helpers/settings-helpers.js';
|
|
import {openSourcesPanel, SourceFileEvents, waitForSourceFiles} from '../helpers/sources-helpers.js';
|
|
|
|
async function openAFileWithQuickMenu() {
|
|
await step('navigate to elements tab', async () => {
|
|
await navigateToElementsTab();
|
|
});
|
|
|
|
await waitForSourceFiles(
|
|
SourceFileEvents.SOURCE_FILE_LOADED, files => files.some(f => f.endsWith('hello-world.html')), async () => {
|
|
await step('open quick open menu and select the first option', async () => {
|
|
await goToResource('pages/hello-world.html');
|
|
await openFileQuickOpen();
|
|
const firstItem = await getMenuItemAtPosition(0);
|
|
await clickElement(firstItem);
|
|
});
|
|
await step('check the sources panel is open with the selected file', async () => {
|
|
await waitFor('.navigator-file-tree-item');
|
|
});
|
|
});
|
|
}
|
|
|
|
describe('Quick Open menu', () => {
|
|
it('lists available files', async () => {
|
|
await goToResource('pages/hello-world.html');
|
|
await openFileQuickOpen();
|
|
const firstItemTitle = await getMenuItemTitleAtPosition(0);
|
|
assert.strictEqual(firstItemTitle, 'hello-world.html');
|
|
});
|
|
|
|
it('opens the sources panel when a file is selected', async () => {
|
|
await openAFileWithQuickMenu();
|
|
await togglePreferenceInSettingsTab('Focus Sources panel when triggering a breakpoint');
|
|
await openAFileWithQuickMenu();
|
|
});
|
|
|
|
it('sorts authored above deployed', async () => {
|
|
await goToResource('sources/multi-workers-sourcemap.html');
|
|
await openSourcesPanel();
|
|
|
|
await typeIntoQuickOpen('mult');
|
|
const list = await readQuickOpenResults();
|
|
assert.deepEqual(list, ['multi-workers.js', 'multi-workers.min.js', 'multi-workers-sourcemap.html']);
|
|
});
|
|
|
|
it('sorts ignore listed below unignored', async () => {
|
|
await setIgnoreListPattern('mycode');
|
|
await goToResource('sources/multi-files.html');
|
|
await openSourcesPanel();
|
|
|
|
await typeIntoQuickOpen('mult');
|
|
const list = await readQuickOpenResults();
|
|
assert.deepEqual(list, ['multi-files-thirdparty.js', 'multi-files.html', 'multi-files-mycode.js']);
|
|
});
|
|
|
|
it('Does not list ignore-listed files', async () => {
|
|
await enableExperiment('just-my-code');
|
|
await setIgnoreListPattern('workers.js');
|
|
await goToResource('sources/multi-workers-sourcemap.html');
|
|
await openSourcesPanel();
|
|
|
|
await typeIntoQuickOpen('mult');
|
|
const list = await readQuickOpenResults();
|
|
assert.deepEqual(list, ['multi-workers.min.js', 'multi-workers-sourcemap.html']);
|
|
});
|
|
|
|
it('lists both deployed and authored file', async () => {
|
|
await goToResource('sources/sourcemap-origin.html');
|
|
await openSourcesPanel();
|
|
|
|
await typeIntoQuickOpen('sourcemap-origin.clash.js');
|
|
const list = await readQuickOpenResults();
|
|
assert.deepEqual(list, ['sourcemap-origin.clash.js', 'sourcemap-origin.clash.js']);
|
|
});
|
|
|
|
it('should not list network fetch requests (that are not overidden)', async () => {
|
|
await goToResource('network/fetch-json.html');
|
|
await typeIntoQuickOpen('json');
|
|
const list = await readQuickOpenResults();
|
|
assert.isFalse(list.includes('coffees.json'));
|
|
});
|
|
|
|
it('should not list network xhr requests (that are not overidden)', async () => {
|
|
await goToResource('network/xhr-json.html');
|
|
await typeIntoQuickOpen('json');
|
|
const list = await readQuickOpenResults();
|
|
assert.isFalse(list.includes('coffees.json'));
|
|
});
|
|
});
|