@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,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
+ export { default as CachePageContent } from './CachePageContent';
11
+ export { default as ClickOperation } from './ClickOperation';
12
+ export { default as CompoundOperation } from './CompoundOperation';
13
+ export { default as EnterOperation } from './EnterOperation';
14
+ export { default as EscOperation } from './EscOperation';
15
+ export { default as BackOperation } from './BackOperation';
16
+ export { default as BackspaceOperation } from './BackspaceOperation';
17
+ export { default as HoverOperation } from './HoverOperation';
18
+ export { default as RunJSCode } from './RunJSCode';
19
+ export { default as ScrollOperation } from './ScrollOperation';
20
+ export { default as TypeOperation } from './TypeOperation';
21
+ export { default as UploadOperation } from './UploadOperation';
22
+ export { default as WaitForElementOperation } from './WaitForElementOperation';
23
+ export { default as WaitOperation } from './WaitOperation';
24
+ export { default as WithCachedPageContent } from './WithCachedPageContent';
25
+ //# sourceMappingURL=Operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Operations.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/Operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAC,OAAO,IAAI,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,qBAAqB,EAAC,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,45 @@
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
+ exports.WithCachedPageContent = exports.WaitOperation = exports.WaitForElementOperation = exports.UploadOperation = exports.TypeOperation = exports.ScrollOperation = exports.RunJSCode = exports.HoverOperation = exports.BackspaceOperation = exports.BackOperation = exports.EscOperation = exports.EnterOperation = exports.CompoundOperation = exports.ClickOperation = exports.CachePageContent = void 0;
16
+ var CachePageContent_1 = require("./CachePageContent");
17
+ Object.defineProperty(exports, "CachePageContent", { enumerable: true, get: function () { return __importDefault(CachePageContent_1).default; } });
18
+ var ClickOperation_1 = require("./ClickOperation");
19
+ Object.defineProperty(exports, "ClickOperation", { enumerable: true, get: function () { return __importDefault(ClickOperation_1).default; } });
20
+ var CompoundOperation_1 = require("./CompoundOperation");
21
+ Object.defineProperty(exports, "CompoundOperation", { enumerable: true, get: function () { return __importDefault(CompoundOperation_1).default; } });
22
+ var EnterOperation_1 = require("./EnterOperation");
23
+ Object.defineProperty(exports, "EnterOperation", { enumerable: true, get: function () { return __importDefault(EnterOperation_1).default; } });
24
+ var EscOperation_1 = require("./EscOperation");
25
+ Object.defineProperty(exports, "EscOperation", { enumerable: true, get: function () { return __importDefault(EscOperation_1).default; } });
26
+ var BackOperation_1 = require("./BackOperation");
27
+ Object.defineProperty(exports, "BackOperation", { enumerable: true, get: function () { return __importDefault(BackOperation_1).default; } });
28
+ var BackspaceOperation_1 = require("./BackspaceOperation");
29
+ Object.defineProperty(exports, "BackspaceOperation", { enumerable: true, get: function () { return __importDefault(BackspaceOperation_1).default; } });
30
+ var HoverOperation_1 = require("./HoverOperation");
31
+ Object.defineProperty(exports, "HoverOperation", { enumerable: true, get: function () { return __importDefault(HoverOperation_1).default; } });
32
+ var RunJSCode_1 = require("./RunJSCode");
33
+ Object.defineProperty(exports, "RunJSCode", { enumerable: true, get: function () { return __importDefault(RunJSCode_1).default; } });
34
+ var ScrollOperation_1 = require("./ScrollOperation");
35
+ Object.defineProperty(exports, "ScrollOperation", { enumerable: true, get: function () { return __importDefault(ScrollOperation_1).default; } });
36
+ var TypeOperation_1 = require("./TypeOperation");
37
+ Object.defineProperty(exports, "TypeOperation", { enumerable: true, get: function () { return __importDefault(TypeOperation_1).default; } });
38
+ var UploadOperation_1 = require("./UploadOperation");
39
+ Object.defineProperty(exports, "UploadOperation", { enumerable: true, get: function () { return __importDefault(UploadOperation_1).default; } });
40
+ var WaitForElementOperation_1 = require("./WaitForElementOperation");
41
+ Object.defineProperty(exports, "WaitForElementOperation", { enumerable: true, get: function () { return __importDefault(WaitForElementOperation_1).default; } });
42
+ var WaitOperation_1 = require("./WaitOperation");
43
+ Object.defineProperty(exports, "WaitOperation", { enumerable: true, get: function () { return __importDefault(WaitOperation_1).default; } });
44
+ var WithCachedPageContent_1 = require("./WithCachedPageContent");
45
+ Object.defineProperty(exports, "WithCachedPageContent", { enumerable: true, get: function () { return __importDefault(WithCachedPageContent_1).default; } });
@@ -0,0 +1,18 @@
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 BaseOperation from './BaseOperation';
11
+ import type { Page } from 'puppeteer';
12
+ import type { OperationArgs } from '@memlab/core';
13
+ export default class RevertOperation extends BaseOperation {
14
+ kind: string;
15
+ constructor();
16
+ act(page: Page, opArgs?: OperationArgs): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=RevertOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RevertOperation.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/RevertOperation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAEpC,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAIhD,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,aAAa;IACxD,IAAI,EAAE,MAAM,CAAC;;IAOP,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAmBjE"}
@@ -0,0 +1,55 @@
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 BaseOperation_1 = __importDefault(require("./BaseOperation"));
25
+ const EscOperation_1 = __importDefault(require("./EscOperation"));
26
+ const BackOperation_1 = __importDefault(require("./BackOperation"));
27
+ const InteractionUtils_1 = __importDefault(require("./InteractionUtils"));
28
+ class RevertOperation extends BaseOperation_1.default {
29
+ constructor() {
30
+ super();
31
+ this.kind = 'revert';
32
+ }
33
+ act(page, opArgs = {}) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ let historyLen = opArgs.pageHistoryLength;
36
+ if (Array.isArray(historyLen) && historyLen.length > 1) {
37
+ historyLen = historyLen;
38
+ const len = historyLen.length;
39
+ const count = historyLen[len - 1];
40
+ const prevCount = historyLen[len - 2];
41
+ let navCountFromPreviousOp = (count | 0) - (prevCount | 0);
42
+ if (navCountFromPreviousOp > 0) {
43
+ while (navCountFromPreviousOp > 0) {
44
+ yield new BackOperation_1.default().act(page);
45
+ yield InteractionUtils_1.default.waitFor(2000);
46
+ --navCountFromPreviousOp;
47
+ }
48
+ return;
49
+ }
50
+ }
51
+ yield new EscOperation_1.default().act(page);
52
+ });
53
+ }
54
+ }
55
+ exports.default = RevertOperation;
@@ -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 { Page } from 'puppeteer';
11
+ import type { AnyFunction, AnyOptions, AnyValue } from '@memlab/core';
12
+ import BaseOperation from './BaseOperation';
13
+ declare class RunJSCode extends BaseOperation {
14
+ kind: string;
15
+ private callback;
16
+ private repeat;
17
+ private args;
18
+ constructor(callback: AnyFunction, opt?: AnyOptions & {
19
+ repeat?: number;
20
+ args?: AnyValue[];
21
+ });
22
+ act(page: Page): Promise<void>;
23
+ }
24
+ export default RunJSCode;
25
+ //# sourceMappingURL=RunJSCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RunJSCode.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/RunJSCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAE/B,OAAO,KAAK,EAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AACpE,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAI5C,cAAM,SAAU,SAAQ,aAAa;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,IAAI,CAAa;gBAGvB,QAAQ,EAAE,WAAW,EACrB,GAAG,GAAE,UAAU,GAAG;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAA;KAAM;IASvD,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAWrC;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,51 @@
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
+ // Run a JS callback in web console
28
+ class RunJSCode extends BaseOperation_1.default {
29
+ constructor(callback, opt = {}) {
30
+ super();
31
+ this.kind = 'run-js-code';
32
+ this.callback = callback;
33
+ this.repeat = opt.repeat != null && opt.repeat > 0 ? opt.repeat : 1;
34
+ this.args = opt.args || [];
35
+ }
36
+ act(page) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ try {
39
+ let n = this.repeat;
40
+ while (n-- > 0) {
41
+ yield page.evaluate(this.callback, ...this.args);
42
+ yield InteractionUtils_1.default.waitFor(1000);
43
+ }
44
+ }
45
+ catch (e) {
46
+ core_1.info.warning(core_1.utils.getError(e).message);
47
+ }
48
+ });
49
+ }
50
+ }
51
+ exports.default = RunJSCode;
@@ -0,0 +1,27 @@
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 { OperationArgs } from '@memlab/core';
12
+ import BaseOperation from './BaseOperation';
13
+ declare type ScrollOptions = {
14
+ scrollUp?: boolean;
15
+ scrollBack?: boolean;
16
+ };
17
+ declare class ScrollOperation extends BaseOperation {
18
+ kind: string;
19
+ strideLength: number;
20
+ repeat: number;
21
+ scrollDirection: number;
22
+ scrollBack: boolean;
23
+ constructor(strideLength: number, repeat?: number, opt?: ScrollOptions);
24
+ act(page: Page, opArgs?: OperationArgs): Promise<void>;
25
+ }
26
+ export default ScrollOperation;
27
+ //# sourceMappingURL=ScrollOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollOperation.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/ScrollOperation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAC/B,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAEhD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAG5C,aAAK,aAAa,GAAG;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,cAAM,eAAgB,SAAQ,aAAa;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;gBACR,YAAY,EAAE,MAAM,EAAE,MAAM,SAAI,EAAE,GAAG,GAAE,aAAkB;IAY/D,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAoBjE;AA4BD,eAAe,eAAe,CAAC"}
@@ -0,0 +1,85 @@
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 ScrollOperation extends BaseOperation_1.default {
28
+ constructor(strideLength, repeat = 1, opt = {}) {
29
+ super();
30
+ this.kind = 'scroll';
31
+ this.strideLength = strideLength;
32
+ this.repeat = repeat;
33
+ // by default scroll down (1 means down, -1 means up)
34
+ this.scrollDirection = opt.scrollUp ? -1 : 1;
35
+ // by default scrollback to the beginning
36
+ this.scrollBack =
37
+ typeof opt.scrollBack === 'boolean' ? opt.scrollBack : true;
38
+ }
39
+ act(page, opArgs = {}) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ if (core_1.config.disableScroll || !core_1.config.runningMode.shouldScroll()) {
42
+ return;
43
+ }
44
+ let repeat = this.repeat;
45
+ let i = 0;
46
+ let totalScrollDistance = 0;
47
+ const direction = this.scrollDirection > 0 ? 'down' : 'up';
48
+ core_1.info.lowLevel(`scrolling ${direction} ${repeat} times...`);
49
+ const strideLength = this.scrollDirection * this.strideLength;
50
+ while (repeat-- > 0) {
51
+ totalScrollDistance += strideLength;
52
+ yield scroll(page, strideLength, ++i, opArgs);
53
+ }
54
+ if (this.scrollBack && totalScrollDistance > 0) {
55
+ // scroll back to the top
56
+ yield scroll(page, -1 * totalScrollDistance, -1, opArgs);
57
+ }
58
+ return;
59
+ });
60
+ }
61
+ }
62
+ function scroll(page, dist, idx = 0, opArgs) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ core_1.info.beginSection('scroll');
65
+ yield InteractionUtils_1.default.waitUntilLoaded(page, opArgs);
66
+ if (idx > 1) {
67
+ core_1.info.overwrite(`(${idx}x) scrolling ${dist}px...`);
68
+ }
69
+ else {
70
+ core_1.info.overwrite(`scrolling ${dist}px...`);
71
+ }
72
+ yield page.evaluate(dist => {
73
+ try {
74
+ window.scrollBy({ top: dist });
75
+ }
76
+ catch (_e) {
77
+ // to nothing
78
+ }
79
+ }, dist);
80
+ yield InteractionUtils_1.default.waitUntilLoaded(page, opArgs);
81
+ yield InteractionUtils_1.default.waitFor(core_1.config.waitAfterScrolling);
82
+ core_1.info.endSection('scroll');
83
+ });
84
+ }
85
+ exports.default = ScrollOperation;
@@ -0,0 +1,18 @@
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 BaseOperation from './BaseOperation';
11
+ import CompoundOperation from './CompoundOperation';
12
+ declare class TargetExtraOperation extends CompoundOperation {
13
+ kind: string;
14
+ operations: BaseOperation[];
15
+ constructor(operations?: never[]);
16
+ }
17
+ export default TargetExtraOperation;
18
+ //# sourceMappingURL=TargetExtraOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TargetExtraOperation.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/TargetExtraOperation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAGpD,cAAM,oBAAqB,SAAQ,iBAAiB;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,aAAa,EAAE,CAAC;gBAChB,UAAU,UAAK;CAW5B;AAED,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,28 @@
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 core_1 = require("@memlab/core");
16
+ const CompoundOperation_1 = __importDefault(require("./CompoundOperation"));
17
+ const ScrollOperation_1 = __importDefault(require("./ScrollOperation"));
18
+ class TargetExtraOperation extends CompoundOperation_1.default {
19
+ constructor(operations = []) {
20
+ super(operations);
21
+ this.kind = 'target-extra';
22
+ if (core_1.config.runningMode.shouldRunExtraTargetOperations()) {
23
+ // scroll the window by certain amount of pixels
24
+ this.operations.push(new ScrollOperation_1.default(core_1.config.windowHeight, core_1.config.scrollRepeat));
25
+ }
26
+ }
27
+ }
28
+ exports.default = TargetExtraOperation;
@@ -0,0 +1,46 @@
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, Cookies, IE2EScenarioSynthesizer, IE2EScenarioVisitPlan, Nullable } from '@memlab/core';
11
+ import type { MemLabConfig } from '@memlab/core';
12
+ declare type TestPlanOptions = {
13
+ config?: MemLabConfig;
14
+ };
15
+ export declare class TestPlanner {
16
+ private synthesizers;
17
+ private visitPlan;
18
+ private cookies;
19
+ private scenario;
20
+ private origin;
21
+ private synthesizer;
22
+ private config;
23
+ constructor(options?: TestPlanOptions);
24
+ private initSynthesizers;
25
+ getVisitPlan(): IE2EScenarioVisitPlan;
26
+ getCookies(): Cookies;
27
+ getOrigin(): Nullable<string>;
28
+ getSynthesizer(options?: AnyOptions): IE2EScenarioSynthesizer;
29
+ preloadSynthesizer(): IE2EScenarioSynthesizer;
30
+ private init;
31
+ private prepareSynthesizer;
32
+ private generateVisitPlan;
33
+ loadCookies(visitPlan: IE2EScenarioVisitPlan, synthesizer: IE2EScenarioSynthesizer): Cookies;
34
+ private populateDomainInCookies;
35
+ private setSnapshotMode;
36
+ private assignSnapshotIds;
37
+ getAppNames(): string[];
38
+ getTargetNames(appName: string, options?: AnyOptions): string[];
39
+ getAllTargets(options?: AnyOptions): {
40
+ app: string;
41
+ interaction: string;
42
+ }[];
43
+ }
44
+ declare const _default: TestPlanner;
45
+ export default _default;
46
+ //# sourceMappingURL=TestPlanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestPlanner.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/TestPlanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,uBAAuB,EACvB,qBAAqB,EAIrB,QAAQ,EACT,MAAM,cAAc,CAAC;AAKtB,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAS/C,aAAK,eAAe,GAAG;IACrB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,qBAAa,WAAW;IACtB,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,SAAS,CAAwB;IACzC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,MAAM,CAAe;gBAEjB,OAAO,GAAE,eAAoB;IAMzC,OAAO,CAAC,gBAAgB;IAYxB,YAAY,IAAI,qBAAqB;IAKrC,UAAU,IAAI,OAAO;IAMrB,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC;IAK7B,cAAc,CAAC,OAAO,GAAE,UAAe,GAAG,uBAAuB;IAOjE,kBAAkB,IAAI,uBAAuB;IAS7C,OAAO,CAAC,IAAI;IASZ,OAAO,CAAC,kBAAkB;IA8B1B,OAAO,CAAC,iBAAiB;IAczB,WAAW,CACT,SAAS,EAAE,qBAAqB,EAChC,WAAW,EAAE,uBAAuB,GACnC,OAAO;IA0BV,OAAO,CAAC,uBAAuB;IAgB/B,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,iBAAiB;IAQzB,WAAW,IAAI,MAAM,EAAE;IASvB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,GAAG,MAAM,EAAE;IAWnE,aAAa,CACX,OAAO,GAAE,UAAe,GACvB;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAC,EAAE;CAYxC;;AAED,wBAAiC"}
@@ -0,0 +1,182 @@
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
+ 'use strict';
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
+ exports.TestPlanner = void 0;
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const core_1 = require("@memlab/core");
19
+ const TestRunnerLoader_1 = __importDefault(require("../../TestRunnerLoader"));
20
+ const E2EUtils_1 = __importDefault(require("../E2EUtils"));
21
+ class TestPlanner {
22
+ constructor(options = {}) {
23
+ var _a;
24
+ this.config = (_a = options.config) !== null && _a !== void 0 ? _a : core_1.config;
25
+ this.synthesizers = new Map();
26
+ this.scenario = null;
27
+ }
28
+ initSynthesizers() {
29
+ if (this.synthesizers.size > 0) {
30
+ return;
31
+ }
32
+ this.synthesizers = new Map();
33
+ const runners = TestRunnerLoader_1.default.load();
34
+ runners.forEach((Constructor) => {
35
+ const synthesizer = new Constructor(this.config);
36
+ this.synthesizers.set(synthesizer.getAppName(), synthesizer);
37
+ });
38
+ }
39
+ getVisitPlan() {
40
+ this.init();
41
+ return this.visitPlan;
42
+ }
43
+ getCookies() {
44
+ this.init();
45
+ return this.cookies;
46
+ }
47
+ // get origin defined in config
48
+ getOrigin() {
49
+ this.init();
50
+ return this.origin;
51
+ }
52
+ getSynthesizer(options = {}) {
53
+ this.init(options);
54
+ return this.synthesizer;
55
+ }
56
+ // preload synthesizer before other meta data is ready
57
+ // this is mainly used for getting synthesizer settings
58
+ preloadSynthesizer() {
59
+ const targetApp = this.config.targetApp;
60
+ this.initSynthesizers();
61
+ if (!this.synthesizers.has(targetApp)) {
62
+ core_1.utils.haltOrThrow(`unknown app: ${targetApp}`);
63
+ }
64
+ return this.synthesizers.get(targetApp);
65
+ }
66
+ init(options = {}) {
67
+ this.initSynthesizers();
68
+ const { visitPlan, cookies, synthesizer } = this.generateVisitPlan(options);
69
+ this.visitPlan = visitPlan;
70
+ this.cookies = cookies;
71
+ this.origin = synthesizer.getOrigin();
72
+ this.synthesizer = synthesizer;
73
+ }
74
+ prepareSynthesizer() {
75
+ if (this.config.scenario) {
76
+ this.scenario = this.config.scenario;
77
+ }
78
+ else {
79
+ // otherwise no action since no scenario definition provided
80
+ // config.targetTab and config.targetApp should be set
81
+ }
82
+ if (this.scenario) {
83
+ this.config.targetTab = core_1.utils.getScenarioName(this.scenario);
84
+ this.config.targetApp = E2EUtils_1.default.getScenarioAppName(this.scenario);
85
+ }
86
+ if (!this.synthesizers.has(this.config.targetApp)) {
87
+ core_1.utils.haltOrThrow(`unknown app: ${this.config.targetApp}`);
88
+ }
89
+ const synthesizer = this.synthesizers.get(this.config.targetApp);
90
+ // if running from a scenario file, register this
91
+ // new scenario in the synthesizer
92
+ if (this.scenario) {
93
+ synthesizer.injectPlan(this.config.targetTab, this.scenario);
94
+ }
95
+ return synthesizer;
96
+ }
97
+ generateVisitPlan(options = {}) {
98
+ const synthesizer = this.prepareSynthesizer();
99
+ const visitPlan = synthesizer.synthesisForTarget(this.config.targetTab);
100
+ this.assignSnapshotIds(visitPlan);
101
+ this.setSnapshotMode(visitPlan);
102
+ const cookies = options.needCookies === false
103
+ ? []
104
+ : this.loadCookies(visitPlan, synthesizer);
105
+ return { visitPlan, cookies, synthesizer };
106
+ }
107
+ loadCookies(visitPlan, synthesizer) {
108
+ var _a;
109
+ if (this.scenario && this.scenario.cookies) {
110
+ return this.scenario.cookies();
111
+ }
112
+ let cookieFile = synthesizer.getCookieFile(visitPlan);
113
+ // if no cookie file is specified
114
+ if (cookieFile == null && this.config.externalCookiesFile == null) {
115
+ return [];
116
+ }
117
+ cookieFile =
118
+ (_a = this.config.externalCookiesFile) !== null && _a !== void 0 ? _a : path_1.default.join(this.config.persistentDataDir, cookieFile);
119
+ if (!fs_1.default.existsSync(cookieFile)) {
120
+ core_1.utils.haltOrThrow(`cookie file doesn't exist: ${cookieFile}`);
121
+ }
122
+ const cookies = JSON.parse(fs_1.default.readFileSync(cookieFile, 'UTF-8'));
123
+ return this.populateDomainInCookies(cookies, synthesizer.getDomain(), synthesizer.getDomainPrefixes());
124
+ }
125
+ populateDomainInCookies(cookies, domain, domainPrefixes) {
126
+ const cookiesTemplate = cookies;
127
+ const ret = [];
128
+ const prefixes = new Set(['', ...domainPrefixes]);
129
+ for (const prefix of prefixes) {
130
+ for (const cookie of cookiesTemplate) {
131
+ ret.push(Object.assign(Object.assign({}, cookie), { domain: `${prefix}${domain}` }));
132
+ }
133
+ }
134
+ return ret;
135
+ }
136
+ setSnapshotMode(visitPlan) {
137
+ if (!this.config.isFullRun) {
138
+ return;
139
+ }
140
+ const tabsOrder = visitPlan.tabsOrder;
141
+ for (const tab of tabsOrder) {
142
+ tab.snapshot = true;
143
+ }
144
+ }
145
+ assignSnapshotIds(visitPlan) {
146
+ const tabsOrder = visitPlan.tabsOrder;
147
+ let snapshotId = 1;
148
+ for (const tab of tabsOrder) {
149
+ tab.idx = snapshotId++;
150
+ }
151
+ }
152
+ getAppNames() {
153
+ this.initSynthesizers();
154
+ const names = [];
155
+ for (const synthesizer of this.synthesizers.values()) {
156
+ names.push(synthesizer.getAppName());
157
+ }
158
+ return names;
159
+ }
160
+ getTargetNames(appName, options = {}) {
161
+ this.initSynthesizers();
162
+ if (!this.synthesizers.has(appName)) {
163
+ core_1.utils.haltOrThrow(`unknown app: ${appName}`);
164
+ }
165
+ const synthesizer = this.synthesizers.get(appName);
166
+ return synthesizer.getAvailableTargetNames(options);
167
+ }
168
+ getAllTargets(options = {}) {
169
+ this.initSynthesizers();
170
+ const ret = [];
171
+ const apps = this.getAppNames();
172
+ for (const app of apps) {
173
+ const interactions = this.getTargetNames(app, options);
174
+ for (const interaction of interactions) {
175
+ ret.push({ app, interaction });
176
+ }
177
+ }
178
+ return ret;
179
+ }
180
+ }
181
+ exports.TestPlanner = TestPlanner;
182
+ exports.default = new TestPlanner();