@lvce-editor/test-worker 6.2.0 → 6.4.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 +39 -1
- package/dist/testWorkerMain.js +99 -22
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
|
|
2
|
+
export interface LocatorExpect {
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
negated: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
readonly checkSingleElementCondition: (fnName: string, options?: any) => Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
readonly checkMultiElementCondition: (fnName: string, options: any) => Promise<void>;
|
|
15
|
+
readonly toBeVisible: () => Promise<void>;
|
|
16
|
+
readonly toHaveText: (text: string) => Promise<void>;
|
|
17
|
+
readonly toContainText: (text: string) => Promise<void>;
|
|
18
|
+
readonly toHaveValue: (value: string) => Promise<void>;
|
|
19
|
+
readonly toBeFocused: () => Promise<void>;
|
|
20
|
+
readonly toHaveCSS: (key: string, value: string) => Promise<void>;
|
|
21
|
+
readonly toHaveAttribute: (key: string, value: string) => Promise<void>;
|
|
22
|
+
readonly toHaveJSProperty: (key: string, value: any) => Promise<void>;
|
|
23
|
+
readonly toHaveClass: (className: string) => Promise<void>;
|
|
24
|
+
readonly toHaveId: (id: string) => Promise<void>;
|
|
25
|
+
readonly toHaveCount: (count: number) => Promise<void>;
|
|
26
|
+
readonly toBeHidden: () => Promise<void>;
|
|
27
|
+
readonly not: LocatorExpect;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
2
32
|
interface LocatorClickOptions {
|
|
3
33
|
readonly button?: string;
|
|
4
34
|
}
|
|
@@ -27,6 +57,7 @@ export interface FileSystemTmpDirOptions {
|
|
|
27
57
|
|
|
28
58
|
interface Workspace {
|
|
29
59
|
readonly openTmpDir: () => Promise<string>;
|
|
60
|
+
readonly resolveFileUrl: (url: string) => string;
|
|
30
61
|
readonly setPath: (path: string) => Promise<void>;
|
|
31
62
|
}
|
|
32
63
|
|
|
@@ -162,6 +193,12 @@ interface EditorHover {
|
|
|
162
193
|
readonly show: () => Promise<void>;
|
|
163
194
|
}
|
|
164
195
|
|
|
196
|
+
interface EditorRename {
|
|
197
|
+
readonly accept: () => Promise<void>;
|
|
198
|
+
readonly cancel: () => Promise<void>;
|
|
199
|
+
readonly handleInput: (value: string) => Promise<void>;
|
|
200
|
+
}
|
|
201
|
+
|
|
165
202
|
interface EditorSourceAction {
|
|
166
203
|
readonly selectCurrentIndex: () => Promise<void>;
|
|
167
204
|
readonly selectIndex: (index: number) => Promise<void>;
|
|
@@ -486,6 +523,7 @@ export interface TestApi {
|
|
|
486
523
|
readonly Editor: Editor
|
|
487
524
|
readonly EditorCompletion: EditorCompletion
|
|
488
525
|
readonly EditorHover: EditorHover
|
|
526
|
+
readonly EditorRename: EditorRename
|
|
489
527
|
readonly EditorSourceAction: EditorSourceAction
|
|
490
528
|
readonly Explorer: Explorer
|
|
491
529
|
readonly Extension: Extension
|
|
@@ -513,7 +551,7 @@ export interface TestApi {
|
|
|
513
551
|
readonly TitleBarMenuBar: TitleBarMenuBar
|
|
514
552
|
readonly Url: Url
|
|
515
553
|
readonly WebView: WebView
|
|
516
|
-
readonly expect:
|
|
554
|
+
readonly expect: (locator: ILocatorExternal) => LocatorExpect
|
|
517
555
|
readonly Locator: (selector: string, option?: any) => ILocatorExternal
|
|
518
556
|
}
|
|
519
557
|
|
package/dist/testWorkerMain.js
CHANGED
|
@@ -1034,6 +1034,7 @@ const WebWorkerRpcClient = {
|
|
|
1034
1034
|
create: create$2
|
|
1035
1035
|
};
|
|
1036
1036
|
|
|
1037
|
+
const EditorWorker = 99;
|
|
1037
1038
|
const RendererWorker = 1;
|
|
1038
1039
|
const TestWorker = 9001;
|
|
1039
1040
|
|
|
@@ -1079,6 +1080,31 @@ const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
|
1079
1080
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
|
|
1080
1081
|
};
|
|
1081
1082
|
|
|
1083
|
+
const createLazyRpc = rpcId => {
|
|
1084
|
+
let rpcPromise;
|
|
1085
|
+
let factory;
|
|
1086
|
+
const createRpc = async () => {
|
|
1087
|
+
const rpc = await factory();
|
|
1088
|
+
set$2(rpcId, rpc);
|
|
1089
|
+
};
|
|
1090
|
+
const ensureRpc = async () => {
|
|
1091
|
+
if (!rpcPromise) {
|
|
1092
|
+
rpcPromise = createRpc();
|
|
1093
|
+
}
|
|
1094
|
+
await rpcPromise;
|
|
1095
|
+
};
|
|
1096
|
+
return {
|
|
1097
|
+
setFactory(value) {
|
|
1098
|
+
factory = value;
|
|
1099
|
+
},
|
|
1100
|
+
async invoke(method, ...params) {
|
|
1101
|
+
await ensureRpc();
|
|
1102
|
+
const rpc = get$1(rpcId);
|
|
1103
|
+
return rpc.invoke(method, ...params);
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1082
1108
|
const callFunction = async (fn, args) => {
|
|
1083
1109
|
try {
|
|
1084
1110
|
await fn(args);
|
|
@@ -1245,6 +1271,20 @@ const toHaveText = async (locator, options) => {
|
|
|
1245
1271
|
}
|
|
1246
1272
|
return `expected selector ${locatorString} to have text "${text}" but was "${actual}"`;
|
|
1247
1273
|
};
|
|
1274
|
+
const toContainText = async (locator, options) => {
|
|
1275
|
+
const locatorString = printLocator(locator);
|
|
1276
|
+
const {
|
|
1277
|
+
wasFound,
|
|
1278
|
+
actual
|
|
1279
|
+
} = await locatorInvoke(locator, 'TestFrameWork.checkConditionError', 'toContainText', locator, options);
|
|
1280
|
+
const {
|
|
1281
|
+
text
|
|
1282
|
+
} = options;
|
|
1283
|
+
if (!wasFound) {
|
|
1284
|
+
return `expected selector ${locatorString} to contain text "${text}" element was not found`;
|
|
1285
|
+
}
|
|
1286
|
+
return `expected selector ${locatorString} to contain text "${text}" but was "${actual}"`;
|
|
1287
|
+
};
|
|
1248
1288
|
const toHaveAttribute = async (locator, options) => {
|
|
1249
1289
|
const locatorString = printLocator(locator);
|
|
1250
1290
|
const {
|
|
@@ -1346,6 +1386,8 @@ const getFunction = fnName => {
|
|
|
1346
1386
|
return toHaveValue;
|
|
1347
1387
|
case 'toHaveText':
|
|
1348
1388
|
return toHaveText;
|
|
1389
|
+
case 'toContainText':
|
|
1390
|
+
return toContainText;
|
|
1349
1391
|
case 'toHaveAttribute':
|
|
1350
1392
|
return toHaveAttribute;
|
|
1351
1393
|
case 'toHaveCount':
|
|
@@ -1883,28 +1925,10 @@ const areSelectionsEqual = (a, b) => {
|
|
|
1883
1925
|
return true;
|
|
1884
1926
|
};
|
|
1885
1927
|
|
|
1886
|
-
const
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
const rpc = await TransferMessagePortRpcParent.create({
|
|
1891
|
-
commandMap: {},
|
|
1892
|
-
send
|
|
1893
|
-
});
|
|
1894
|
-
return rpc;
|
|
1895
|
-
};
|
|
1896
|
-
|
|
1897
|
-
let rpcPromise;
|
|
1898
|
-
const getRpc = () => {
|
|
1899
|
-
if (!rpcPromise) {
|
|
1900
|
-
rpcPromise = launchEditorWorkerRpc();
|
|
1901
|
-
}
|
|
1902
|
-
return rpcPromise;
|
|
1903
|
-
};
|
|
1904
|
-
const invoke = async (method, ...params) => {
|
|
1905
|
-
const rpc = await getRpc();
|
|
1906
|
-
return rpc.invoke(method, ...params);
|
|
1907
|
-
};
|
|
1928
|
+
const {
|
|
1929
|
+
invoke,
|
|
1930
|
+
setFactory
|
|
1931
|
+
} = createLazyRpc(EditorWorker);
|
|
1908
1932
|
|
|
1909
1933
|
const Script = 2;
|
|
1910
1934
|
|
|
@@ -2223,6 +2247,26 @@ const TestFrameWorkComponentEditorHover = {
|
|
|
2223
2247
|
show: show$3
|
|
2224
2248
|
};
|
|
2225
2249
|
|
|
2250
|
+
const handleInput$4 = async value => {
|
|
2251
|
+
// @ts-ignore
|
|
2252
|
+
await invoke$1('EditorRename.handleInput', value, Script);
|
|
2253
|
+
};
|
|
2254
|
+
const accept = async () => {
|
|
2255
|
+
// @ts-ignore
|
|
2256
|
+
await invoke$1('EditorRename.accept');
|
|
2257
|
+
};
|
|
2258
|
+
const cancel = async () => {
|
|
2259
|
+
// @ts-ignore
|
|
2260
|
+
await invoke$1('EditorRename.cancel');
|
|
2261
|
+
};
|
|
2262
|
+
|
|
2263
|
+
const TestFrameWorkComponentEditorRename = {
|
|
2264
|
+
__proto__: null,
|
|
2265
|
+
accept,
|
|
2266
|
+
cancel,
|
|
2267
|
+
handleInput: handleInput$4
|
|
2268
|
+
};
|
|
2269
|
+
|
|
2226
2270
|
const selectIndex$5 = async index => {
|
|
2227
2271
|
// @ts-ignore
|
|
2228
2272
|
await invoke$1('EditorSourceAction.selectIndex', index);
|
|
@@ -3563,6 +3607,16 @@ const TestFrameWorkComponentWebView = {
|
|
|
3563
3607
|
fromId
|
|
3564
3608
|
};
|
|
3565
3609
|
|
|
3610
|
+
const toFileUrl = url => {
|
|
3611
|
+
const urlObject = new URL(url);
|
|
3612
|
+
const pathName = urlObject.pathname;
|
|
3613
|
+
if (!pathName.startsWith('/remote')) {
|
|
3614
|
+
throw new Error(`url must start with /remote`);
|
|
3615
|
+
}
|
|
3616
|
+
const rest = pathName.slice('/remote'.length);
|
|
3617
|
+
return `file://${rest}`;
|
|
3618
|
+
};
|
|
3619
|
+
|
|
3566
3620
|
const setPath = async path => {
|
|
3567
3621
|
await invoke$1('Workspace.setPath', path);
|
|
3568
3622
|
};
|
|
@@ -3571,10 +3625,20 @@ const openTmpDir = async () => {
|
|
|
3571
3625
|
await setPath(tmpDir);
|
|
3572
3626
|
return tmpDir;
|
|
3573
3627
|
};
|
|
3628
|
+
const resolveFileUrl = url => {
|
|
3629
|
+
// TODO in web, convert to memfs or fetch url
|
|
3630
|
+
// TODO on web: read filemap for that fixture
|
|
3631
|
+
// else, use filesystem to read the files
|
|
3632
|
+
// TODO covert remote url to file url
|
|
3633
|
+
// then set that as workspace path
|
|
3634
|
+
|
|
3635
|
+
return toFileUrl(url);
|
|
3636
|
+
};
|
|
3574
3637
|
|
|
3575
3638
|
const TestFrameWorkComponentWorkspace = {
|
|
3576
3639
|
__proto__: null,
|
|
3577
3640
|
openTmpDir,
|
|
3641
|
+
resolveFileUrl,
|
|
3578
3642
|
setPath
|
|
3579
3643
|
};
|
|
3580
3644
|
|
|
@@ -3591,6 +3655,7 @@ const TestFrameWorkComponent = {
|
|
|
3591
3655
|
Editor: TestFrameWorkComponentEditor,
|
|
3592
3656
|
EditorCompletion: TestFrameWorkComponentEditorCompletion,
|
|
3593
3657
|
EditorHover: TestFrameWorkComponentEditorHover,
|
|
3658
|
+
EditorRename: TestFrameWorkComponentEditorRename,
|
|
3594
3659
|
EditorSourceAction: TestFrameWorkComponentEditorSourceAction,
|
|
3595
3660
|
Explorer: TestFrameWorkComponentExplorer,
|
|
3596
3661
|
Extension: TestFrameWorkComponentExtension,
|
|
@@ -3665,7 +3730,19 @@ const commandMap = {
|
|
|
3665
3730
|
'Test.executeMock': executeMock
|
|
3666
3731
|
};
|
|
3667
3732
|
|
|
3733
|
+
const send = async port => {
|
|
3734
|
+
await sendMessagePortToEditorWorker(port, TestWorker);
|
|
3735
|
+
};
|
|
3736
|
+
const launchEditorWorkerRpc = async () => {
|
|
3737
|
+
const rpc = await TransferMessagePortRpcParent.create({
|
|
3738
|
+
commandMap: {},
|
|
3739
|
+
send
|
|
3740
|
+
});
|
|
3741
|
+
return rpc;
|
|
3742
|
+
};
|
|
3743
|
+
|
|
3668
3744
|
const listen = async () => {
|
|
3745
|
+
setFactory(launchEditorWorkerRpc);
|
|
3669
3746
|
const rpc = await WebWorkerRpcClient.create({
|
|
3670
3747
|
commandMap: commandMap
|
|
3671
3748
|
});
|