@camperaid/watest 2.5.5 → 2.5.7

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/.watestrc.js CHANGED
@@ -43,6 +43,12 @@ const cfg = {
43
43
  */
44
44
  webdriver_loglevel: process.env.WATEST_WEBDRIVER_LOGLEVEL,
45
45
 
46
+ /**
47
+ * Additional Chrome arguments.
48
+ * JSON array, e.g.: ["enable-unsafe-swiftshader", "use-gl=swiftshader"]
49
+ */
50
+ webdriver_chrome_args: process.env.WATEST_WEBDRIVER_CHROME_ARGS,
51
+
46
52
  /**
47
53
  * Web drivers to run tests for.
48
54
  */
package/core/series.js CHANGED
@@ -481,6 +481,7 @@ class Series {
481
481
  failures_info: [],
482
482
  skip_on_fail: 'skip-on-fail',
483
483
  init_or_uninit: true,
484
+ ...(test_module.timeout && { timeout: test_module.timeout }),
484
485
  });
485
486
  }
486
487
 
@@ -535,6 +536,7 @@ class Series {
535
536
  failures_info: [],
536
537
  skip_on_fail: 'skip-on-fail',
537
538
  init_or_uninit: true,
539
+ ...(test_module.timeout && { timeout: test_module.timeout }),
538
540
  });
539
541
  }
540
542
 
@@ -715,10 +717,7 @@ class Series {
715
717
  return kKungFuDeathGripTimeout;
716
718
  }
717
719
  });
718
- kungFuDeathGripTimer = setTimeout(
719
- kungFuDeathGripResolve,
720
- timeoutMs,
721
- );
720
+ kungFuDeathGripTimer = setTimeout(kungFuDeathGripResolve, timeoutMs);
722
721
  let retval = await Promise.race([func(), kungFuDeathGrip]);
723
722
  if (retval != kKungFuDeathGripTimeout) {
724
723
  clearTimeout(kungFuDeathGripTimer);
package/core/settings.js CHANGED
@@ -112,12 +112,33 @@ class Settings {
112
112
  this.rc.webdriver_headless == true ||
113
113
  this.rc.webdriver_headless == 'true';
114
114
  this.webdriver_loglevel = this.rc.webdriver_loglevel;
115
+ this.webdriver_chrome_args = [];
116
+
117
+ if (typeof this.rc.webdriver_chrome_args == 'string') {
118
+ try {
119
+ const parsed = JSON.parse(this.rc.webdriver_chrome_args);
120
+ if (Array.isArray(parsed)) {
121
+ this.webdriver_chrome_args = parsed;
122
+ }
123
+ } catch (e) {
124
+ console.error(
125
+ `Settings: failed to parse webdriver_chrome_args '${this.rc.webdriver_chrome_args}'`,
126
+ e,
127
+ );
128
+ }
129
+ }
115
130
 
116
131
  this.webdriver_window_width =
117
132
  parseInt(this.rc.webdriver_window_width) || 1366;
118
133
  this.webdriver_window_height =
119
134
  parseInt(this.rc.webdriver_window_height) || 768;
120
135
 
136
+ if (!this.silent) {
137
+ console.log(
138
+ `Settings: webdriver_chrome_args=${JSON.stringify(this.webdriver_chrome_args)}`,
139
+ );
140
+ }
141
+
121
142
  if (this.webdrivers && !this.silent) {
122
143
  console.log(`Settings: ${this.webdrivers.join(', ')} webdrivers`);
123
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camperaid/watest",
3
- "version": "2.5.5",
3
+ "version": "2.5.7",
4
4
  "description": "Web Application Testsuite",
5
5
  "type": "module",
6
6
  "engines": {
@@ -20,6 +20,7 @@ export async function test() {
20
20
  const expected_stdout = [
21
21
  'Settings: no temporary storage dir',
22
22
  'Settings: logging into /tmp',
23
+ 'Settings: webdriver_chrome_args=[]',
23
24
  'Settings: chrome webdrivers',
24
25
  '\x1B[38;5;99mStarted\x1B[0m mac/',
25
26
  '\x1B[38;5;99mStarted\x1B[0m mac/unit',
@@ -33,6 +33,7 @@ export async function test() {
33
33
  const expected_stdout = [
34
34
  'Settings: no temporary storage dir',
35
35
  'Settings: logging into /tmp',
36
+ 'Settings: webdriver_chrome_args=[]',
36
37
  'Settings: chrome webdrivers',
37
38
  ...expected_out_for_success,
38
39
  ...expected_out_for_success,
@@ -35,6 +35,7 @@ export async function test() {
35
35
  [
36
36
  'Settings: no temporary storage dir',
37
37
  'Settings: logging into /tmp',
38
+ 'Settings: webdriver_chrome_args=[]',
38
39
  'Settings: chrome webdrivers',
39
40
  '\x1B[38;5;99mStarted\x1B[0m mac/',
40
41
  '\x1B[38;5;99mStarted\x1B[0m mac/unit',
@@ -33,6 +33,7 @@ export async function test() {
33
33
  const expected_stdout = [
34
34
  'Settings: no temporary storage dir',
35
35
  'Settings: logging into /tmp',
36
+ 'Settings: webdriver_chrome_args=[]',
36
37
  'Settings: chrome webdrivers',
37
38
  '\x1B[38;5;99mStarted\x1B[0m mac/',
38
39
  '\x1B[38;5;99mStarted\x1B[0m mac/webdriver',
@@ -33,6 +33,7 @@ export async function test() {
33
33
  const expected_stdout = [
34
34
  'Settings: no temporary storage dir',
35
35
  'Settings: logging into /tmp',
36
+ 'Settings: webdriver_chrome_args=[]',
36
37
  'Settings: chrome webdrivers',
37
38
  '\x1B[38;5;99mStarted\x1B[0m mac/',
38
39
  '\x1B[38;5;99mStarted\x1B[0m mac/unit',
@@ -35,6 +35,7 @@ export async function test() {
35
35
  [
36
36
  'Settings: no temporary storage dir',
37
37
  'Settings: logging into /tmp',
38
+ 'Settings: webdriver_chrome_args=[]',
38
39
  'Settings: chrome webdrivers',
39
40
  '\x1B[38;5;99mStarted\x1B[0m mac/',
40
41
 
@@ -26,6 +26,7 @@ export async function test() {
26
26
  [
27
27
  'Settings: no temporary storage dir',
28
28
  'Settings: logging into /tmp',
29
+ 'Settings: webdriver_chrome_args=[]',
29
30
  'Settings: chrome webdrivers',
30
31
  '\x1B[38;5;99mStarted\x1B[0m mac/',
31
32
  '!Running: mac/init, path: tests/meta.js',
@@ -66,6 +66,7 @@ export async function test() {
66
66
  [
67
67
  'Settings: no temporary storage dir',
68
68
  'Settings: logging into /tmp',
69
+ 'Settings: webdriver_chrome_args=[]',
69
70
  'Settings: chrome webdrivers',
70
71
  '\x1B[38;5;99mStarted\x1B[0m mac/',
71
72
  '\x1B[38;5;99mStarted\x1B[0m mac/folder1',
@@ -22,6 +22,7 @@ export async function test() {
22
22
  [
23
23
  'Settings: no temporary storage dir',
24
24
  'Settings: logging into /tmp',
25
+ 'Settings: webdriver_chrome_args=[]',
25
26
  'Settings: chrome webdrivers',
26
27
  '\x1B[38;5;99mStarted\x1B[0m mac/',
27
28
  '!Running: mac/init, path: tests/meta.js',
@@ -44,6 +44,13 @@ function getChromeOptions() {
44
44
  chromeOptions.addArguments('no-sandbox');
45
45
  chromeOptions.addArguments('disable-dev-shm-usage');
46
46
 
47
+ // Disable disk cache so stale resources from previous deploys are never
48
+ // served from cache. Each test session fetches everything from the network.
49
+ chromeOptions.addArguments('disk-cache-size=0');
50
+
51
+ for (const arg of settings.webdriver_chrome_args || []) {
52
+ chromeOptions.addArguments(arg);
53
+ }
47
54
  return chromeOptions;
48
55
  }
49
56
 
@@ -577,15 +584,43 @@ class DriverBase {
577
584
  });
578
585
  `;
579
586
 
587
+ // Removes listeners and cleans up globals without waiting for a click
588
+ // event. Used when no_click_check is set and the click may not fire
589
+ // standard mouse events (e.g. range inputs on mobile Chrome).
590
+ let cleanupClick = `
591
+ const events = ['mousedown', 'mouseup', 'click', 'dblclick'];
592
+ for (let ev of events) {
593
+ window.document.removeEventListener(
594
+ ev, window.__selenium_clickHandler, true
595
+ );
596
+ }
597
+ delete window.__selenium_clickHandler;
598
+ delete window.__selenium_lastClick;
599
+ delete window.__selenium_clickElRect;
600
+ (arguments[arguments.length - 1])();
601
+ `;
602
+
580
603
  return this.waitForElementToInvoke(
581
604
  selector,
582
605
  el =>
583
606
  this.dvr
584
607
  .executeAsyncScript(listenClick, selector)
585
608
  .then(() => click_func(el))
586
- .then(
587
- () => !no_click_check && this.dvr.executeAsyncScript(checkClick),
588
- )
609
+ .then(() => {
610
+ let p = this.dvr.executeAsyncScript(
611
+ no_click_check ? cleanupClick : checkClick,
612
+ );
613
+ if (no_click_check) {
614
+ // Page may navigate before cleanup script runs - that's OK.
615
+ p = p.catch(e => {
616
+ if (e instanceof error.ScriptTimeoutError) {
617
+ return null;
618
+ }
619
+ throw e;
620
+ });
621
+ }
622
+ return p;
623
+ })
589
624
  .then(r => {
590
625
  if (!r) {
591
626
  if (!no_click_check) {