@lvce-editor/test-worker 11.1.0 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +19 -3
- package/dist/testWorkerMain.js +76 -54
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ interface LocatorClickOptions {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
interface ILocatorExternal {
|
|
22
|
-
readonly click: (options
|
|
22
|
+
readonly click: (options?: LocatorClickOptions) => Promise<void>;
|
|
23
23
|
readonly dispatchEvent: (type: string, init: string) => Promise<void>;
|
|
24
24
|
readonly first: () => ILocatorExternal;
|
|
25
25
|
readonly hover: () => Promise<void>;
|
|
@@ -28,8 +28,24 @@ interface ILocatorExternal {
|
|
|
28
28
|
readonly type: (text: string) => Promise<void>;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
interface
|
|
32
|
-
|
|
31
|
+
interface ILocatorCreateOptions {
|
|
32
|
+
readonly hasText?: string;
|
|
33
|
+
readonly nth?: number;
|
|
34
|
+
}
|
|
35
|
+
export declare class Locator implements ILocator {
|
|
36
|
+
readonly _selector: any;
|
|
37
|
+
readonly _nth: number;
|
|
38
|
+
readonly _hasText: string;
|
|
39
|
+
constructor(selector: any, { hasText, nth }?: ILocatorCreateOptions);
|
|
40
|
+
click({ button }?: {
|
|
41
|
+
readonly button?: string;
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
hover(): Promise<void>;
|
|
44
|
+
first(): any;
|
|
45
|
+
locator(subSelector: string): any;
|
|
46
|
+
nth(nth: number): any;
|
|
47
|
+
type(text: string): Promise<void>;
|
|
48
|
+
dispatchEvent(type: string, init: any): Promise<void>;
|
|
33
49
|
}
|
|
34
50
|
|
|
35
51
|
export interface Diagnostic {
|
package/dist/testWorkerMain.js
CHANGED
|
@@ -517,7 +517,7 @@ const callbacks$1 = Object.create(null);
|
|
|
517
517
|
const get$2 = id => {
|
|
518
518
|
return callbacks$1[id];
|
|
519
519
|
};
|
|
520
|
-
const remove$
|
|
520
|
+
const remove$2 = id => {
|
|
521
521
|
delete callbacks$1[id];
|
|
522
522
|
};
|
|
523
523
|
class JsonRpcError extends Error {
|
|
@@ -670,7 +670,7 @@ const resolve$1 = (id, response) => {
|
|
|
670
670
|
return;
|
|
671
671
|
}
|
|
672
672
|
fn(response);
|
|
673
|
-
remove$
|
|
673
|
+
remove$2(id);
|
|
674
674
|
};
|
|
675
675
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
676
676
|
const getErrorType = prettyError => {
|
|
@@ -713,7 +713,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
713
713
|
}
|
|
714
714
|
};
|
|
715
715
|
};
|
|
716
|
-
const create$1$
|
|
716
|
+
const create$1$1 = (id, error) => {
|
|
717
717
|
return {
|
|
718
718
|
jsonrpc: Two$1,
|
|
719
719
|
id,
|
|
@@ -724,7 +724,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
724
724
|
const prettyError = preparePrettyError(error);
|
|
725
725
|
logError(error, prettyError);
|
|
726
726
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
727
|
-
return create$1$
|
|
727
|
+
return create$1$1(id, errorProperty);
|
|
728
728
|
};
|
|
729
729
|
const create$3 = (message, result) => {
|
|
730
730
|
return {
|
|
@@ -1063,7 +1063,7 @@ const create$2 = async ({
|
|
|
1063
1063
|
messagePort: port2
|
|
1064
1064
|
});
|
|
1065
1065
|
};
|
|
1066
|
-
const create$1
|
|
1066
|
+
const create$1 = async ({
|
|
1067
1067
|
commandMap
|
|
1068
1068
|
}) => {
|
|
1069
1069
|
// TODO create a commandMap per rpc instance
|
|
@@ -1075,7 +1075,26 @@ const create$1$1 = async ({
|
|
|
1075
1075
|
};
|
|
1076
1076
|
const WebWorkerRpcClient = {
|
|
1077
1077
|
__proto__: null,
|
|
1078
|
-
create: create$1
|
|
1078
|
+
create: create$1
|
|
1079
|
+
};
|
|
1080
|
+
const createMockRpc = ({
|
|
1081
|
+
commandMap
|
|
1082
|
+
}) => {
|
|
1083
|
+
const invocations = [];
|
|
1084
|
+
const invoke = (method, ...params) => {
|
|
1085
|
+
invocations.push([method, ...params]);
|
|
1086
|
+
const command = commandMap[method];
|
|
1087
|
+
if (!command) {
|
|
1088
|
+
throw new Error(`command ${method} not found`);
|
|
1089
|
+
}
|
|
1090
|
+
return command(...params);
|
|
1091
|
+
};
|
|
1092
|
+
const mockRpc = {
|
|
1093
|
+
invocations,
|
|
1094
|
+
invoke,
|
|
1095
|
+
invokeAndTransfer: invoke
|
|
1096
|
+
};
|
|
1097
|
+
return mockRpc;
|
|
1079
1098
|
};
|
|
1080
1099
|
|
|
1081
1100
|
const Directory = 3;
|
|
@@ -1096,8 +1115,12 @@ const set$3 = (id, rpc) => {
|
|
|
1096
1115
|
const get$1 = id => {
|
|
1097
1116
|
return rpcs[id];
|
|
1098
1117
|
};
|
|
1118
|
+
const remove$1 = id => {
|
|
1119
|
+
delete rpcs[id];
|
|
1120
|
+
};
|
|
1099
1121
|
|
|
1100
|
-
|
|
1122
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1123
|
+
const create = rpcId => {
|
|
1101
1124
|
return {
|
|
1102
1125
|
async dispose() {
|
|
1103
1126
|
const rpc = get$1(rpcId);
|
|
@@ -1115,6 +1138,18 @@ const create$1 = rpcId => {
|
|
|
1115
1138
|
// @ts-ignore
|
|
1116
1139
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1117
1140
|
},
|
|
1141
|
+
registerMockRpc(commandMap) {
|
|
1142
|
+
const mockRpc = createMockRpc({
|
|
1143
|
+
commandMap
|
|
1144
|
+
});
|
|
1145
|
+
set$3(rpcId, mockRpc);
|
|
1146
|
+
// @ts-ignore
|
|
1147
|
+
mockRpc[Symbol.dispose] = () => {
|
|
1148
|
+
remove$1(rpcId);
|
|
1149
|
+
};
|
|
1150
|
+
// @ts-ignore
|
|
1151
|
+
return mockRpc;
|
|
1152
|
+
},
|
|
1118
1153
|
set(rpc) {
|
|
1119
1154
|
set$3(rpcId, rpc);
|
|
1120
1155
|
}
|
|
@@ -1124,13 +1159,13 @@ const create$1 = rpcId => {
|
|
|
1124
1159
|
const {
|
|
1125
1160
|
invoke: invoke$1,
|
|
1126
1161
|
set: set$2
|
|
1127
|
-
} = create
|
|
1162
|
+
} = create(EditorWorker);
|
|
1128
1163
|
|
|
1129
1164
|
const {
|
|
1130
1165
|
invoke,
|
|
1131
1166
|
invokeAndTransfer,
|
|
1132
1167
|
set: set$1
|
|
1133
|
-
} = create
|
|
1168
|
+
} = create(RendererWorker);
|
|
1134
1169
|
const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
1135
1170
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1136
1171
|
// @ts-ignore
|
|
@@ -1499,17 +1534,17 @@ const addTest = (name, fn) => {
|
|
|
1499
1534
|
name
|
|
1500
1535
|
});
|
|
1501
1536
|
};
|
|
1502
|
-
const getTests = () => {
|
|
1503
|
-
const tests = state.pendingTests;
|
|
1504
|
-
state.pendingTests = [];
|
|
1505
|
-
return tests;
|
|
1506
|
-
};
|
|
1507
1537
|
const setMockRpc = mockRpc => {
|
|
1508
1538
|
object(mockRpc);
|
|
1509
1539
|
string$1(mockRpc.name);
|
|
1510
1540
|
state.mockRpcs[mockRpc.name] = mockRpc;
|
|
1511
1541
|
};
|
|
1512
1542
|
|
|
1543
|
+
const performAction = async (locator, action, options) => {
|
|
1544
|
+
const invoke = getLocatorInvoke(locator);
|
|
1545
|
+
return invoke('TestFrameWork.performAction', locator, action, options);
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1513
1548
|
const toButtonNumber = buttonType => {
|
|
1514
1549
|
switch (buttonType) {
|
|
1515
1550
|
case 'left':
|
|
@@ -1523,13 +1558,6 @@ const toButtonNumber = buttonType => {
|
|
|
1523
1558
|
}
|
|
1524
1559
|
};
|
|
1525
1560
|
|
|
1526
|
-
const create = (selector, options = {}) => {
|
|
1527
|
-
return new Locator(selector, options);
|
|
1528
|
-
};
|
|
1529
|
-
const performAction = async (locator, action, options) => {
|
|
1530
|
-
const invoke = getLocatorInvoke(locator);
|
|
1531
|
-
return invoke('TestFrameWork.performAction', locator, action, options);
|
|
1532
|
-
};
|
|
1533
1561
|
class Locator {
|
|
1534
1562
|
constructor(selector, {
|
|
1535
1563
|
hasText = '',
|
|
@@ -1558,18 +1586,18 @@ class Locator {
|
|
|
1558
1586
|
return performAction(this, 'hover', options);
|
|
1559
1587
|
}
|
|
1560
1588
|
first() {
|
|
1561
|
-
return
|
|
1589
|
+
return new Locator(this._selector, {
|
|
1562
1590
|
nth: 0
|
|
1563
1591
|
});
|
|
1564
1592
|
}
|
|
1565
1593
|
locator(subSelector) {
|
|
1566
1594
|
if (this._nth !== -1) {
|
|
1567
|
-
return
|
|
1595
|
+
return new Locator(`${this._selector}:nth-of-type(${this._nth + 1}) ${subSelector}`);
|
|
1568
1596
|
}
|
|
1569
|
-
return
|
|
1597
|
+
return new Locator(`${this._selector} ${subSelector}`);
|
|
1570
1598
|
}
|
|
1571
1599
|
nth(nth) {
|
|
1572
|
-
return
|
|
1600
|
+
return new Locator(this._selector, {
|
|
1573
1601
|
nth
|
|
1574
1602
|
});
|
|
1575
1603
|
}
|
|
@@ -1587,6 +1615,10 @@ class Locator {
|
|
|
1587
1615
|
}
|
|
1588
1616
|
}
|
|
1589
1617
|
|
|
1618
|
+
const createLocator = (selector, options = {}) => {
|
|
1619
|
+
return new Locator(selector, options);
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1590
1622
|
const getTmpDir$1 = async () => {
|
|
1591
1623
|
return 'memfs://';
|
|
1592
1624
|
};
|
|
@@ -1594,7 +1626,7 @@ const test = async (name, fn) => {
|
|
|
1594
1626
|
nameAnonymousFunction(fn, `test/${name}`);
|
|
1595
1627
|
addTest(name, fn);
|
|
1596
1628
|
};
|
|
1597
|
-
|
|
1629
|
+
const skipTest = async id => {
|
|
1598
1630
|
const state = 'skip';
|
|
1599
1631
|
const background = 'yellow';
|
|
1600
1632
|
const text = `test skipped ${id}`;
|
|
@@ -3061,7 +3093,22 @@ const Main = {
|
|
|
3061
3093
|
splitRight
|
|
3062
3094
|
};
|
|
3063
3095
|
|
|
3096
|
+
const open$2 = async id => {
|
|
3097
|
+
await invoke('Layout.showPanel', id);
|
|
3098
|
+
};
|
|
3099
|
+
const openProblems = async () => {
|
|
3100
|
+
await open$2('Problems');
|
|
3101
|
+
await invoke('Panel.selectIndex', 0);
|
|
3102
|
+
};
|
|
3103
|
+
|
|
3104
|
+
const Panel = {
|
|
3105
|
+
__proto__: null,
|
|
3106
|
+
open: open$2,
|
|
3107
|
+
openProblems
|
|
3108
|
+
};
|
|
3109
|
+
|
|
3064
3110
|
const show$4 = async () => {
|
|
3111
|
+
await open$2('Output');
|
|
3065
3112
|
await invoke('Panel.selectIndex', 1);
|
|
3066
3113
|
};
|
|
3067
3114
|
const handleFilterInput$1 = async text => {
|
|
@@ -3086,20 +3133,6 @@ const Output = {
|
|
|
3086
3133
|
show: show$4
|
|
3087
3134
|
};
|
|
3088
3135
|
|
|
3089
|
-
const open$2 = async id => {
|
|
3090
|
-
await invoke('Layout.showPanel', id);
|
|
3091
|
-
};
|
|
3092
|
-
const openProblems = async () => {
|
|
3093
|
-
await open$2('Problems');
|
|
3094
|
-
await invoke('Panel.selectIndex', 0);
|
|
3095
|
-
};
|
|
3096
|
-
|
|
3097
|
-
const Panel = {
|
|
3098
|
-
__proto__: null,
|
|
3099
|
-
open: open$2,
|
|
3100
|
-
openProblems
|
|
3101
|
-
};
|
|
3102
|
-
|
|
3103
3136
|
const getIsFirefox = () => {
|
|
3104
3137
|
if (typeof navigator === 'undefined') {
|
|
3105
3138
|
return false;
|
|
@@ -3720,7 +3753,7 @@ const fromId = async webViewId => {
|
|
|
3720
3753
|
set(webViewId, rpc);
|
|
3721
3754
|
return {
|
|
3722
3755
|
locator(selector, options) {
|
|
3723
|
-
const baseLocator =
|
|
3756
|
+
const baseLocator = createLocator(selector, options);
|
|
3724
3757
|
|
|
3725
3758
|
// @ts-ignore
|
|
3726
3759
|
baseLocator.webViewId = webViewId;
|
|
@@ -3787,7 +3820,7 @@ const createApi = (platform, assetDir) => {
|
|
|
3787
3820
|
IframeInspector,
|
|
3788
3821
|
KeyBindingsEditor,
|
|
3789
3822
|
KeyBoard,
|
|
3790
|
-
Locator:
|
|
3823
|
+
Locator: createLocator,
|
|
3791
3824
|
Main,
|
|
3792
3825
|
Output,
|
|
3793
3826
|
Panel,
|
|
@@ -3974,22 +4007,11 @@ const execute = async (href, platform, assetDir) => {
|
|
|
3974
4007
|
}
|
|
3975
4008
|
if (module.test) {
|
|
3976
4009
|
if (module.skip) {
|
|
3977
|
-
await
|
|
4010
|
+
await skipTest(module.name);
|
|
3978
4011
|
} else {
|
|
3979
4012
|
await executeTest(module.name, module.test, globals);
|
|
3980
4013
|
}
|
|
3981
|
-
} else {
|
|
3982
|
-
const tests = getTests();
|
|
3983
|
-
for (const test of tests) {
|
|
3984
|
-
await executeTest(test.name, test.fn);
|
|
3985
|
-
}
|
|
3986
4014
|
}
|
|
3987
|
-
// 3. if import fails, display error message
|
|
3988
|
-
|
|
3989
|
-
// 4. run the test
|
|
3990
|
-
// 5. if test fails, display error message
|
|
3991
|
-
// 6. if test succeeds, display success message
|
|
3992
|
-
|
|
3993
4015
|
// TODO maybe setup file watcher earlier, to not miss events?
|
|
3994
4016
|
|
|
3995
4017
|
push({
|