123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Dashboard
- *| (C) Copyright IBM Corp. 2018, 2020
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define(['underscore', '../../../lib/@waca/dashboard-common/dist/core/APIFactory', './api/ViprUITestApi', './BinarySearchTupleLocator', './SelectorTupleLocator'], function (_, APIFactory, ViprUITestAPI, BinarySearchTupleLocator, SelectorTupleLocator) {
- /**
- * The ViprUITest is a support class for the functional Test UI.
- * Its purpose is to allow the test framework to check and interact with a visualization from an external point of view.
- * In the case of VIPR, we assume that VIPR "does the right thing" and checking its structures via getItemsAtPoint/getItemsInPolygon is sufficient.
- * The hope is to have VIPR implement an interface and this class will simply adapt to the UITestAPI interface and not use private information.
- */
- var ViprUITest = function () {
- function ViprUITest(options) {
- _classCallCheck(this, ViprUITest);
- this.content = options.content;
- }
- ViprUITest.prototype.getAPI = function getAPI() {
- if (!this._api) {
- this._api = APIFactory.createAPI(this, [ViprUITestAPI]);
- }
- return this._api;
- };
- ViprUITest.prototype._initLocators = function _initLocators() {
- if (!this.locators) {
- var viprView = this.content.getFeature('livewidget.internal').getVisView();
- var viprWidget = viprView.viprWidget;
- var viprViewElement = viprView.$el;
- this.locators = {
- data: new BinarySearchTupleLocator({ viprWidget: viprWidget }), //Most test logic will want this one
- axis: new SelectorTupleLocator({ '$el': viprViewElement, viprWidget: viprWidget, selector: '.axis-label' }), //Most cases won't need selectors like these
- legend: new SelectorTupleLocator({ '$el': viprViewElement, viprWidget: viprWidget, selector: '.Legend li' }) //however these features only work with selectors (at the moment)
- };
- }
- };
- /**
- * given a searchTuple of captions, return points in the visualization that match.
- * @param searchTuple - an array of captions to match eg: ['2004', 'Friday'] for dataPoint which is the intersection of Year and Release Day.
- * @param [options]
- * @param [options.axis] - return axis matches (eg: for bar charts)
- * @param [options.legend] - return legend matches
- * @param [options.data] - return data point matches
- * @returns an object with the match (or null).
- */
- ViprUITest.prototype.findPoint = function findPoint(searchTuple, options) {
- this._initLocators();
- if (!options) {
- options = {
- axis: true,
- legend: true,
- data: true
- };
- }
- var locatorKeys = Object.keys(this.locators);
- for (var i = 0; i < locatorKeys.length; i++) {
- var locatorKey = locatorKeys[i];
- if (options[locatorKey]) {
- var locator = this.locators[locatorKey];
- var results = locator.findTupleVisualInfo({ tuple: searchTuple }, { includePoints: true });
- if (results.length) {
- return results[0].point;
- }
- }
- }
- };
- /**
- * Take a 'snapshot' of the visualization which includes the tuples which are part of the visualization
- * and their selection state.
- * @param filter - (optional) - if specified, only the itemInfo which matches the filter are returned. eg: { isSelected: true }
- */
- ViprUITest.prototype.takeSnapshot = function takeSnapshot(filter) {
- var _this = this;
- this._initLocators();
- var results = {};
- Object.keys(this.locators).forEach(function (locatorKey) {
- return results[locatorKey + 'Points'] = _this.locators[locatorKey].findTupleVisualInfo(filter, { includeInfo: true }).map(function (_ref) {
- var info = _ref.info;
- return info;
- });
- });
- return results;
- };
- return ViprUITest;
- }();
- return ViprUITest;
- });
- //# sourceMappingURL=ViprUITest.js.map
|