@memlab/e2e 1.0.3 → 1.0.6

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/README.md CHANGED
@@ -3,5 +3,6 @@
3
3
  This is the memlab E2E testing framework for headless/headful Chromium. It is mainly responsible
4
4
  for controling/interacting with browser, recording heap snapshots, and logging other execution meta data.
5
5
 
6
- ## Full documentation
7
- https://facebookincubator.github.io/memlab
6
+ ## Online Resources
7
+ * [Official Website and Demo](https://facebookincubator.github.io/memlab)
8
+ * [Documentation](https://facebookincubator.github.io/memlab/docs/intro)
package/dist/index.d.ts CHANGED
@@ -7,6 +7,8 @@
7
7
  * @emails oncall+ws_labs
8
8
  * @format
9
9
  */
10
+ /** @internal */
11
+ export declare function registerPackage(): Promise<void>;
10
12
  export { default as defaultTestPlanner } from './lib/operations/TestPlanner';
11
13
  export * from './lib/operations/TestPlanner';
12
14
  export { default as Xvfb } from './lib/operations/XVirtualFrameBuffer';
package/dist/index.js CHANGED
@@ -22,11 +22,29 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
22
22
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
23
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
25
34
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
36
  };
28
37
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.E2EUtils = exports.BaseSynthesizer = exports.E2EInteractionManager = exports.Xvfb = exports.defaultTestPlanner = void 0;
38
+ exports.E2EUtils = exports.BaseSynthesizer = exports.E2EInteractionManager = exports.Xvfb = exports.defaultTestPlanner = exports.registerPackage = void 0;
39
+ const path_1 = __importDefault(require("path"));
40
+ const core_1 = require("@memlab/core");
41
+ /** @internal */
42
+ function registerPackage() {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ return core_1.PackageInfoLoader.registerPackage(path_1.default.join(__dirname, '..'));
45
+ });
46
+ }
47
+ exports.registerPackage = registerPackage;
30
48
  var TestPlanner_1 = require("./lib/operations/TestPlanner");
31
49
  Object.defineProperty(exports, "defaultTestPlanner", { enumerable: true, get: function () { return __importDefault(TestPlanner_1).default; } });
32
50
  __exportStar(require("./lib/operations/TestPlanner"), exports);
@@ -31,6 +31,7 @@ export declare class TestPlanner {
31
31
  private prepareSynthesizer;
32
32
  private generateVisitPlan;
33
33
  loadCookies(visitPlan: IE2EScenarioVisitPlan, synthesizer: IE2EScenarioSynthesizer): Cookies;
34
+ private populateDomainInCookiesFromScenario;
34
35
  private populateDomainInCookies;
35
36
  private setSnapshotMode;
36
37
  private assignSnapshotIds;
@@ -107,7 +107,8 @@ class TestPlanner {
107
107
  loadCookies(visitPlan, synthesizer) {
108
108
  var _a;
109
109
  if (this.scenario && this.scenario.cookies) {
110
- return this.scenario.cookies();
110
+ const cookies = this.scenario.cookies();
111
+ return this.populateDomainInCookiesFromScenario(cookies, this.scenario);
111
112
  }
112
113
  let cookieFile = synthesizer.getCookieFile(visitPlan);
113
114
  // if no cookie file is specified
@@ -122,6 +123,20 @@ class TestPlanner {
122
123
  const cookies = JSON.parse(fs_1.default.readFileSync(cookieFile, 'UTF-8'));
123
124
  return this.populateDomainInCookies(cookies, synthesizer.getDomain(), synthesizer.getDomainPrefixes());
124
125
  }
126
+ populateDomainInCookiesFromScenario(cookies, scenario) {
127
+ const ret = [];
128
+ const url = new URL(scenario.url());
129
+ const domain = '.' + url.hostname.split('.').slice(1).join('.');
130
+ for (const cookie of cookies) {
131
+ if (cookie.domain) {
132
+ ret.push(Object.assign({}, cookie));
133
+ }
134
+ else {
135
+ ret.push(Object.assign(Object.assign({}, cookie), { domain }));
136
+ }
137
+ }
138
+ return ret;
139
+ }
125
140
  populateDomainInCookies(cookies, domain, domainPrefixes) {
126
141
  const cookiesTemplate = cookies;
127
142
  const ret = [];
@@ -36,6 +36,6 @@ function back(page) {
36
36
  }
37
37
  // specify the number of repeat for the action
38
38
  function repeat() {
39
- return 15;
39
+ return 1;
40
40
  }
41
41
  module.exports = { action, back, repeat, url };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memlab/e2e",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "license": "MIT",
5
5
  "description": "memlab browser E2E interaction libraries",
6
6
  "author": "Liang Gong <lgong@fb.com>",
@@ -20,7 +20,7 @@
20
20
  "static"
21
21
  ],
22
22
  "dependencies": {
23
- "@memlab/core": "^1.0.0",
23
+ "@memlab/core": "^1.1.5",
24
24
  "ansi": "^0.3.1",
25
25
  "babar": "^0.2.0",
26
26
  "chalk": "^4.0.0",
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @emails oncall+ws_labs
8
8
  * @format
9
+ * @oncall ws_labs
9
10
  */
10
11
 
11
12
  import Layout from '../components/layout.jsx';
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @emails oncall+ws_labs
8
8
  * @format
9
+ * @oncall ws_labs
9
10
  */
10
11
 
11
12
  import {Head, Html, Main, NextScript} from 'next/document';
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @emails oncall+ws_labs
8
8
  * @format
9
+ * @oncall ws_labs
9
10
  */
10
11
 
11
12
  import Link from 'next/link';
@@ -11,7 +11,7 @@
11
11
 
12
12
  import React from 'react';
13
13
 
14
- // Use the the window.injectHookForLink{n} hook to inject objects
14
+ // Use the window.injectHookForLink{n} hook to inject objects
15
15
  // to memory when link-{n} is triggered, for example:
16
16
  //
17
17
  // window.injectHookForLink4 = () => {