@lvce-editor/renderer-process 14.0.0 → 14.0.1

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.
@@ -3204,7 +3204,7 @@ const KeyBoardActions = {
3204
3204
  press
3205
3205
  };
3206
3206
 
3207
- const toHaveCount = (elements, {
3207
+ const toHaveCount$1 = (elements, {
3208
3208
  count
3209
3209
  }) => {
3210
3210
  return elements.length === count;
@@ -3216,7 +3216,7 @@ const toBeHidden = elements => {
3216
3216
  const MultiElementConditions = {
3217
3217
  __proto__: null,
3218
3218
  toBeHidden,
3219
- toHaveCount
3219
+ toHaveCount: toHaveCount$1
3220
3220
  };
3221
3221
 
3222
3222
  const htmlElements = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdo', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'link', 'map', 'mark', 'menu', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'pre', 'progress', 'q', 'rp', 'rt', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr'];
@@ -3305,7 +3305,7 @@ const toHaveValue = (element, {
3305
3305
  }) => {
3306
3306
  return element.value === value;
3307
3307
  };
3308
- const toHaveText = (element, {
3308
+ const toHaveText$1 = (element, {
3309
3309
  text
3310
3310
  }) => {
3311
3311
  return element.textContent === text;
@@ -3315,27 +3315,27 @@ const toContainText = (element, {
3315
3315
  }) => {
3316
3316
  return element.textContent.includes(text);
3317
3317
  };
3318
- const toHaveAttribute = (element, {
3318
+ const toHaveAttribute$1 = (element, {
3319
3319
  key,
3320
3320
  value
3321
3321
  }) => {
3322
3322
  const attribute = element.getAttribute(key);
3323
3323
  return attribute === value;
3324
3324
  };
3325
- const toBeFocused = element => {
3325
+ const toBeFocused$1 = element => {
3326
3326
  return element === document.activeElement;
3327
3327
  };
3328
- const toHaveClass = (element, {
3328
+ const toHaveClass$1 = (element, {
3329
3329
  className
3330
3330
  }) => {
3331
3331
  return element.classList.contains(className);
3332
3332
  };
3333
- const toHaveId = (element, {
3333
+ const toHaveId$1 = (element, {
3334
3334
  id
3335
3335
  }) => {
3336
3336
  return element.id === id;
3337
3337
  };
3338
- const toHaveCss = (element, {
3338
+ const toHaveCss$1 = (element, {
3339
3339
  key,
3340
3340
  value
3341
3341
  }) => {
@@ -3349,15 +3349,134 @@ const toHaveCss = (element, {
3349
3349
 
3350
3350
  const SingleElementConditions = {
3351
3351
  __proto__: null,
3352
- toBeFocused,
3352
+ toBeFocused: toBeFocused$1,
3353
3353
  toBeVisible,
3354
3354
  toContainText,
3355
+ toHaveAttribute: toHaveAttribute$1,
3356
+ toHaveClass: toHaveClass$1,
3357
+ toHaveCss: toHaveCss$1,
3358
+ toHaveId: toHaveId$1,
3359
+ toHaveText: toHaveText$1,
3360
+ toHaveValue
3361
+ };
3362
+
3363
+ const toHaveText = locator => {
3364
+ const element = querySelectorWithOptions(locator._selector, {
3365
+ nth: locator._nth,
3366
+ hasText: locator._hasText
3367
+ });
3368
+ if (!element) {
3369
+ return {
3370
+ wasFound: false,
3371
+ actual: ''
3372
+ };
3373
+ }
3374
+ return {
3375
+ wasFound: true,
3376
+ actual: element.textContent
3377
+ };
3378
+ };
3379
+ const toHaveAttribute = (locator, {
3380
+ key,
3381
+ value
3382
+ }) => {
3383
+ const element = querySelectorWithOptions(locator._selector, {
3384
+ nth: locator._nth,
3385
+ hasText: locator._hasText
3386
+ });
3387
+ if (!element) {
3388
+ return {
3389
+ wasFound: false,
3390
+ actual: ''
3391
+ };
3392
+ }
3393
+ const actual = element.getAttribute(key);
3394
+ return {
3395
+ wasFound: true,
3396
+ actual
3397
+ };
3398
+ };
3399
+ const toHaveCount = locator => {
3400
+ const elements = querySelector(locator._selector);
3401
+ const actualCount = elements.length;
3402
+ return {
3403
+ actual: actualCount
3404
+ };
3405
+ };
3406
+ const stringifyElement = element => {
3407
+ if (element.id) {
3408
+ return `#${element.id}`;
3409
+ }
3410
+ if (element.className) {
3411
+ return `.${element.className}`;
3412
+ }
3413
+ if (element === document.body) {
3414
+ return 'document.body';
3415
+ }
3416
+ return element.tagName;
3417
+ };
3418
+ const toBeFocused = locator => {
3419
+ const activeElement = document.activeElement;
3420
+ const stringifiedActiveElement = stringifyElement(activeElement);
3421
+ return {
3422
+ actual: stringifiedActiveElement
3423
+ };
3424
+ };
3425
+ const toHaveClass = (locator, {
3426
+ className
3427
+ }) => {
3428
+ const [element] = querySelector(locator._selector);
3429
+ if (!element) {
3430
+ return {
3431
+ wasFound: false,
3432
+ actual: ''
3433
+ };
3434
+ }
3435
+ return {
3436
+ wasFound: true,
3437
+ actual: className
3438
+ };
3439
+ };
3440
+ const toHaveId = locator => {
3441
+ const [element] = querySelector(locator._selector);
3442
+ if (!element) {
3443
+ return {
3444
+ wasFound: false,
3445
+ actual: ''
3446
+ };
3447
+ }
3448
+ return {
3449
+ wasFound: true,
3450
+ actual: element.id
3451
+ };
3452
+ };
3453
+ const toHaveCss = (locator, {
3454
+ key
3455
+ }) => {
3456
+ const [element] = querySelector(locator._selector);
3457
+ if (!element) {
3458
+ return {
3459
+ wasFound: false,
3460
+ actual: ''
3461
+ };
3462
+ }
3463
+ const style = getComputedStyle(element);
3464
+ const actual = style[key];
3465
+ return {
3466
+ wasFound: true,
3467
+ actual
3468
+ };
3469
+ };
3470
+
3471
+ const ConditionValues = {
3472
+ __proto__: null,
3473
+ toBeFocused,
3355
3474
  toHaveAttribute,
3356
3475
  toHaveClass,
3476
+ toHaveCount,
3357
3477
  toHaveCss,
3358
3478
  toHaveId,
3359
- toHaveText,
3360
- toHaveValue
3479
+ toHaveText
3361
3480
  };
3362
3481
 
3363
3482
  // TODO this should also come in via options
@@ -3476,6 +3595,10 @@ const checkMultiElementCondition = async (locator, fnName, options) => {
3476
3595
  error: true
3477
3596
  };
3478
3597
  };
3598
+ const checkConditionError = (fnName, ...params) => {
3599
+ const fn = ConditionValues[fnName];
3600
+ return fn(...params);
3601
+ };
3479
3602
 
3480
3603
  const webViews = Object.create(null);
3481
3604
  const set$4 = (id, webView) => {
@@ -9544,6 +9667,7 @@ const commandMap = {
9544
9667
  'TestFrameWork.showOverlay': showOverlay,
9545
9668
  'TestFrameWork.transfer': transfer,
9546
9669
  'TestFrameWork.transferToWebView': transferToWebView,
9670
+ 'TestFrameWork.checkConditionError': checkConditionError,
9547
9671
  'Viewlet.addKeyBindings': addKeyBindings,
9548
9672
  'Viewlet.appendViewlet': appendViewlet,
9549
9673
  'Viewlet.dispose': dispose$3,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "14.0.0",
3
+ "version": "14.0.1",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lvce-editor",