@lvce-editor/test-worker 6.2.0 → 6.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 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
 
@@ -513,7 +544,7 @@ export interface TestApi {
513
544
  readonly TitleBarMenuBar: TitleBarMenuBar
514
545
  readonly Url: Url
515
546
  readonly WebView: WebView
516
- readonly expect: any
547
+ readonly expect: (locator: ILocatorExternal) => LocatorExpect
517
548
  readonly Locator: (selector: string, option?: any) => ILocatorExternal
518
549
  }
519
550
 
@@ -1245,6 +1245,20 @@ const toHaveText = async (locator, options) => {
1245
1245
  }
1246
1246
  return `expected selector ${locatorString} to have text "${text}" but was "${actual}"`;
1247
1247
  };
1248
+ const toContainText = async (locator, options) => {
1249
+ const locatorString = printLocator(locator);
1250
+ const {
1251
+ wasFound,
1252
+ actual
1253
+ } = await locatorInvoke(locator, 'TestFrameWork.checkConditionError', 'toContainText', locator, options);
1254
+ const {
1255
+ text
1256
+ } = options;
1257
+ if (!wasFound) {
1258
+ return `expected selector ${locatorString} to contain text "${text}" element was not found`;
1259
+ }
1260
+ return `expected selector ${locatorString} to contain text "${text}" but was "${actual}"`;
1261
+ };
1248
1262
  const toHaveAttribute = async (locator, options) => {
1249
1263
  const locatorString = printLocator(locator);
1250
1264
  const {
@@ -1346,6 +1360,8 @@ const getFunction = fnName => {
1346
1360
  return toHaveValue;
1347
1361
  case 'toHaveText':
1348
1362
  return toHaveText;
1363
+ case 'toContainText':
1364
+ return toContainText;
1349
1365
  case 'toHaveAttribute':
1350
1366
  return toHaveAttribute;
1351
1367
  case 'toHaveCount':
@@ -3563,6 +3579,16 @@ const TestFrameWorkComponentWebView = {
3563
3579
  fromId
3564
3580
  };
3565
3581
 
3582
+ const toFileUrl = url => {
3583
+ const urlObject = new URL(url);
3584
+ const pathName = urlObject.pathname;
3585
+ if (!pathName.startsWith('/remote')) {
3586
+ throw new Error(`url must start with /remote`);
3587
+ }
3588
+ const rest = pathName.slice('/remote'.length);
3589
+ return `file://${rest}`;
3590
+ };
3591
+
3566
3592
  const setPath = async path => {
3567
3593
  await invoke$1('Workspace.setPath', path);
3568
3594
  };
@@ -3571,10 +3597,20 @@ const openTmpDir = async () => {
3571
3597
  await setPath(tmpDir);
3572
3598
  return tmpDir;
3573
3599
  };
3600
+ const resolveFileUrl = url => {
3601
+ // TODO in web, convert to memfs or fetch url
3602
+ // TODO on web: read filemap for that fixture
3603
+ // else, use filesystem to read the files
3604
+ // TODO covert remote url to file url
3605
+ // then set that as workspace path
3606
+
3607
+ return toFileUrl(url);
3608
+ };
3574
3609
 
3575
3610
  const TestFrameWorkComponentWorkspace = {
3576
3611
  __proto__: null,
3577
3612
  openTmpDir,
3613
+ resolveFileUrl,
3578
3614
  setPath
3579
3615
  };
3580
3616
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",