Skip to content

Commit 10eef98

Browse files
authored
chore: remove old proxyless implementation 4 (#7133)
* 1 * 2 * 2 * 4 * 5 * 6 * 7 * 8 * 10 * 9 * 11 * 12 * 13 * fix lint * fix legacy tests * 14 * fix build again * 14 * 15 * one more changes * make error more clean * fix tests 2 * fix test in ie * fix tests again
1 parent 52bed25 commit 10eef98

File tree

101 files changed

+866
-1502
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+866
-1502
lines changed

src/api/test-controller/execution-context.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createContext } from 'vm';
22
import Module from 'module';
33
import path from 'path';
44
import exportableLib from '../exportable-lib';
5-
import NODE_MODULES from '../../shared/node-modules-folder-name';
5+
import NODE_MODULES from '../../utils/node-modules-folder-name';
66

77
const OPTIONS_KEY = Symbol('options');
88

src/client/automation/cursor.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/shared/actions/cursor.ts renamed to src/client/automation/cursor/cursor.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
1-
import { CursorUI } from './types';
2-
import AxisValues, { AxisValuesData } from '../utils/values/axis-values';
3-
import { SharedWindow } from '../types';
1+
import { CursorUI } from '../types';
2+
import AxisValues, { AxisValuesData } from '../../core/utils/values/axis-values';
43
// @ts-ignore
5-
import { Promise } from '../../client/driver/deps/hammerhead';
4+
import { Promise } from '../../driver/deps/hammerhead';
65

7-
export default class Cursor<W extends SharedWindow> {
8-
private _activeWindow: W;
6+
export default class Cursor {
7+
private _activeWindow: Window;
98
private _x: number;
109
private _y: number;
1110
private readonly _ui: CursorUI;
1211

13-
public constructor (activeWin: W, ui: CursorUI) {
12+
public constructor (activeWin: Window, ui: CursorUI) {
1413
this._ui = ui;
1514

16-
// NOTE: the default position should be outside of the page (GH-794)
15+
// NOTE: the default position should be outside the page (GH-794)
1716
this._x = -1;
1817
this._y = -1;
1918

2019
this._activeWindow = activeWin;
2120
}
2221

23-
private _ensureActiveWindow (win: W): void {
22+
private _ensureActiveWindow (win: Window): void {
2423
if (this._activeWindow === win || this._activeWindow === win.parent)
2524
return;
2625

2726
if (this._activeWindow.parent !== win)
2827
this._activeWindow = win;
2928
}
3029

31-
public isActive (currWin: W): boolean {
30+
public isActive (currWin: Window): boolean {
3231
this._ensureActiveWindow(currWin);
3332

3433
return this._activeWindow === currWin;
3534
}
3635

37-
public setActiveWindow (win: W): void {
36+
public setActiveWindow (win: Window): void {
3837
this._activeWindow = win;
3938
}
4039

41-
public getActiveWindow (currWin: W): W {
40+
public getActiveWindow (currWin: Window): Window {
4241
this._ensureActiveWindow(currWin);
4342

4443
return this._activeWindow;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import testCafeUI from '../deps/testcafe-ui';
2+
import isIframeWindow from '../../../utils/is-window-in-iframe';
3+
import Cursor from './cursor';
4+
5+
const cursorUI = !isIframeWindow(window) ? testCafeUI.cursorUI : testCafeUI.iframeCursorUI;
6+
7+
export default new Cursor(window.top, cursorUI);

src/client/automation/get-element.js

Lines changed: 0 additions & 107 deletions
This file was deleted.

src/shared/actions/get-element.ts renamed to src/client/automation/get-element.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
import { adapter } from '../adapter';
2-
import isIframeWindow from './utils/is-window-iframe';
3-
import { AxisValuesData } from '../utils/values/axis-values';
4-
import { SharedWindow } from '../types';
1+
import { AxisValuesData } from '../core/utils/values/axis-values';
52
// @ts-ignore
6-
import { Promise, utils } from '../../client/driver/deps/hammerhead';
7-
// @ts-ignore
8-
import * as domUtils from '../../client/core/utils/dom';
3+
import { Promise, utils } from '../driver/deps/hammerhead';
4+
import * as domUtils from '../core/utils/dom';
5+
import * as positionUtils from '../core/utils/position';
6+
import getElementExceptUI from './utils/get-element-except-ui';
97

10-
function ensureImageMap<E> (imgElement: E, areaElement: E): Promise<E> {
8+
function ensureImageMap (imgElement: Element, areaElement: Element): Promise<HTMLElement> {
119
return Promise.resolve(domUtils.closest(areaElement, 'map'))
1210
.then((mapElement: HTMLMapElement) => {
1311
return mapElement && mapElement.name === domUtils.getImgMapName(imgElement) ? areaElement : imgElement;
1412
});
1513
}
1614

17-
function findElementOrNonEmptyChildFromPoint<E> (point: AxisValuesData<number>, element?: E): Promise<E | null> {
18-
return Promise.resolve(adapter.position.getElementFromPoint(point))
15+
function findElementOrNonEmptyChildFromPoint (point: AxisValuesData<number>, element?: HTMLElement): Promise<HTMLElement | null> {
16+
return Promise.resolve(positionUtils.getElementFromPoint(point))
1917
.then((topElement: HTMLElement) => {
2018
return Promise.resolve(domUtils.containsElement(element, topElement))
2119
.then((containsEl: HTMLElement) => containsEl && domUtils.getNodeText(topElement))
2220
.then((isNonEmptyChild: HTMLElement) => isNonEmptyChild || topElement && domUtils.isNodeEqual(topElement, element) ? topElement : null);
2321
});
2422
}
2523

26-
function correctTopElementByExpectedElement<E> (topElement: E, expectedElement?: E): Promise<E> | E {
24+
function correctTopElementByExpectedElement (topElement: Element, expectedElement?: HTMLElement): Promise<HTMLElement> | HTMLElement {
2725
if (!expectedElement || !topElement || domUtils.isNodeEqual(topElement, expectedElement))
2826
return topElement;
2927

@@ -56,24 +54,24 @@ function correctTopElementByExpectedElement<E> (topElement: E, expectedElement?:
5654
if (!shouldSearchForMultilineLink)
5755
return topElement;
5856

59-
return Promise.resolve(adapter.position.getClientDimensions(expectedElement))
57+
return Promise.resolve(positionUtils.getClientDimensions(expectedElement))
6058
.then((linkRect: any) => findElementOrNonEmptyChildFromPoint({ x: linkRect.right - 1, y: linkRect.top + 1 }, expectedElement)
6159
.then((el: any) => el || findElementOrNonEmptyChildFromPoint({ x: linkRect.left + 1, y: linkRect.bottom - 1 }, expectedElement))
6260
.then((el: any) => el || topElement));
6361
});
6462
}
6563

66-
export default function getElementFromPoint<E, W extends SharedWindow> (point: AxisValuesData<number>, win: W, expectedEl?: E): Promise<E> {
67-
return adapter.getElementExceptUI(point)
68-
.then((topElement: E) => {
64+
export default function getElementFromPoint (point: AxisValuesData<number>, win?: Window, expectedEl?: HTMLElement): Promise<HTMLElement> {
65+
return getElementExceptUI(point)
66+
.then((topElement: HTMLElement) => {
6967
// NOTE: when trying to get an element by elementFromPoint in iframe and the target
7068
// element is under any of shadow-ui elements, you will get null (only in IE).
7169
// In this case, you should hide a top window's shadow-ui root to obtain an element.
7270
let resChain = Promise.resolve(topElement);
7371

74-
if (!topElement && isIframeWindow(win) && point.x > 0 && point.y > 0)
75-
resChain = resChain.then(() => adapter.getElementExceptUI(point, true));
72+
if (!topElement && utils.dom.isIframeWindow(win || window) && point.x > 0 && point.y > 0)
73+
resChain = resChain.then(() => getElementExceptUI(point, true));
7674

77-
return resChain.then((element: E) => correctTopElementByExpectedElement(element, expectedEl));
75+
return resChain.then((element: HTMLElement) => correctTopElementByExpectedElement(element, expectedEl));
7876
});
7977
}

src/client/automation/index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
// NOTE: Initializer should be the first
2-
import './shared-adapter-initializer';
3-
41
import hammerhead from './deps/hammerhead';
52
import DispatchEventAutomation from './playback/dispatch-event';
63
import SetScrollAutomation from './playback/set-scroll';
74
import ScrollIntoViewAutomation from './playback/scroll-into-view';
8-
import ClickAutomation from '../../shared/actions/automations/click';
5+
import ClickAutomation from './playback/click';
96
import SelectChildClickAutomation from './playback/click/select-child';
107
import DblClickAutomation from './playback/dblclick';
118
import DragToOffsetAutomation from './playback/drag/to-offset';
@@ -22,16 +19,16 @@ import {
2219
ClickOptions,
2320
TypeOptions,
2421
} from '../../test-run/commands/options';
25-
import AutomationSettings from '../../shared/actions/automations/settings';
26-
import { getOffsetOptions } from '../../shared/actions/utils/offsets';
22+
import AutomationSettings from './settings';
23+
import { getOffsetOptions } from '../core/utils/offsets';
2724
import { getNextFocusableElement } from './playback/press/utils';
2825
import SHORTCUT_TYPE from './playback/press/shortcut-type';
2926
import { getSelectionCoordinatesByPosition } from './playback/select/utils';
3027
import getElementFromPoint from './get-element';
3128
import calculateSelectTextArguments from './playback/select/calculate-select-text-arguments';
3229
import ERROR_TYPES from '../../shared/errors/automation-errors';
3330
import cursor from './cursor';
34-
import MoveAutomation from '../../shared/actions/automations/move';
31+
import MoveAutomation from './move';
3532

3633

3734
const exports = {};

0 commit comments

Comments
 (0)