@capillarytech/cap-ui-utils 3.1.0 → 3.1.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.
@@ -48,15 +48,20 @@ class LockService {
48
48
  } catch {
49
49
  return false; // vanished meanwhile — nothing to clean
50
50
  }
51
- if (Date.now() - mtimeMs > STALE_LOCK_TTL_MS) return true;
51
+ // Probe the owner's liveness FIRST a live owner must never lose its lock,
52
+ // regardless of age (slow cluster, retried publish, debug SETTLE_MS pauses).
53
+ // The TTL only applies when the owner is dead, unknown, or a reused pid.
52
54
  const match = /^Test-(\d+)-\d+$/.exec(owner.trim());
53
- if (!match) return false; // unknown owner format — only TTL applies
55
+ if (!match) return Date.now() - mtimeMs > STALE_LOCK_TTL_MS; // unknown format — TTL only
54
56
  try {
55
57
  process.kill(Number(match[1]), 0); // signal 0 = liveness probe, sends nothing
56
- return false;
58
+ return false; // owner alive — never steal
57
59
  } catch (error) {
58
- // ESRCH: no such process → stale. EPERM: process exists but is not ours.
59
- return (error as NodeJS.ErrnoException).code !== 'EPERM';
60
+ // ESRCH: no such process → stale. EPERM: exists but not ours → TTL fallback (pid reuse).
61
+ if ((error as NodeJS.ErrnoException).code === 'EPERM') {
62
+ return Date.now() - mtimeMs > STALE_LOCK_TTL_MS;
63
+ }
64
+ return true;
60
65
  }
61
66
  }
62
67
 
File without changes
@@ -15,7 +15,7 @@ class ElementUtils {
15
15
  await browser.pause(2000)
16
16
  await element.waitForDisplayed({ timeout: 90000})
17
17
  try{
18
- await element.waitForClickable({ timeout: 60000, interval:1000, timeoutMsg:await element.getHTML(false)+" is still not clickable" })
18
+ await element.waitForClickable({ timeout: 60000, interval:1000, timeoutMsg:"element is still not clickable" })
19
19
  await element.click()
20
20
  }
21
21
  catch(error){
@@ -193,7 +193,7 @@ class ElementUtils {
193
193
  async enterText(element:WebdriverIO.Element, textToEnter){
194
194
  await browser.pause(1000)
195
195
  // browser.execute('arguments[0].style.outline = "#f00 solid 4px";', element);
196
- await element.waitForEnabled({ timeout: 40000, interval:1000, timeoutMsg:await element.getHTML(false)+" is still not editable" })
196
+ await element.waitForEnabled({ timeout: 40000, interval:1000, timeoutMsg:"element is still not editable" })
197
197
  await element.setValue(textToEnter)
198
198
  }
199
199
 
@@ -206,7 +206,7 @@ class ElementUtils {
206
206
  await element.waitForEnabled({
207
207
  timeout: 40000,
208
208
  interval: 1000,
209
- timeoutMsg: await element.getHTML(false) + " is still not editable"
209
+ timeoutMsg: "element is still not editable"
210
210
  });
211
211
  await element.addValue(textToEnter);
212
212
  }
@@ -327,7 +327,7 @@ class ElementUtils {
327
327
  await target.waitForEnabled({
328
328
  timeout: 40000,
329
329
  interval: 1000,
330
- timeoutMsg: await target.getHTML(false) + " is still not editable"
330
+ timeoutMsg: "element is still not editable"
331
331
  });
332
332
  await browser.execute((el: any, val: string) => {
333
333
  const desc = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value");
@@ -343,7 +343,7 @@ class ElementUtils {
343
343
  }
344
344
 
345
345
  async switchToUrl(url: string){
346
- await browser.switchWindow('url')
346
+ await browser.switchWindow(url)
347
347
  }
348
348
 
349
349
  async waitUntilDisplayed(element:WebdriverIO.Element, awaitedText, timeout=30000){
@@ -378,7 +378,7 @@ class ElementUtils {
378
378
  await browser.pause(1000);
379
379
  let isDisplayed = await element.isDisplayed();
380
380
  if (isDisplayed) {
381
- await element.waitForClickable({ timeout: 40000, interval:1000, timeoutMsg:await element.getHTML(false)+" is still not clickable" })
381
+ await element.waitForClickable({ timeout: 40000, interval:1000, timeoutMsg:"element is still not clickable" })
382
382
  await element.click()
383
383
  }
384
384
  }
@@ -431,7 +431,7 @@ class ElementUtils {
431
431
  await element.waitForEnabled({
432
432
  timeout: 40000,
433
433
  interval: 1000,
434
- timeoutMsg: await element.getHTML(false) + " is still not editable"
434
+ timeoutMsg: "element is still not editable"
435
435
  });
436
436
  await element.setValue(textToEnter);
437
437
  }
@@ -455,7 +455,7 @@ class ElementUtils {
455
455
  await element.waitForClickable({
456
456
  timeout: 40000,
457
457
  interval: 1000,
458
- timeoutMsg: await element.getHTML(false) + " is still not interactable for hover"
458
+ timeoutMsg: "element is still not interactable for hover"
459
459
  });
460
460
 
461
461
  // Perform the hover action
@@ -33,10 +33,17 @@ class LogCollectorUtil {
33
33
  "time": exeTime.toString(), "validataionMessage": validationMessage,
34
34
  "total": this.callCount}}}}
35
35
  const messagePayload ={"result" : message}
36
- const response = await request.
37
- post('/logger')
38
- .send(messagePayload)
39
- console.log('API Response',response.body);
36
+ try {
37
+ const response = await request
38
+ .post('/logger')
39
+ .timeout({ deadline: 10000 })
40
+ .send(messagePayload)
41
+ console.log('API Response', response.body);
42
+ } catch (err) {
43
+ // The in-pod log collector can be slow or absent (e.g. skipLogCollector);
44
+ // a logging failure must never fail the test itself.
45
+ console.log('logCollector POST failed (non-fatal):', (err as Error).message);
46
+ }
40
47
  console.log('Message', message)
41
48
  }
42
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capillarytech/cap-ui-utils",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Utility functions shared accross all the modules",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1 +0,0 @@
1
- ready