Skip to content

Commit 6f60ece

Browse files
committed
chore: Conform with new type definitions for WebDriverIO execute method
1 parent 2b4cf2e commit 6f60ece

File tree

3 files changed

+31
-38
lines changed

3 files changed

+31
-38
lines changed

web/packages/selfhosted/test/integration_tests/context_menu_position/test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ async function setDirection(
1515
direction: string,
1616
) {
1717
await browser.execute(
18-
(element, direction) => {
19-
const el = element as unknown as HTMLElement;
20-
el.dir = direction;
18+
({ el, dir }: { el: HTMLElement; dir: string }) => {
19+
el.dir = dir;
2120
},
22-
element,
23-
direction,
21+
{ el: element, dir: direction },
2422
);
2523
}
2624

web/packages/selfhosted/test/integration_tests/external_interface/test.ts

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,36 @@ interface RuffleTest {
2323
}
2424

2525
declare global {
26-
// eslint-disable-next-line @typescript-eslint/no-namespace
27-
namespace WebdriverIO {
28-
interface Element {
29-
// ExternalInterface makes whatever functions exist "magically" - so let's just declare here for type's sake
26+
interface HTMLElement {
27+
// ExternalInterface makes whatever functions exist "magically" - so let's just declare here for type's sake
3028

31-
// Logs all arguments to trace
32-
log: (...args: unknown[]) => void;
29+
// Logs all arguments to trace
30+
log: (...args: unknown[]) => void;
3331

34-
// Calls `ExternalInterface.call(name, ...args)` after a delay (to avoid reentrancy)
35-
callMethodWithDelay: (name: string, ...args: unknown[]) => void;
32+
// Calls `ExternalInterface.call(name, ...args)` after a delay (to avoid reentrancy)
33+
callMethodWithDelay: (name: string, ...args: unknown[]) => void;
3634

37-
// Calls `ExternalInterface.call(name, ...args)` immediately (causing reentrancy)
38-
callMethodImmediately: (name: string, ...args: unknown[]) => void;
35+
// Calls `ExternalInterface.call(name, ...args)` immediately (causing reentrancy)
36+
callMethodImmediately: (name: string, ...args: unknown[]) => void;
3937

40-
// Returns `value`
41-
returnAValue: <T>(value: T) => T;
38+
// Returns `value`
39+
returnAValue: <T>(value: T) => T;
4240

43-
// Should return an exception...
44-
throwAnException: () => void;
41+
// Should return an exception...
42+
throwAnException: () => void;
4543

46-
// Calls `ExternalInterface.marshallExceptions = value`
47-
setMarshallExceptions: (value: boolean) => void;
44+
// Calls `ExternalInterface.marshallExceptions = value`
45+
setMarshallExceptions: (value: boolean) => void;
4846

49-
// Calls `ExternalInterface.addCallback(name, function() { return returnValue; })`
50-
addAnotherCallback: (name: string, returnValue: unknown) => void;
47+
// Calls `ExternalInterface.addCallback(name, function() { return returnValue; })`
48+
addAnotherCallback: (name: string, returnValue: unknown) => void;
5149

52-
// Going to be redefined as part of a test
53-
redefinedMethod: () => string;
50+
// Going to be redefined as part of a test
51+
redefinedMethod: () => string;
5452

55-
ruffle<V extends keyof Player.APIVersions = 1>(
56-
version?: V,
57-
): Player.APIVersions[V];
58-
}
53+
ruffle<V extends keyof Player.APIVersions = 1>(
54+
version?: V,
55+
): Player.APIVersions[V];
5956
}
6057

6158
interface Window {
@@ -102,11 +99,9 @@ ExternalInterface.objectID: "flash_name"
10299
return called;
103100
},
104101
log: function (...args: any[]) {
105-
(
106-
document.getElementById(
107-
"flash_id",
108-
) as unknown as WebdriverIO.Element
109-
).log(...args);
102+
(document.getElementById("flash_id") as HTMLElement).log(
103+
...args,
104+
);
110105
},
111106
};
112107
});

web/packages/selfhosted/test/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ export async function closeAllModals(
213213
browser: WebdriverIO.Browser,
214214
player: ChainablePromiseElement,
215215
) {
216+
const modals = await player.$$(".modal:not(.hidden)");
216217
await browser.execute(
217-
(modals) => {
218-
for (const modal of modals) {
219-
const m = modal as unknown as HTMLElement;
218+
({ modals }) => {
219+
for (const m of modals) {
220220
const cl = m.querySelector(".close-modal")! as HTMLElement;
221221
cl.click();
222222
}
223223
},
224-
await player.$$(".modal:not(.hidden)"),
224+
{ modals },
225225
);
226226
}
227227

0 commit comments

Comments
 (0)