@twilio/flex-plugin-e2e-tests 5.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 (102) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -0
  3. package/dist/core/index.d.ts +3 -0
  4. package/dist/core/index.js +16 -0
  5. package/dist/core/index.js.map +1 -0
  6. package/dist/core/parameters.d.ts +54 -0
  7. package/dist/core/parameters.js +95 -0
  8. package/dist/core/parameters.js.map +1 -0
  9. package/dist/core/runner.d.ts +8 -0
  10. package/dist/core/runner.js +313 -0
  11. package/dist/core/runner.js.map +1 -0
  12. package/dist/core/suites.d.ts +11 -0
  13. package/dist/core/suites.js +17 -0
  14. package/dist/core/suites.js.map +1 -0
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.js +16 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/tests/step001.d.ts +3 -0
  19. package/dist/tests/step001.js +65 -0
  20. package/dist/tests/step001.js.map +1 -0
  21. package/dist/tests/step002.d.ts +3 -0
  22. package/dist/tests/step002.js +133 -0
  23. package/dist/tests/step002.js.map +1 -0
  24. package/dist/tests/step003.d.ts +3 -0
  25. package/dist/tests/step003.js +63 -0
  26. package/dist/tests/step003.js.map +1 -0
  27. package/dist/tests/step004.d.ts +3 -0
  28. package/dist/tests/step004.js +65 -0
  29. package/dist/tests/step004.js.map +1 -0
  30. package/dist/tests/step005.d.ts +3 -0
  31. package/dist/tests/step005.js +86 -0
  32. package/dist/tests/step005.js.map +1 -0
  33. package/dist/tests/step006.d.ts +3 -0
  34. package/dist/tests/step006.js +122 -0
  35. package/dist/tests/step006.js.map +1 -0
  36. package/dist/tests/step007.d.ts +3 -0
  37. package/dist/tests/step007.js +122 -0
  38. package/dist/tests/step007.js.map +1 -0
  39. package/dist/tests/step008.d.ts +3 -0
  40. package/dist/tests/step008.js +103 -0
  41. package/dist/tests/step008.js.map +1 -0
  42. package/dist/tests/step009.d.ts +3 -0
  43. package/dist/tests/step009.js +119 -0
  44. package/dist/tests/step009.js.map +1 -0
  45. package/dist/tests/step010.d.ts +3 -0
  46. package/dist/tests/step010.js +168 -0
  47. package/dist/tests/step010.js.map +1 -0
  48. package/dist/tests/step011.d.ts +3 -0
  49. package/dist/tests/step011.js +164 -0
  50. package/dist/tests/step011.js.map +1 -0
  51. package/dist/tests/step012.d.ts +3 -0
  52. package/dist/tests/step012.js +177 -0
  53. package/dist/tests/step012.js.map +1 -0
  54. package/dist/utils/assertion.d.ts +39 -0
  55. package/dist/utils/assertion.js +151 -0
  56. package/dist/utils/assertion.js.map +1 -0
  57. package/dist/utils/browser.d.ts +20 -0
  58. package/dist/utils/browser.js +142 -0
  59. package/dist/utils/browser.js.map +1 -0
  60. package/dist/utils/console-api.d.ts +43 -0
  61. package/dist/utils/console-api.js +154 -0
  62. package/dist/utils/console-api.js.map +1 -0
  63. package/dist/utils/index.d.ts +9 -0
  64. package/dist/utils/index.js +35 -0
  65. package/dist/utils/index.js.map +1 -0
  66. package/dist/utils/pages/app.d.ts +37 -0
  67. package/dist/utils/pages/app.js +133 -0
  68. package/dist/utils/pages/app.js.map +1 -0
  69. package/dist/utils/pages/index.d.ts +1 -0
  70. package/dist/utils/pages/index.js +14 -0
  71. package/dist/utils/pages/index.js.map +1 -0
  72. package/dist/utils/pages/view/admin-dashboard.d.ts +17 -0
  73. package/dist/utils/pages/view/admin-dashboard.js +91 -0
  74. package/dist/utils/pages/view/admin-dashboard.js.map +1 -0
  75. package/dist/utils/pages/view/agent-desktop.d.ts +17 -0
  76. package/dist/utils/pages/view/agent-desktop.js +91 -0
  77. package/dist/utils/pages/view/agent-desktop.js.map +1 -0
  78. package/dist/utils/pages/view/base.d.ts +29 -0
  79. package/dist/utils/pages/view/base.js +124 -0
  80. package/dist/utils/pages/view/base.js.map +1 -0
  81. package/dist/utils/pages/view/plugins.d.ts +31 -0
  82. package/dist/utils/pages/view/plugins.js +112 -0
  83. package/dist/utils/pages/view/plugins.js.map +1 -0
  84. package/dist/utils/pages/view/twilio-console.d.ts +26 -0
  85. package/dist/utils/pages/view/twilio-console.js +143 -0
  86. package/dist/utils/pages/view/twilio-console.js.map +1 -0
  87. package/dist/utils/plugin-helper.d.ts +6 -0
  88. package/dist/utils/plugin-helper.js +131 -0
  89. package/dist/utils/plugin-helper.js.map +1 -0
  90. package/dist/utils/plugins-api.d.ts +11 -0
  91. package/dist/utils/plugins-api.js +195 -0
  92. package/dist/utils/plugins-api.js.map +1 -0
  93. package/dist/utils/serverless-api.d.ts +7 -0
  94. package/dist/utils/serverless-api.js +117 -0
  95. package/dist/utils/serverless-api.js.map +1 -0
  96. package/dist/utils/spawn.d.ts +26 -0
  97. package/dist/utils/spawn.js +169 -0
  98. package/dist/utils/spawn.js.map +1 -0
  99. package/dist/utils/timers.d.ts +5 -0
  100. package/dist/utils/timers.js +48 -0
  101. package/dist/utils/timers.js.map +1 -0
  102. package/package.json +57 -0
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.AdminDashboard = void 0;
55
+ var base_1 = require("./base");
56
+ var AdminDashboard = /** @class */ (function (_super) {
57
+ __extends(AdminDashboard, _super);
58
+ function AdminDashboard(page, baseUrl) {
59
+ var _this = _super.call(this, page) || this;
60
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
61
+ _this.assert = {
62
+ /**
63
+ * Checks whether Welcome Banner is visible on Admin Dashboard
64
+ */
65
+ isVisible: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
66
+ return [2 /*return*/, this.elementVisible(AdminDashboard._welcomeBanner, 'Welcome banner')];
67
+ }); }); },
68
+ };
69
+ _this._baseUrl = baseUrl;
70
+ return _this;
71
+ }
72
+ /**
73
+ * Navigates to Admin Dashboard
74
+ */
75
+ AdminDashboard.prototype.open = function () {
76
+ return __awaiter(this, void 0, void 0, function () {
77
+ return __generator(this, function (_a) {
78
+ switch (_a.label) {
79
+ case 0: return [4 /*yield*/, this.goto({ baseUrl: this._baseUrl, path: 'admin' })];
80
+ case 1:
81
+ _a.sent();
82
+ return [2 /*return*/];
83
+ }
84
+ });
85
+ });
86
+ };
87
+ AdminDashboard._welcomeBanner = '.welcome-banner';
88
+ return AdminDashboard;
89
+ }(base_1.Base));
90
+ exports.AdminDashboard = AdminDashboard;
91
+ //# sourceMappingURL=admin-dashboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-dashboard.js","sourceRoot":"","sources":["../../../../src/utils/pages/view/admin-dashboard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,+BAA8B;AAE9B;IAAoC,kCAAI;IActC,wBAAY,IAAU,EAAE,OAAe;QAAvC,YACE,kBAAM,IAAI,CAAC,SAEZ;QAdD,6EAA6E;QAC7E,YAAM,GAAG;YACP;;eAEG;YACH,SAAS,EAAE;gBACT,sBAAA,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,gBAAgB,CAAC,EAAA;qBAAA;SACvE,CAAC;QAMA,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;;IAC1B,CAAC;IAED;;OAEG;IACG,6BAAI,GAAV;;;;4BACE,qBAAM,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAA;;wBAA1D,SAA0D,CAAC;;;;;KAC5D;IAvBuB,6BAAc,GAAG,iBAAiB,CAAC;IAwB7D,qBAAC;CAAA,AAzBD,CAAoC,WAAI,GAyBvC;AAzBY,wCAAc"}
@@ -0,0 +1,17 @@
1
+ import { ElementHandle, Page } from 'puppeteer';
2
+ import { Base } from './base';
3
+ export declare class AgentDesktop extends Base {
4
+ private static readonly _noTaskCanvas;
5
+ assert: {
6
+ /**
7
+ * Checks whether task canvas are visible on the Agent Desktop
8
+ */
9
+ isVisible: () => Promise<ElementHandle<Element>>;
10
+ };
11
+ private readonly _baseUrl;
12
+ constructor(page: Page, baseUrl: string);
13
+ /**
14
+ * Navigates to Agent Desktop
15
+ */
16
+ open(): Promise<void>;
17
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.AgentDesktop = void 0;
55
+ var base_1 = require("./base");
56
+ var AgentDesktop = /** @class */ (function (_super) {
57
+ __extends(AgentDesktop, _super);
58
+ function AgentDesktop(page, baseUrl) {
59
+ var _this = _super.call(this, page) || this;
60
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
61
+ _this.assert = {
62
+ /**
63
+ * Checks whether task canvas are visible on the Agent Desktop
64
+ */
65
+ isVisible: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
66
+ return [2 /*return*/, this.elementVisible(AgentDesktop._noTaskCanvas, 'Task canvas')];
67
+ }); }); },
68
+ };
69
+ _this._baseUrl = baseUrl;
70
+ return _this;
71
+ }
72
+ /**
73
+ * Navigates to Agent Desktop
74
+ */
75
+ AgentDesktop.prototype.open = function () {
76
+ return __awaiter(this, void 0, void 0, function () {
77
+ return __generator(this, function (_a) {
78
+ switch (_a.label) {
79
+ case 0: return [4 /*yield*/, this.goto({ baseUrl: this._baseUrl, path: 'agent-desktop' })];
80
+ case 1:
81
+ _a.sent();
82
+ return [2 /*return*/];
83
+ }
84
+ });
85
+ });
86
+ };
87
+ AgentDesktop._noTaskCanvas = '.Twilio-NoTasksCanvas';
88
+ return AgentDesktop;
89
+ }(base_1.Base));
90
+ exports.AgentDesktop = AgentDesktop;
91
+ //# sourceMappingURL=agent-desktop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-desktop.js","sourceRoot":"","sources":["../../../../src/utils/pages/view/agent-desktop.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,+BAA8B;AAE9B;IAAkC,gCAAI;IAcpC,sBAAY,IAAU,EAAE,OAAe;QAAvC,YACE,kBAAM,IAAI,CAAC,SAEZ;QAdD,6EAA6E;QAC7E,YAAM,GAAG;YACP;;eAEG;YACH,SAAS,EAAE;gBACT,sBAAA,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,aAAa,EAAE,aAAa,CAAC,EAAA;qBAAA;SACjE,CAAC;QAMA,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;;IAC1B,CAAC;IAED;;OAEG;IACG,2BAAI,GAAV;;;;4BACE,qBAAM,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,EAAA;;wBAAlE,SAAkE,CAAC;;;;;KACpE;IAvBuB,0BAAa,GAAG,uBAAuB,CAAC;IAwBlE,mBAAC;CAAA,AAzBD,CAAkC,WAAI,GAyBrC;AAzBY,oCAAY"}
@@ -0,0 +1,29 @@
1
+ import { ElementHandle, Page } from 'puppeteer';
2
+ export declare abstract class Base {
3
+ protected static readonly DEFAULT_LOCATE_TIMEOUT = 20000;
4
+ protected static readonly DEFAULT_PAGE_LOAD_TIMEOUT = 60000;
5
+ protected readonly page: Page;
6
+ constructor(page: Page);
7
+ /**
8
+ * Navigate to the given url
9
+ * @param baseUrl
10
+ * @param path
11
+ */
12
+ protected goto({ baseUrl, path }: {
13
+ baseUrl: string;
14
+ path?: string;
15
+ }): Promise<void>;
16
+ /**
17
+ * Get text from an element
18
+ * @param element
19
+ * @param elementName
20
+ */
21
+ protected getText(element: ElementHandle<Element>, elementName: string): Promise<string>;
22
+ /**
23
+ * Check that element exists and is visible
24
+ * @param selector element which should be visible
25
+ * @param elementName name of the searchable element
26
+ * @param timeout time to wait for until element is visible in the UI
27
+ */
28
+ protected elementVisible(seletor: string, elementName: string, timeout?: number): Promise<ElementHandle<Element>>;
29
+ }
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Base = void 0;
40
+ var Base = /** @class */ (function () {
41
+ function Base(page) {
42
+ this.page = page;
43
+ }
44
+ /**
45
+ * Navigate to the given url
46
+ * @param baseUrl
47
+ * @param path
48
+ */
49
+ Base.prototype.goto = function (_a) {
50
+ var baseUrl = _a.baseUrl, path = _a.path;
51
+ return __awaiter(this, void 0, void 0, function () {
52
+ var fullPath;
53
+ return __generator(this, function (_b) {
54
+ switch (_b.label) {
55
+ case 0:
56
+ fullPath = path ? baseUrl + "/" + path : baseUrl;
57
+ return [4 /*yield*/, this.page.goto(fullPath, { waitUntil: 'load', timeout: 60000 })];
58
+ case 1:
59
+ _b.sent();
60
+ return [2 /*return*/];
61
+ }
62
+ });
63
+ });
64
+ };
65
+ /**
66
+ * Get text from an element
67
+ * @param element
68
+ * @param elementName
69
+ */
70
+ Base.prototype.getText = function (element, elementName) {
71
+ return __awaiter(this, void 0, void 0, function () {
72
+ var text;
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0: return [4 /*yield*/, element.evaluate(function (el) { return el.textContent; })];
76
+ case 1:
77
+ text = _a.sent();
78
+ if (!text) {
79
+ throw new Error(elementName + " does not contain any text");
80
+ }
81
+ return [2 /*return*/, text];
82
+ }
83
+ });
84
+ });
85
+ };
86
+ /**
87
+ * Check that element exists and is visible
88
+ * @param selector element which should be visible
89
+ * @param elementName name of the searchable element
90
+ * @param timeout time to wait for until element is visible in the UI
91
+ */
92
+ Base.prototype.elementVisible = function (seletor, elementName, timeout) {
93
+ if (timeout === void 0) { timeout = Base.DEFAULT_LOCATE_TIMEOUT; }
94
+ return __awaiter(this, void 0, void 0, function () {
95
+ var waitOptions, element, _a;
96
+ return __generator(this, function (_b) {
97
+ switch (_b.label) {
98
+ case 0:
99
+ waitOptions = { timeout: timeout };
100
+ if (!seletor.startsWith('//')) return [3 /*break*/, 2];
101
+ return [4 /*yield*/, this.page.waitForXPath(seletor, waitOptions)];
102
+ case 1:
103
+ _a = _b.sent();
104
+ return [3 /*break*/, 4];
105
+ case 2: return [4 /*yield*/, this.page.waitForSelector(seletor, waitOptions)];
106
+ case 3:
107
+ _a = _b.sent();
108
+ _b.label = 4;
109
+ case 4:
110
+ element = _a;
111
+ if (!element) {
112
+ throw new Error("Element: " + elementName + " is not visible in the UI");
113
+ }
114
+ return [2 /*return*/, element];
115
+ }
116
+ });
117
+ });
118
+ };
119
+ Base.DEFAULT_LOCATE_TIMEOUT = 20000;
120
+ Base.DEFAULT_PAGE_LOAD_TIMEOUT = 60000;
121
+ return Base;
122
+ }());
123
+ exports.Base = Base;
124
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/utils/pages/view/base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;IAOE,cAAY,IAAU;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACa,mBAAI,GAApB,UAAqB,EAAqD;YAAnD,OAAO,aAAA,EAAE,IAAI,UAAA;;;;;;wBAC5B,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAI,OAAO,SAAI,IAAM,CAAC,CAAC,CAAC,OAAO,CAAC;wBACvD,qBAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAA;;wBAArE,SAAqE,CAAC;;;;;KACvE;IAED;;;;OAIG;IACa,sBAAO,GAAvB,UAAwB,OAA+B,EAAE,WAAmB;;;;;4BAC7D,qBAAM,OAAO,CAAC,QAAQ,CAAC,UAAC,EAAE,IAAK,OAAA,EAAE,CAAC,WAAW,EAAd,CAAc,CAAC,EAAA;;wBAArD,IAAI,GAAG,SAA8C;wBAE3D,IAAI,CAAC,IAAI,EAAE;4BACT,MAAM,IAAI,KAAK,CAAI,WAAW,+BAA4B,CAAC,CAAC;yBAC7D;wBAED,sBAAO,IAAI,EAAC;;;;KACb;IAED;;;;;OAKG;IACa,6BAAc,GAA9B,UACE,OAAe,EACf,WAAmB,EACnB,OAAqC;QAArC,wBAAA,EAAA,UAAU,IAAI,CAAC,sBAAsB;;;;;;wBAE/B,WAAW,GAAG,EAAE,OAAO,SAAA,EAAE,CAAC;6BAGhB,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAxB,wBAAwB;wBACpC,qBAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,WAAW,CAAC,EAAA;;wBAAlD,KAAA,SAAkD,CAAA;;4BAClD,qBAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,EAAA;;wBAArD,KAAA,SAAqD,CAAA;;;wBAFnD,OAAO,KAE4C;wBAEzD,IAAI,CAAC,OAAO,EAAE;4BACZ,MAAM,IAAI,KAAK,CAAC,cAAY,WAAW,8BAA2B,CAAC,CAAC;yBACrE;wBACD,sBAAO,OAAO,EAAC;;;;KAChB;IAzDyB,2BAAsB,GAAG,KAAK,CAAC;IAE/B,8BAAyB,GAAG,KAAK,CAAC;IAwD9D,WAAC;CAAA,AA3DD,IA2DC;AA3DqB,oBAAI"}
@@ -0,0 +1,31 @@
1
+ import { ElementHandle, Page } from 'puppeteer';
2
+ import { Base } from './base';
3
+ interface PluginResponse {
4
+ name: string;
5
+ version: string;
6
+ phase: number;
7
+ src: string;
8
+ }
9
+ export declare class Plugins extends Base {
10
+ private static readonly _pluginList;
11
+ assert: {
12
+ plugin: {
13
+ /**
14
+ * Checks whether plugin with the given text is visible in the UI
15
+ * @param pluginText
16
+ */
17
+ isVisible: (pluginText: string) => Promise<ElementHandle<Element>>;
18
+ };
19
+ };
20
+ private readonly _baseUrl;
21
+ constructor(page: Page, baseUrl: string);
22
+ /**
23
+ * Retrieves all plugins from /plugins
24
+ */
25
+ list(): Promise<PluginResponse[]>;
26
+ /**
27
+ * Creates selector for plugin based on its text
28
+ */
29
+ private _plugin;
30
+ }
31
+ export {};
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.Plugins = void 0;
55
+ var flex_dev_utils_1 = require("@twilio/flex-dev-utils");
56
+ var base_1 = require("./base");
57
+ var Plugins = /** @class */ (function (_super) {
58
+ __extends(Plugins, _super);
59
+ function Plugins(page, baseUrl) {
60
+ var _this = _super.call(this, page) || this;
61
+ _this.assert = {
62
+ plugin: {
63
+ /**
64
+ * Checks whether plugin with the given text is visible in the UI
65
+ * @param pluginText
66
+ */
67
+ isVisible: function (pluginText) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
68
+ return [2 /*return*/, this.elementVisible(this._plugin(pluginText), "Plugin with text: " + pluginText)];
69
+ }); }); },
70
+ },
71
+ };
72
+ /**
73
+ * Creates selector for plugin based on its text
74
+ */
75
+ _this._plugin = function (text) { return "//div[contains(text(), '" + text + "')]"; };
76
+ _this._baseUrl = baseUrl.includes('localhost') ? 'https://flex.twilio.com' : baseUrl;
77
+ return _this;
78
+ }
79
+ /**
80
+ * Retrieves all plugins from /plugins
81
+ */
82
+ Plugins.prototype.list = function () {
83
+ return __awaiter(this, void 0, void 0, function () {
84
+ var pluginListElementHandle, pluginListAsString;
85
+ return __generator(this, function (_a) {
86
+ switch (_a.label) {
87
+ case 0: return [4 /*yield*/, this.goto({ baseUrl: this._baseUrl, path: '/plugins' })];
88
+ case 1:
89
+ _a.sent();
90
+ return [4 /*yield*/, this.elementVisible(Plugins._pluginList, 'Plugins in PRE tag')];
91
+ case 2:
92
+ pluginListElementHandle = _a.sent();
93
+ return [4 /*yield*/, this.getText(pluginListElementHandle, 'Plugins in PRE tag')];
94
+ case 3:
95
+ pluginListAsString = _a.sent();
96
+ try {
97
+ return [2 /*return*/, JSON.parse(pluginListAsString)];
98
+ }
99
+ catch (e) {
100
+ flex_dev_utils_1.logger.error('Plugin list retrieved from the /plugins is not a valid JSON');
101
+ throw e;
102
+ }
103
+ return [2 /*return*/];
104
+ }
105
+ });
106
+ });
107
+ };
108
+ Plugins._pluginList = 'pre';
109
+ return Plugins;
110
+ }(base_1.Base));
111
+ exports.Plugins = Plugins;
112
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../../../src/utils/pages/view/plugins.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAgD;AAGhD,+BAA8B;AAS9B;IAA6B,2BAAI;IAgB/B,iBAAY,IAAU,EAAE,OAAe;QAAvC,YACE,kBAAM,IAAI,CAAC,SAEZ;QAhBD,YAAM,GAAG;YACP,MAAM,EAAE;gBACN;;;mBAGG;gBACH,SAAS,EAAE,UAAO,UAAkB;oBAClC,sBAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,uBAAqB,UAAY,CAAC,EAAA;yBAAA;aACnF;SACF,CAAC;QA0BF;;WAEG;QACK,aAAO,GAAG,UAAC,IAAY,IAAa,OAAA,6BAA2B,IAAI,QAAK,EAApC,CAAoC,CAAC;QAvB/E,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,OAAO,CAAC;;IACtF,CAAC;IAED;;OAEG;IACG,sBAAI,GAAV;;;;;4BACE,qBAAM,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAA;;wBAA7D,SAA6D,CAAC;wBAE9B,qBAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,EAAE,oBAAoB,CAAC,EAAA;;wBAA9F,uBAAuB,GAAG,SAAoE;wBACzE,qBAAM,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,oBAAoB,CAAC,EAAA;;wBAAtF,kBAAkB,GAAG,SAAiE;wBAE5F,IAAI;4BACF,sBAAO,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAC;yBACvC;wBAAC,OAAO,CAAC,EAAE;4BACV,uBAAM,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;4BAC5E,MAAM,CAAC,CAAC;yBACT;;;;;KACF;IAnCuB,mBAAW,GAAG,KAAK,CAAC;IAyC9C,cAAC;CAAA,AA1CD,CAA6B,WAAI,GA0ChC;AA1CY,0BAAO"}
@@ -0,0 +1,26 @@
1
+ import { Page } from 'puppeteer';
2
+ import { Base } from './base';
3
+ import { Cookies } from '../../console-api';
4
+ export declare class TwilioConsole extends Base {
5
+ private static _loginForm;
6
+ assert: {};
7
+ private readonly _baseUrl;
8
+ private readonly _flexBaseUrl;
9
+ constructor(page: Page, { flex, twilioConsole }: {
10
+ flex: string;
11
+ twilioConsole: string;
12
+ });
13
+ /**
14
+ * Creates a localhost url
15
+ * @param port
16
+ */
17
+ private static _createLocalhostUrl;
18
+ /**
19
+ * Logs user in through service-login
20
+ * @param cookies
21
+ * @param flexBaseUrl
22
+ * @param flexPath
23
+ * @param accountSid
24
+ */
25
+ login(cookies: Cookies, flexPath: string, accountSid: string, localhostPort: number): Promise<void>;
26
+ }