mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 01:07:01 +08:00
[e2e] Fix selection after delete
Discovered a race condition when running e2e in SLOWMO. This CL fixes the race condition by ensuring that the old content is definitely grabbed before the backspace key is pressed. Change-Id: I6f39f18b8352ed03a1b6e4c067a2e526589b4ace Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2130789 Commit-Queue: Paul Lewis <aerotwist@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
This commit is contained in:
@@ -5,14 +5,14 @@
|
||||
import {describe, it} from 'mocha';
|
||||
|
||||
import {click, getBrowserAndPages, resetPages, resourcesPath, waitFor, waitForElementWithTextContent} from '../../shared/helper.js';
|
||||
import {assertContentOfSelectedElementsNode, expandSelectedNodeRecursively, waitForSelectedNodeChange} from '../helpers/elements-helpers.js';
|
||||
import {assertContentOfSelectedElementsNode, expandSelectedNodeRecursively, getContentOfSelectedNode, waitForSelectedNodeChange} from '../helpers/elements-helpers.js';
|
||||
|
||||
describe('The Elements tab', async () => {
|
||||
beforeEach(async () => {
|
||||
await resetPages();
|
||||
});
|
||||
|
||||
it('can delete stuff', async () => {
|
||||
it('can delete elements in the tree', async () => {
|
||||
const {target, frontend} = getBrowserAndPages();
|
||||
|
||||
await target.goto(`${resourcesPath}/elements/selection-after-delete.html`);
|
||||
@@ -40,10 +40,9 @@ describe('The Elements tab', async () => {
|
||||
do {
|
||||
const nextVal = expected.shift() || '';
|
||||
|
||||
// Start watching for the node change before hitting backspace.
|
||||
const elementChanged = waitForSelectedNodeChange();
|
||||
const initialValue = await getContentOfSelectedNode();
|
||||
await frontend.keyboard.press('Backspace');
|
||||
await elementChanged;
|
||||
await waitForSelectedNodeChange(initialValue);
|
||||
|
||||
await assertContentOfSelectedElementsNode(nextVal);
|
||||
} while (expected.length);
|
||||
|
||||
@@ -24,16 +24,15 @@ export const getContentOfSelectedNode = async () => {
|
||||
return await selectedNode.evaluate(node => node.textContent);
|
||||
};
|
||||
|
||||
export const waitForSelectedNodeChange = async (maxTotalTimeout = 1000) => {
|
||||
export const waitForSelectedNodeChange = async (initialValue: string, maxTotalTimeout = 1000) => {
|
||||
if (maxTotalTimeout === 0) {
|
||||
maxTotalTimeout = Number.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
const start = performance.now();
|
||||
const initialNodeContent = await getContentOfSelectedNode();
|
||||
do {
|
||||
const currentContent = await getContentOfSelectedNode();
|
||||
if (currentContent !== initialNodeContent) {
|
||||
if (currentContent !== initialValue) {
|
||||
return currentContent;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user