@memlab/e2e 1.0.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.
Files changed (118) hide show
  1. package/README.md +11 -0
  2. package/dist/BaseSynthesizer.d.ts +63 -0
  3. package/dist/BaseSynthesizer.d.ts.map +1 -0
  4. package/dist/BaseSynthesizer.js +433 -0
  5. package/dist/E2EInteractionManager.d.ts +41 -0
  6. package/dist/E2EInteractionManager.d.ts.map +1 -0
  7. package/dist/E2EInteractionManager.js +347 -0
  8. package/dist/TestRunnerLoader.d.ts +16 -0
  9. package/dist/TestRunnerLoader.d.ts.map +1 -0
  10. package/dist/TestRunnerLoader.js +41 -0
  11. package/dist/TypesThirdParty.d.ts +25 -0
  12. package/dist/TypesThirdParty.d.ts.map +1 -0
  13. package/dist/TypesThirdParty.js +10 -0
  14. package/dist/index.d.ts +16 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +40 -0
  17. package/dist/lib/E2EUtils.d.ts +59 -0
  18. package/dist/lib/E2EUtils.d.ts.map +1 -0
  19. package/dist/lib/E2EUtils.js +286 -0
  20. package/dist/lib/SynthesisUtils.d.ts +25 -0
  21. package/dist/lib/SynthesisUtils.d.ts.map +1 -0
  22. package/dist/lib/SynthesisUtils.js +30 -0
  23. package/dist/lib/operations/BackOperation.d.ts +17 -0
  24. package/dist/lib/operations/BackOperation.d.ts.map +1 -0
  25. package/dist/lib/operations/BackOperation.js +37 -0
  26. package/dist/lib/operations/BackspaceOperation.d.ts +18 -0
  27. package/dist/lib/operations/BackspaceOperation.d.ts.map +1 -0
  28. package/dist/lib/operations/BackspaceOperation.js +36 -0
  29. package/dist/lib/operations/BaseOperation.d.ts +22 -0
  30. package/dist/lib/operations/BaseOperation.d.ts.map +1 -0
  31. package/dist/lib/operations/BaseOperation.js +67 -0
  32. package/dist/lib/operations/CachePageContent.d.ts +22 -0
  33. package/dist/lib/operations/CachePageContent.d.ts.map +1 -0
  34. package/dist/lib/operations/CachePageContent.js +46 -0
  35. package/dist/lib/operations/ClickOperation.d.ts +36 -0
  36. package/dist/lib/operations/ClickOperation.d.ts.map +1 -0
  37. package/dist/lib/operations/ClickOperation.js +131 -0
  38. package/dist/lib/operations/CompoundOperation.d.ts +20 -0
  39. package/dist/lib/operations/CompoundOperation.d.ts.map +1 -0
  40. package/dist/lib/operations/CompoundOperation.js +39 -0
  41. package/dist/lib/operations/EnterOperation.d.ts +18 -0
  42. package/dist/lib/operations/EnterOperation.d.ts.map +1 -0
  43. package/dist/lib/operations/EnterOperation.js +36 -0
  44. package/dist/lib/operations/EscOperation.d.ts +17 -0
  45. package/dist/lib/operations/EscOperation.d.ts.map +1 -0
  46. package/dist/lib/operations/EscOperation.js +36 -0
  47. package/dist/lib/operations/HoverOperation.d.ts +28 -0
  48. package/dist/lib/operations/HoverOperation.d.ts.map +1 -0
  49. package/dist/lib/operations/HoverOperation.js +73 -0
  50. package/dist/lib/operations/InteractionUtils.d.ts +33 -0
  51. package/dist/lib/operations/InteractionUtils.d.ts.map +1 -0
  52. package/dist/lib/operations/InteractionUtils.js +207 -0
  53. package/dist/lib/operations/Operations.d.ts +25 -0
  54. package/dist/lib/operations/Operations.d.ts.map +1 -0
  55. package/dist/lib/operations/Operations.js +45 -0
  56. package/dist/lib/operations/RevertOperation.d.ts +18 -0
  57. package/dist/lib/operations/RevertOperation.d.ts.map +1 -0
  58. package/dist/lib/operations/RevertOperation.js +55 -0
  59. package/dist/lib/operations/RunJSCode.d.ts +25 -0
  60. package/dist/lib/operations/RunJSCode.d.ts.map +1 -0
  61. package/dist/lib/operations/RunJSCode.js +51 -0
  62. package/dist/lib/operations/ScrollOperation.d.ts +27 -0
  63. package/dist/lib/operations/ScrollOperation.d.ts.map +1 -0
  64. package/dist/lib/operations/ScrollOperation.js +85 -0
  65. package/dist/lib/operations/TargetExtraOperation.d.ts +18 -0
  66. package/dist/lib/operations/TargetExtraOperation.d.ts.map +1 -0
  67. package/dist/lib/operations/TargetExtraOperation.js +28 -0
  68. package/dist/lib/operations/TestPlanner.d.ts +46 -0
  69. package/dist/lib/operations/TestPlanner.d.ts.map +1 -0
  70. package/dist/lib/operations/TestPlanner.js +182 -0
  71. package/dist/lib/operations/TypeOperation.d.ts +29 -0
  72. package/dist/lib/operations/TypeOperation.d.ts.map +1 -0
  73. package/dist/lib/operations/TypeOperation.js +64 -0
  74. package/dist/lib/operations/UploadOperation.d.ts +25 -0
  75. package/dist/lib/operations/UploadOperation.d.ts.map +1 -0
  76. package/dist/lib/operations/UploadOperation.js +56 -0
  77. package/dist/lib/operations/WaitForElementOperation.d.ts +32 -0
  78. package/dist/lib/operations/WaitForElementOperation.d.ts.map +1 -0
  79. package/dist/lib/operations/WaitForElementOperation.js +67 -0
  80. package/dist/lib/operations/WaitOperation.d.ts +19 -0
  81. package/dist/lib/operations/WaitOperation.d.ts.map +1 -0
  82. package/dist/lib/operations/WaitOperation.js +42 -0
  83. package/dist/lib/operations/WithCachedPageContent.d.ts +26 -0
  84. package/dist/lib/operations/WithCachedPageContent.d.ts.map +1 -0
  85. package/dist/lib/operations/WithCachedPageContent.js +53 -0
  86. package/dist/lib/operations/XVirtualFrameBuffer.d.ts +15 -0
  87. package/dist/lib/operations/XVirtualFrameBuffer.d.ts.map +1 -0
  88. package/dist/lib/operations/XVirtualFrameBuffer.js +44 -0
  89. package/dist/plugins/DefaultScenarioSynthesizer.d.ts +23 -0
  90. package/dist/plugins/DefaultScenarioSynthesizer.d.ts.map +1 -0
  91. package/dist/plugins/DefaultScenarioSynthesizer.js +61 -0
  92. package/dist/plugins/TestSPAVisitSynthesizer.d.ts +23 -0
  93. package/dist/plugins/TestSPAVisitSynthesizer.d.ts.map +1 -0
  94. package/dist/plugins/TestSPAVisitSynthesizer.js +72 -0
  95. package/dist/plugins/scenarios/test-airbnb.d.ts +14 -0
  96. package/dist/plugins/scenarios/test-airbnb.d.ts.map +1 -0
  97. package/dist/plugins/scenarios/test-airbnb.js +48 -0
  98. package/dist/plugins/scenarios/test-databricks.d.ts +14 -0
  99. package/dist/plugins/scenarios/test-databricks.d.ts.map +1 -0
  100. package/dist/plugins/scenarios/test-databricks.js +40 -0
  101. package/dist/plugins/scenarios/test-ebay.d.ts +14 -0
  102. package/dist/plugins/scenarios/test-ebay.d.ts.map +1 -0
  103. package/dist/plugins/scenarios/test-ebay.js +48 -0
  104. package/dist/plugins/scenarios/test-google-maps.d.ts +14 -0
  105. package/dist/plugins/scenarios/test-google-maps.d.ts.map +1 -0
  106. package/dist/plugins/scenarios/test-google-maps.js +41 -0
  107. package/dist/plugins/scenarios/test-shopify.d.ts +14 -0
  108. package/dist/plugins/scenarios/test-shopify.d.ts.map +1 -0
  109. package/dist/plugins/scenarios/test-shopify.js +40 -0
  110. package/dist/plugins/scenarios/test-youtube.d.ts +14 -0
  111. package/dist/plugins/scenarios/test-youtube.d.ts.map +1 -0
  112. package/dist/plugins/scenarios/test-youtube.js +40 -0
  113. package/package.json +53 -0
  114. package/static/links/index.html +18 -0
  115. package/static/links/min.js +3 -0
  116. package/static/links/package.json +36 -0
  117. package/static/links/src/App.js +48 -0
  118. package/static/links/src/index.js +20 -0
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import { Page } from 'puppeteer';
11
+ import BaseOperation from './BaseOperation';
12
+ declare type TypeOptions = {
13
+ randomSuffix?: boolean;
14
+ clear?: boolean;
15
+ delay?: number;
16
+ };
17
+ declare class TypeOperation extends BaseOperation {
18
+ kind: string;
19
+ selector: string;
20
+ inputText: string;
21
+ clear: boolean;
22
+ randomSuffix: boolean;
23
+ delay: number;
24
+ constructor(selector: string, inputText: string, args?: TypeOptions);
25
+ private clearInput;
26
+ act(page: Page): Promise<void>;
27
+ }
28
+ export default TypeOperation;
29
+ //# sourceMappingURL=TypeOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeOperation.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/TypeOperation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAE/B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAI5C,aAAK,WAAW,GAAG;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,cAAM,aAAc,SAAQ,aAAa;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;gBAEF,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB;YAUzD,UAAU;IAOlB,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAcrC;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const core_1 = require("@memlab/core");
25
+ const BaseOperation_1 = __importDefault(require("./BaseOperation"));
26
+ const ClickOperation_1 = __importDefault(require("./ClickOperation"));
27
+ const InteractionUtils_1 = __importDefault(require("./InteractionUtils"));
28
+ class TypeOperation extends BaseOperation_1.default {
29
+ constructor(selector, inputText, args = {}) {
30
+ var _a;
31
+ super();
32
+ this.kind = 'type';
33
+ this.selector = selector;
34
+ this.inputText = inputText;
35
+ this.clear = !!args.clear;
36
+ this.randomSuffix = !!args.randomSuffix;
37
+ this.delay = (_a = args.delay) !== null && _a !== void 0 ? _a : 0;
38
+ }
39
+ clearInput(page) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const click = new ClickOperation_1.default(this.selector, { clickCount: 3 });
42
+ yield click.act(page);
43
+ yield page.keyboard.press('Backspace');
44
+ yield InteractionUtils_1.default.waitFor(100);
45
+ });
46
+ }
47
+ act(page) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ if (this.clear) {
50
+ yield this.clearInput(page);
51
+ yield InteractionUtils_1.default.waitFor(2000);
52
+ }
53
+ const suffix = this.randomSuffix ? `${Math.random()}` : '';
54
+ const textToType = this.inputText + suffix;
55
+ this.log(`Typing "${textToType}"`);
56
+ yield page.type(this.selector, textToType, { delay: 100 });
57
+ yield InteractionUtils_1.default.waitFor(core_1.config.waitAfterTyping);
58
+ if (this.delay > 0) {
59
+ yield InteractionUtils_1.default.waitFor(this.delay);
60
+ }
61
+ });
62
+ }
63
+ }
64
+ exports.default = TypeOperation;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import type { Page } from 'puppeteer';
11
+ import BaseOperation from './BaseOperation';
12
+ declare type UploadOptions = {
13
+ delay?: number;
14
+ file: string;
15
+ };
16
+ declare class UploadOperation extends BaseOperation {
17
+ kind: string;
18
+ selector: string;
19
+ delay: number;
20
+ file: string;
21
+ constructor(selector: string, args: UploadOptions);
22
+ act(page: Page): Promise<void>;
23
+ }
24
+ export default UploadOperation;
25
+ //# sourceMappingURL=UploadOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UploadOperation.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/UploadOperation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAIpC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAG5C,aAAK,aAAa,GAAG;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,cAAM,eAAgB,SAAQ,aAAa;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;gBAED,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa;IAQ3C,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAoBrC;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const path_1 = __importDefault(require("path"));
25
+ const core_1 = require("@memlab/core");
26
+ const BaseOperation_1 = __importDefault(require("./BaseOperation"));
27
+ const InteractionUtils_1 = __importDefault(require("./InteractionUtils"));
28
+ class UploadOperation extends BaseOperation_1.default {
29
+ constructor(selector, args) {
30
+ var _a;
31
+ super();
32
+ this.kind = 'upload';
33
+ this.selector = selector;
34
+ this.delay = (_a = args.delay) !== null && _a !== void 0 ? _a : 0;
35
+ this.file = path_1.default.join(core_1.config.inputDataDir, args.file);
36
+ }
37
+ act(page) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ this.log(`uploading file ${this.file}...`);
40
+ const uploadHandle = yield page.$(this.selector);
41
+ if (!uploadHandle) {
42
+ throw core_1.utils.haltOrThrow(`upload failed, selector not found: ${this.selector}`);
43
+ }
44
+ yield uploadHandle.uploadFile(this.file);
45
+ yield page.evaluate(upload => {
46
+ upload.dispatchEvent(new Event('change', { bubbles: true }));
47
+ }, uploadHandle);
48
+ yield InteractionUtils_1.default.waitFor(2000);
49
+ yield uploadHandle.dispose();
50
+ if (this.delay > 0) {
51
+ yield InteractionUtils_1.default.waitFor(this.delay);
52
+ }
53
+ });
54
+ }
55
+ }
56
+ exports.default = UploadOperation;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import type { Page } from 'puppeteer';
11
+ import BaseOperation from './BaseOperation';
12
+ declare type WaitForOptions = {
13
+ waitForElementTo?: string;
14
+ };
15
+ /**
16
+ * This operation waits for an element matching the given selector. It only
17
+ * fails if the given selector does not come to exist within the timeout
18
+ * specified in `checkIfPresent`. If you want to invert this behavior and wait
19
+ * for it to disappear, pass the option `{waitForElementTo: 'disappear'}`.
20
+ * Furthermore, if you want to ensure that the element not only comes to exist
21
+ * but is visible (ie. neither `display:none` nor `visibility:hidden`) then pass
22
+ * the option `{waitForElementTo: 'appear'}`.
23
+ */
24
+ declare class WaitForElementOperation extends BaseOperation {
25
+ kind: string;
26
+ selector: string;
27
+ waitForElementTo: string;
28
+ constructor(selector: string, options?: WaitForOptions);
29
+ act(page: Page): Promise<void>;
30
+ }
31
+ export default WaitForElementOperation;
32
+ //# sourceMappingURL=WaitForElementOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WaitForElementOperation.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/WaitForElementOperation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAGpC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAG5C,aAAK,cAAc,GAAG;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;;;;;GAQG;AACH,cAAM,uBAAwB,SAAQ,aAAa;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;gBAEb,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IAOpD,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAuBrC;AAED,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const core_1 = require("@memlab/core");
25
+ const BaseOperation_1 = __importDefault(require("./BaseOperation"));
26
+ const InteractionUtils_1 = __importDefault(require("./InteractionUtils"));
27
+ /**
28
+ * This operation waits for an element matching the given selector. It only
29
+ * fails if the given selector does not come to exist within the timeout
30
+ * specified in `checkIfPresent`. If you want to invert this behavior and wait
31
+ * for it to disappear, pass the option `{waitForElementTo: 'disappear'}`.
32
+ * Furthermore, if you want to ensure that the element not only comes to exist
33
+ * but is visible (ie. neither `display:none` nor `visibility:hidden`) then pass
34
+ * the option `{waitForElementTo: 'appear'}`.
35
+ */
36
+ class WaitForElementOperation extends BaseOperation_1.default {
37
+ constructor(selector, options = {}) {
38
+ super();
39
+ this.kind = 'wait-for-element';
40
+ this.selector = selector;
41
+ this.waitForElementTo = options.waitForElementTo || 'exist';
42
+ }
43
+ act(page) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ this.log(`Waiting for \`${this.selector}\` to ${this.waitForElementTo}`);
46
+ const waitForElementTo = this.waitForElementTo;
47
+ switch (waitForElementTo) {
48
+ case 'appear':
49
+ if (!(yield InteractionUtils_1.default.checkIfVisible(page, this.selector))) {
50
+ core_1.utils.haltOrThrow(`Element \`${this.selector}\` did not become visible`);
51
+ }
52
+ break;
53
+ case 'exist':
54
+ if (!(yield InteractionUtils_1.default.checkIfPresent(page, this.selector))) {
55
+ core_1.utils.haltOrThrow(`Cannot find element \`${this.selector}\``);
56
+ }
57
+ break;
58
+ case 'disappear':
59
+ if (!(yield InteractionUtils_1.default.waitForDisappearance(page, this.selector))) {
60
+ core_1.utils.haltOrThrow(`Element \`${this.selector}\` did not disappear`);
61
+ }
62
+ break;
63
+ }
64
+ });
65
+ }
66
+ }
67
+ exports.default = WaitForElementOperation;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import { Page } from 'puppeteer';
11
+ import BaseOperation from './BaseOperation';
12
+ declare class WaitOperation extends BaseOperation {
13
+ kind: string;
14
+ timeout: number;
15
+ constructor(timeout: number);
16
+ act(_page: Page): Promise<void>;
17
+ }
18
+ export default WaitOperation;
19
+ //# sourceMappingURL=WaitOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WaitOperation.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/WaitOperation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAE/B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAG5C,cAAM,aAAc,SAAQ,aAAa;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;gBAEJ,OAAO,EAAE,MAAM;IAOrB,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAKtC;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const core_1 = require("@memlab/core");
25
+ const BaseOperation_1 = __importDefault(require("./BaseOperation"));
26
+ const InteractionUtils_1 = __importDefault(require("./InteractionUtils"));
27
+ class WaitOperation extends BaseOperation_1.default {
28
+ constructor(timeout) {
29
+ super();
30
+ this.kind = 'wait';
31
+ this.timeout = timeout;
32
+ }
33
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
34
+ act(_page) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ core_1.info.lowLevel(`wait for ${this.timeout} ms ...`);
37
+ yield InteractionUtils_1.default.waitFor(this.timeout);
38
+ return;
39
+ });
40
+ }
41
+ }
42
+ exports.default = WaitOperation;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import { Page } from 'puppeteer';
11
+ import type { AnyValue } from '@memlab/core';
12
+ import BaseOperation from './BaseOperation';
13
+ declare type OperationFactory = (memCache: Record<string, AnyValue>) => BaseOperation;
14
+ /**
15
+ * Supply a factory function that produces an operation, and this operation will
16
+ * supply the memory cache to it. Use this in cases where you want the inner
17
+ * operation to be customizable based on some piece of cached content (eg. the
18
+ * URL of a post permalink created in an earlier step).
19
+ */
20
+ declare class WithCachedPageContent extends BaseOperation {
21
+ operationFactory: OperationFactory;
22
+ constructor(operationFactory: OperationFactory);
23
+ act(page: Page): Promise<void>;
24
+ }
25
+ export default WithCachedPageContent;
26
+ //# sourceMappingURL=WithCachedPageContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithCachedPageContent.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/WithCachedPageContent.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAE/B,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,aAAK,gBAAgB,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,aAAa,CAAC;AAE9E;;;;;GAKG;AACH,cAAM,qBAAsB,SAAQ,aAAa;IAC/C,gBAAgB,EAAE,gBAAgB,CAAC;gBACvB,gBAAgB,EAAE,gBAAgB;IAKxC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBrC;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const core_1 = require("@memlab/core");
25
+ const BaseOperation_1 = __importDefault(require("./BaseOperation"));
26
+ /**
27
+ * Supply a factory function that produces an operation, and this operation will
28
+ * supply the memory cache to it. Use this in cases where you want the inner
29
+ * operation to be customizable based on some piece of cached content (eg. the
30
+ * URL of a post permalink created in an earlier step).
31
+ */
32
+ class WithCachedPageContent extends BaseOperation_1.default {
33
+ constructor(operationFactory) {
34
+ super();
35
+ this.operationFactory = operationFactory;
36
+ }
37
+ act(page) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const operationFactory = this.operationFactory;
40
+ if (!operationFactory) {
41
+ core_1.utils.haltOrThrow('WithCachedPageContent: Must provide a function that returns an ' +
42
+ 'operation');
43
+ }
44
+ const operation = operationFactory(core_1.utils.memCache);
45
+ if (!operation || typeof operation.act != 'function') {
46
+ core_1.utils.haltOrThrow('WithCachedPageContent: Value returned from the operation factory ' +
47
+ 'function must be an object with an `act` method.');
48
+ }
49
+ yield operation.act(page);
50
+ });
51
+ }
52
+ }
53
+ exports.default = WithCachedPageContent;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import type { Nullable, XvfbType } from '@memlab/core';
11
+ declare const _default: {
12
+ startIfEnabled(): Nullable<XvfbType>;
13
+ };
14
+ export default _default;
15
+ //# sourceMappingURL=XVirtualFrameBuffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XVirtualFrameBuffer.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/XVirtualFrameBuffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;;sBAIjC,SAAS,QAAQ,CAAC;;AADtC,wBA0BE"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const xvfb_1 = __importDefault(require("xvfb"));
16
+ const core_1 = require("@memlab/core");
17
+ exports.default = {
18
+ startIfEnabled() {
19
+ const failRet = null;
20
+ if (!core_1.config.useXVFB || !core_1.config.machineSupportsXVFB) {
21
+ return failRet;
22
+ }
23
+ if (core_1.config.verbose) {
24
+ core_1.info.lowLevel('starting xvfb...');
25
+ }
26
+ const xvfb = new xvfb_1.default({
27
+ silent: true,
28
+ xvfb_args: ['-screen', '0', '1280x720x24', '-ac'],
29
+ timeout: 10000, // 10 seconds timeout for Xvfb start
30
+ });
31
+ try {
32
+ xvfb.startSync();
33
+ }
34
+ catch (_e) {
35
+ if (core_1.config.verbose) {
36
+ core_1.info.lowLevel('fail to start xvfb...');
37
+ }
38
+ core_1.config.disableXvfb();
39
+ return failRet;
40
+ }
41
+ core_1.config.enableXvfb(xvfb.display());
42
+ return xvfb;
43
+ },
44
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import type { AnyOptions, CheckPageLoadCallback, IE2EScenarioVisitPlan, IE2EStepBasic } from '@memlab/core';
11
+ import BaseSynthesizer from '../BaseSynthesizer';
12
+ export default class DefaultScenarioSynthesizer extends BaseSynthesizer {
13
+ getBaseURL(_options?: AnyOptions): string;
14
+ getAppName(): string;
15
+ getNumberOfWarmup(): number;
16
+ getCookieFile(): string | null;
17
+ getDomain(): string;
18
+ getAvailableSteps(): IE2EStepBasic[];
19
+ getDefaultStartStepName(): string;
20
+ getAvailableVisitPlans(): IE2EScenarioVisitPlan[];
21
+ getPageLoadChecker(): CheckPageLoadCallback;
22
+ }
23
+ //# sourceMappingURL=DefaultScenarioSynthesizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultScenarioSynthesizer.d.ts","sourceRoot":"","sources":["../../src/plugins/DefaultScenarioSynthesizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACd,MAAM,cAAc,CAAC;AAEtB,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAIjD,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,eAAe;IAErE,UAAU,CAAC,QAAQ,GAAE,UAAe,GAAG,MAAM;IAI7C,UAAU,IAAI,MAAM;IAIpB,iBAAiB,IAAI,MAAM;IAI3B,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B,SAAS,IAAI,MAAM;IAInB,iBAAiB,IAAI,aAAa,EAAE;IAIpC,uBAAuB,IAAI,MAAM;IAIjC,sBAAsB,IAAI,qBAAqB,EAAE;IAIjD,kBAAkB,IAAI,qBAAqB;CAO5C"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const BaseSynthesizer_1 = __importDefault(require("../BaseSynthesizer"));
25
+ const InteractionUtils_1 = __importDefault(require("../lib/operations/InteractionUtils"));
26
+ const E2EUtils_1 = __importDefault(require("../lib/E2EUtils"));
27
+ class DefaultScenarioSynthesizer extends BaseSynthesizer_1.default {
28
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
+ getBaseURL(_options = {}) {
30
+ return '';
31
+ }
32
+ getAppName() {
33
+ return E2EUtils_1.default.getScenarioAppName();
34
+ }
35
+ getNumberOfWarmup() {
36
+ return 1;
37
+ }
38
+ getCookieFile() {
39
+ return null;
40
+ }
41
+ getDomain() {
42
+ return '';
43
+ }
44
+ getAvailableSteps() {
45
+ return [];
46
+ }
47
+ getDefaultStartStepName() {
48
+ return '';
49
+ }
50
+ getAvailableVisitPlans() {
51
+ return [];
52
+ }
53
+ getPageLoadChecker() {
54
+ return (page) => __awaiter(this, void 0, void 0, function* () {
55
+ yield InteractionUtils_1.default.waitFor(500);
56
+ yield page.waitForNavigation({ waitUntil: 'networkidle0' });
57
+ return true;
58
+ });
59
+ }
60
+ }
61
+ exports.default = DefaultScenarioSynthesizer;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import type { AnyOptions, CheckPageLoadCallback, IE2EScenarioVisitPlan, IE2EStepBasic } from '@memlab/core';
11
+ import BaseSynthesizer from '../BaseSynthesizer';
12
+ export default class TestSPAVisitSynthesizer extends BaseSynthesizer {
13
+ getBaseURL(_options?: AnyOptions): string;
14
+ getAppName(): string;
15
+ getNumberOfWarmup(): number;
16
+ getCookieFile(): string | null;
17
+ getDomain(): string;
18
+ getAvailableSteps(): IE2EStepBasic[];
19
+ getDefaultStartStepName(): string;
20
+ getAvailableVisitPlans(): IE2EScenarioVisitPlan[];
21
+ getPageLoadChecker(): CheckPageLoadCallback;
22
+ }
23
+ //# sourceMappingURL=TestSPAVisitSynthesizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestSPAVisitSynthesizer.d.ts","sourceRoot":"","sources":["../../src/plugins/TestSPAVisitSynthesizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACd,MAAM,cAAc,CAAC;AAGtB,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAIjD,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,eAAe;IAElE,UAAU,CAAC,QAAQ,GAAE,UAAe;IAYpC,UAAU,IAAI,MAAM;IAIpB,iBAAiB,IAAI,MAAM;IAI3B,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B,SAAS,IAAI,MAAM;IAInB,iBAAiB,IAAI,aAAa,EAAE;IAYpC,uBAAuB,IAAI,MAAM;IAIjC,sBAAsB,IAAI,qBAAqB,EAAE;IAKjD,kBAAkB,IAAI,qBAAqB;CAO5C"}