@lvce-editor/test-worker 11.1.0 → 11.3.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 +88 -63
- 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,18 +1159,21 @@ 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
|
|
1137
1172
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
|
|
1138
1173
|
};
|
|
1174
|
+
const readFile$1 = async uri => {
|
|
1175
|
+
return invoke('FileSystem.readFile', uri);
|
|
1176
|
+
};
|
|
1139
1177
|
const getPreference = async key => {
|
|
1140
1178
|
return await invoke('Preferences.get', key);
|
|
1141
1179
|
};
|
|
@@ -1499,17 +1537,17 @@ const addTest = (name, fn) => {
|
|
|
1499
1537
|
name
|
|
1500
1538
|
});
|
|
1501
1539
|
};
|
|
1502
|
-
const getTests = () => {
|
|
1503
|
-
const tests = state.pendingTests;
|
|
1504
|
-
state.pendingTests = [];
|
|
1505
|
-
return tests;
|
|
1506
|
-
};
|
|
1507
1540
|
const setMockRpc = mockRpc => {
|
|
1508
1541
|
object(mockRpc);
|
|
1509
1542
|
string$1(mockRpc.name);
|
|
1510
1543
|
state.mockRpcs[mockRpc.name] = mockRpc;
|
|
1511
1544
|
};
|
|
1512
1545
|
|
|
1546
|
+
const performAction = async (locator, action, options) => {
|
|
1547
|
+
const invoke = getLocatorInvoke(locator);
|
|
1548
|
+
return invoke('TestFrameWork.performAction', locator, action, options);
|
|
1549
|
+
};
|
|
1550
|
+
|
|
1513
1551
|
const toButtonNumber = buttonType => {
|
|
1514
1552
|
switch (buttonType) {
|
|
1515
1553
|
case 'left':
|
|
@@ -1523,13 +1561,6 @@ const toButtonNumber = buttonType => {
|
|
|
1523
1561
|
}
|
|
1524
1562
|
};
|
|
1525
1563
|
|
|
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
1564
|
class Locator {
|
|
1534
1565
|
constructor(selector, {
|
|
1535
1566
|
hasText = '',
|
|
@@ -1558,18 +1589,18 @@ class Locator {
|
|
|
1558
1589
|
return performAction(this, 'hover', options);
|
|
1559
1590
|
}
|
|
1560
1591
|
first() {
|
|
1561
|
-
return
|
|
1592
|
+
return new Locator(this._selector, {
|
|
1562
1593
|
nth: 0
|
|
1563
1594
|
});
|
|
1564
1595
|
}
|
|
1565
1596
|
locator(subSelector) {
|
|
1566
1597
|
if (this._nth !== -1) {
|
|
1567
|
-
return
|
|
1598
|
+
return new Locator(`${this._selector}:nth-of-type(${this._nth + 1}) ${subSelector}`);
|
|
1568
1599
|
}
|
|
1569
|
-
return
|
|
1600
|
+
return new Locator(`${this._selector} ${subSelector}`);
|
|
1570
1601
|
}
|
|
1571
1602
|
nth(nth) {
|
|
1572
|
-
return
|
|
1603
|
+
return new Locator(this._selector, {
|
|
1573
1604
|
nth
|
|
1574
1605
|
});
|
|
1575
1606
|
}
|
|
@@ -1587,6 +1618,10 @@ class Locator {
|
|
|
1587
1618
|
}
|
|
1588
1619
|
}
|
|
1589
1620
|
|
|
1621
|
+
const createLocator = (selector, options = {}) => {
|
|
1622
|
+
return new Locator(selector, options);
|
|
1623
|
+
};
|
|
1624
|
+
|
|
1590
1625
|
const getTmpDir$1 = async () => {
|
|
1591
1626
|
return 'memfs://';
|
|
1592
1627
|
};
|
|
@@ -1594,7 +1629,7 @@ const test = async (name, fn) => {
|
|
|
1594
1629
|
nameAnonymousFunction(fn, `test/${name}`);
|
|
1595
1630
|
addTest(name, fn);
|
|
1596
1631
|
};
|
|
1597
|
-
|
|
1632
|
+
const skipTest = async id => {
|
|
1598
1633
|
const state = 'skip';
|
|
1599
1634
|
const background = 'yellow';
|
|
1600
1635
|
const text = `test skipped ${id}`;
|
|
@@ -2574,24 +2609,25 @@ const toFileUrl = url => {
|
|
|
2574
2609
|
return `file://${rest}`;
|
|
2575
2610
|
};
|
|
2576
2611
|
|
|
2577
|
-
|
|
2578
|
-
const
|
|
2612
|
+
const getDirents = async fileUrl => {
|
|
2613
|
+
const allDirents = [];
|
|
2579
2614
|
const dirents = await invoke('FileSystem.readDirWithFileTypes', fileUrl);
|
|
2580
2615
|
for (const dirent of dirents) {
|
|
2581
2616
|
if (dirent.type === Directory) {
|
|
2582
|
-
await getDirents(
|
|
2617
|
+
const subDirents = await getDirents(`${fileUrl}/${dirent.name}`);
|
|
2618
|
+
allDirents.push(...subDirents);
|
|
2583
2619
|
} else {
|
|
2584
2620
|
allDirents.push(`${fileUrl}/${dirent.name}`);
|
|
2585
2621
|
}
|
|
2586
2622
|
}
|
|
2623
|
+
return allDirents;
|
|
2587
2624
|
};
|
|
2588
2625
|
const getFileMapNode = async url => {
|
|
2589
2626
|
const fileUrl = toFileUrl(url);
|
|
2590
|
-
const allFiles =
|
|
2591
|
-
await getDirents(allFiles, fileUrl);
|
|
2627
|
+
const allFiles = await getDirents(fileUrl);
|
|
2592
2628
|
const fileMap = Object.create(null);
|
|
2593
2629
|
for (const filePath of allFiles) {
|
|
2594
|
-
const content = await
|
|
2630
|
+
const content = await readFile$1(filePath);
|
|
2595
2631
|
const relativePaths = filePath.slice(fileUrl.length + 1);
|
|
2596
2632
|
fileMap[relativePaths] = content;
|
|
2597
2633
|
}
|
|
@@ -3061,7 +3097,22 @@ const Main = {
|
|
|
3061
3097
|
splitRight
|
|
3062
3098
|
};
|
|
3063
3099
|
|
|
3100
|
+
const open$2 = async id => {
|
|
3101
|
+
await invoke('Layout.showPanel', id);
|
|
3102
|
+
};
|
|
3103
|
+
const openProblems = async () => {
|
|
3104
|
+
await open$2('Problems');
|
|
3105
|
+
await invoke('Panel.selectIndex', 0);
|
|
3106
|
+
};
|
|
3107
|
+
|
|
3108
|
+
const Panel = {
|
|
3109
|
+
__proto__: null,
|
|
3110
|
+
open: open$2,
|
|
3111
|
+
openProblems
|
|
3112
|
+
};
|
|
3113
|
+
|
|
3064
3114
|
const show$4 = async () => {
|
|
3115
|
+
await open$2('Output');
|
|
3065
3116
|
await invoke('Panel.selectIndex', 1);
|
|
3066
3117
|
};
|
|
3067
3118
|
const handleFilterInput$1 = async text => {
|
|
@@ -3086,20 +3137,6 @@ const Output = {
|
|
|
3086
3137
|
show: show$4
|
|
3087
3138
|
};
|
|
3088
3139
|
|
|
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
3140
|
const getIsFirefox = () => {
|
|
3104
3141
|
if (typeof navigator === 'undefined') {
|
|
3105
3142
|
return false;
|
|
@@ -3428,7 +3465,7 @@ const handleInputContextMenu = async (name, button, x, y) => {
|
|
|
3428
3465
|
await invoke('Search.handleInputConextMenu', name, button, x, y);
|
|
3429
3466
|
};
|
|
3430
3467
|
const handleContextMenu$2 = async (button, x, y) => {
|
|
3431
|
-
await invoke('Search.handleContextMenu',
|
|
3468
|
+
await invoke('Search.handleContextMenu', button, x, y);
|
|
3432
3469
|
};
|
|
3433
3470
|
|
|
3434
3471
|
const Search = {
|
|
@@ -3486,8 +3523,7 @@ const clear = async searchValue => {
|
|
|
3486
3523
|
return invoke('Settings.clear', searchValue, Script);
|
|
3487
3524
|
};
|
|
3488
3525
|
const clearHistory = async () => {
|
|
3489
|
-
|
|
3490
|
-
return invoke('Settings.clearHistory', searchValue, Script);
|
|
3526
|
+
return invoke('Settings.clearHistory');
|
|
3491
3527
|
};
|
|
3492
3528
|
const selectTab = async tabId => {
|
|
3493
3529
|
return invoke('Settings.handleClickTab', tabId);
|
|
@@ -3720,7 +3756,7 @@ const fromId = async webViewId => {
|
|
|
3720
3756
|
set(webViewId, rpc);
|
|
3721
3757
|
return {
|
|
3722
3758
|
locator(selector, options) {
|
|
3723
|
-
const baseLocator =
|
|
3759
|
+
const baseLocator = createLocator(selector, options);
|
|
3724
3760
|
|
|
3725
3761
|
// @ts-ignore
|
|
3726
3762
|
baseLocator.webViewId = webViewId;
|
|
@@ -3787,7 +3823,7 @@ const createApi = (platform, assetDir) => {
|
|
|
3787
3823
|
IframeInspector,
|
|
3788
3824
|
KeyBindingsEditor,
|
|
3789
3825
|
KeyBoard,
|
|
3790
|
-
Locator:
|
|
3826
|
+
Locator: createLocator,
|
|
3791
3827
|
Main,
|
|
3792
3828
|
Output,
|
|
3793
3829
|
Panel,
|
|
@@ -3974,22 +4010,11 @@ const execute = async (href, platform, assetDir) => {
|
|
|
3974
4010
|
}
|
|
3975
4011
|
if (module.test) {
|
|
3976
4012
|
if (module.skip) {
|
|
3977
|
-
await
|
|
4013
|
+
await skipTest(module.name);
|
|
3978
4014
|
} else {
|
|
3979
4015
|
await executeTest(module.name, module.test, globals);
|
|
3980
4016
|
}
|
|
3981
|
-
} else {
|
|
3982
|
-
const tests = getTests();
|
|
3983
|
-
for (const test of tests) {
|
|
3984
|
-
await executeTest(test.name, test.fn);
|
|
3985
|
-
}
|
|
3986
4017
|
}
|
|
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
4018
|
// TODO maybe setup file watcher earlier, to not miss events?
|
|
3994
4019
|
|
|
3995
4020
|
push({
|