@cloudscape-design/browser-test-tools 3.0.18 → 3.0.20

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.
@@ -0,0 +1,3 @@
1
+ export declare function initLiveAnnouncementsObserver(): void;
2
+ export declare function getLiveAnnouncements(): string[];
3
+ export declare function clearLiveAnnouncements(): void;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.clearLiveAnnouncements = exports.getLiveAnnouncements = exports.initLiveAnnouncementsObserver = void 0;
6
+ function initLiveAnnouncementsObserver() {
7
+ const observer = new MutationObserver(mutationList => {
8
+ for (const mutation of mutationList) {
9
+ if (mutation.type === 'childList' &&
10
+ mutation.target instanceof HTMLElement &&
11
+ mutation.target.hasAttribute('aria-live') &&
12
+ mutation.target.textContent) {
13
+ if (!window.__liveAnnouncements) {
14
+ window.__liveAnnouncements = [];
15
+ }
16
+ window.__liveAnnouncements.push(mutation.target.textContent);
17
+ }
18
+ }
19
+ });
20
+ observer.observe(document.body, { attributes: false, childList: true, subtree: true });
21
+ }
22
+ exports.initLiveAnnouncementsObserver = initLiveAnnouncementsObserver;
23
+ function getLiveAnnouncements() {
24
+ var _a;
25
+ return (_a = window.__liveAnnouncements) !== null && _a !== void 0 ? _a : [];
26
+ }
27
+ exports.getLiveAnnouncements = getLiveAnnouncements;
28
+ function clearLiveAnnouncements() {
29
+ window.__liveAnnouncements = [];
30
+ }
31
+ exports.clearLiveAnnouncements = clearLiveAnnouncements;
@@ -73,4 +73,10 @@ export default class BasePageObject {
73
73
  getBoundingBox(selector: string): Promise<ElementRect>;
74
74
  getText(selector: string): Promise<string>;
75
75
  getElementsText(selector: string): Promise<string[]>;
76
+ /**
77
+ * Attaches observer to collect all live updates from the page that can be fetched with page.getLiveAnnouncements().
78
+ */
79
+ initLiveAnnouncementsObserver(): Promise<void>;
80
+ getLiveAnnouncements(): Promise<string[]>;
81
+ clearLiveAnnouncements(): Promise<void>;
76
82
  }
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
@@ -8,6 +31,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
31
  const p_retry_1 = __importDefault(require("p-retry"));
9
32
  const browser_scripts_1 = require("../browser-scripts");
10
33
  const events_spy_1 = __importDefault(require("./events-spy"));
34
+ const liveAnnouncements = __importStar(require("../browser-scripts/live-announcements"));
11
35
  const utils_1 = require("./utils");
12
36
  const browser_scripts_2 = require("./browser-scripts");
13
37
  class BasePageObject {
@@ -183,5 +207,17 @@ class BasePageObject {
183
207
  const elements = await this.browser.$$(selector);
184
208
  return Promise.all(elements.map(async (element) => element.getText()));
185
209
  }
210
+ /**
211
+ * Attaches observer to collect all live updates from the page that can be fetched with page.getLiveAnnouncements().
212
+ */
213
+ async initLiveAnnouncementsObserver() {
214
+ await this.browser.execute(liveAnnouncements.initLiveAnnouncementsObserver);
215
+ }
216
+ async getLiveAnnouncements() {
217
+ return await this.browser.execute(liveAnnouncements.getLiveAnnouncements);
218
+ }
219
+ async clearLiveAnnouncements() {
220
+ await this.browser.execute(liveAnnouncements.clearLiveAnnouncements);
221
+ }
186
222
  }
187
223
  exports.default = BasePageObject;
@@ -8,7 +8,7 @@ const browser_scripts_1 = require("../browser-scripts");
8
8
  const merge_1 = __importDefault(require("../image-utils/merge"));
9
9
  const browser_scripts_2 = require("./browser-scripts");
10
10
  const utils_1 = require("./utils");
11
- const MAX_SCREENSHOT_HEIGHT = 20000;
11
+ const MAX_SCREENSHOT_HEIGHT = 16000;
12
12
  async function scroll(browser, topOffset) {
13
13
  await browser.execute(browser_scripts_1.windowScrollTo, topOffset, 0);
14
14
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "643493422415b99ef9644a7b9a97e1b9867687e2"
2
+ "commit": "a4853c33f6681df9e06565e85941d13811b1e2ef"
3
3
  }
package/package.json CHANGED
@@ -60,6 +60,6 @@
60
60
  "type": "git",
61
61
  "url": "git+https://github.com/cloudscape-design/browser-test-tools.git"
62
62
  },
63
- "version": "3.0.18",
63
+ "version": "3.0.20",
64
64
  "license": "Apache-2.0"
65
65
  }