Files
react-native-devtools-frontend/test/e2e/console/console-clear_test.ts
T
Jack Franklin e839c0cf22 Enable long import wrapping for JS imports
DISABLE_THIRD_PARTY_CHECK=big clang format run against all files in
front_end and test/

Bug: 1319340
Change-Id: I1fff63cb07544ccd0e3059fc901f9a48ff4af13b
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3598879
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Wolfgang Beyer <wolfi@chromium.org>
2022-05-03 10:22:12 +00:00

57 lines
2.2 KiB
TypeScript

// Copyright 2020 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 {click, getBrowserAndPages, step} from '../../shared/helper.js';
import {describe, it} from '../../shared/mocha-extensions.js';
import {
CONSOLE_TAB_SELECTOR,
focusConsolePrompt,
typeIntoConsole,
typeIntoConsoleAndWaitForResult,
} from '../helpers/console-helpers.js';
describe('The Console Tab', async function() {
it('is cleared via the console.clear() method', async () => {
const {frontend} = getBrowserAndPages();
await click(CONSOLE_TAB_SELECTOR);
await focusConsolePrompt();
await step('enter 1 in console', async () => {
await typeIntoConsoleAndWaitForResult(frontend, '1;');
});
await step('enter 2 in console', async () => {
await typeIntoConsoleAndWaitForResult(frontend, '2;');
});
await step('enter 3 in console', async () => {
await typeIntoConsoleAndWaitForResult(frontend, '3;');
});
await step('Check the evaluation results from console', async () => {
const evaluateResults = await frontend.evaluate(() => {
return Array.from(document.querySelectorAll('.console-user-command-result')).map(node => node.textContent);
});
assert.deepEqual(evaluateResults, ['1', '2', '3'], 'did not find expected output in the console');
});
await step('enter console.clear() in console', async () => {
await typeIntoConsole(frontend, 'console.clear();');
});
await step('wait for the console to be cleared', async () => {
await frontend.waitForFunction(() => {
return document.querySelectorAll('.console-user-command-result').length === 1;
});
});
await step('check that the remaining text in the console is correct', async () => {
const clearResult = await frontend.evaluate(() => {
const result = document.querySelector('.console-user-command-result');
if (!result) {
assert.fail('Could not find user command result in the DOM.');
}
return result.textContent;
});
assert.strictEqual(clearResult, 'undefined', 'the result of clear was not undefined');
});
});
});