New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rx-page-objects

Package Overview
Dependencies
Maintainers
1
Versions
182
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rx-page-objects - npm Package Compare versions

Comparing version 1.36.0 to 1.37.0

rx-page-objects-1.37.0.tgz

763

exercise.js

@@ -367,186 +367,2 @@ /*jshint node:true*/

var rxMetadata = require('./index').rxMetadata;
/**
* rxMetadata exercises
* @exports encore.exercise.rxMetadata
* @param {Object} [options=] Test options. Used to build valid tests.
* @param {string} [options.cssSelector=] Fallback selector string to initialize widget with.
* @param {Boolean} [options.present=true] Determines if the metadata is present in the DOM
* @param {Boolean} [options.visible=true] Determines if the metadata is visible
* @param {Object} [transformFns=] - Transformation functions to be passed to rxMetadata
* @param {Object} [options.terms=] The expected label text of each metadata entry
* @example
* ```js
* describe('metadata', encore.exercise.rxMetadata({
* transformFns: {
* 'Signup Date': function (elem) {
* return elem.getText().then(function (text) {
* return new Date(text);
* });
* },
* 'Overdue Balance': function (elem) {
* return elem.getText().then(encore.rxMisc.currencyToPennies);
* },
* 'Current Due': function (elem) {
* return elem.getText().then(encore.rxMisc.currencyToPennies);
* },
* 'Expiration Date' function (elem) {
* return elem.getText().then(function (text) {
* return new Date(text);
* });
* }
* },
* terms: {
* 'Signup Date': new Date('March 1st, 2011'),
* 'Overdue Balance': 13256,
* 'Current Due': 64400,
* 'Expiration Date': new Date('January 1st, 2021')
* }
* }));
* ```
*/
exports.rxMetadata = function (options) {
if (options === undefined) {
options = {};
}
options = _.defaults(options, {
present: true,
visible: true,
});
return function () {
var component;
before(function () {
if (options.cssSelector === undefined) {
// don't use main -- you need to be able to supply `transformFns` via `initialize`
component = rxMetadata.initialize($('rx-metadata'), options.transformFns);
} else {
component = rxMetadata.initialize($(options.cssSelector), options.transformFns);
}
});
it('should ' + (options.present ? 'be' : 'not be') + ' present', function () {
expect(component.isPresent()).to.eventually.eq(options.present);
});
it('should ' + (options.visible ? 'be' : 'not be') + ' visible', function () {
expect(component.isDisplayed()).to.eventually.eq(options.visible);
});
it('should have every term present and in the correct order', function () {
expect(component.terms).to.eventually.eql(Object.keys(options.terms));
});
_.forEach(options.terms, function (definition, term) {
it('should have the correct definition for ' + term, function () {
if (_.isObject(definition) || _.isArray(definition)) {
expect(component.term(term)).to.eventually.eql(definition);
} else {
expect(component.term(term)).to.eventually.equal(definition);
}
});
});
};
};
var rxMultiSelect = require('./index').rxMultiSelect;
/**
rxMultiSelect exercises.
@exports encore.exercise.rxMultiSelect
@param {Object} [options=] - Test options. Used to build valid tests.
@param {rxMultiSelect} [options.instance=rxMultiSelect.main] - Component to exercise.
@example
```js
describe('default exercises', encore.exercise.rxMultiSelect({
cssSelector: '.secondary-info rx-paginate', // select one of many widgets on page
}));
```
*/
exports.rxMultiSelect = function (options) {
if (options === undefined) {
options = {};
}
options = _.defaults(options, {
instance: rxMultiSelect.main
});
return function () {
var component;
before(function () {
component = options.instance;
});
it('should start exercising defaults now');
};
};
var rxOptionTable = require('./index').rxOptionTable;
/**
* rxOptionTable exercises.
* @exports encore.exercise.rxOptionTable
* @param {Object} [options=] - Test options. Used to build valid tests.
* @param {rxOptionTable} [options.instance=] - Component to exercise.
* @param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with.
* @param {string} [options.visible=true] - Determines if the option table is visible
* @param {string} [options.empty=false] - Determines if the option table is empty
*/
exports.rxOptionTable = function (options) {
if (options === undefined) {
options = {};
}
options = _.defaults(options, {
visible: true,
empty: false
});
return function () {
var component;
before(function () {
if (options.instance !== undefined) {
component = options.instance;
} else {
component = rxOptionTable.main;
}
if (options.cssSelector !== undefined) {
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`');
component = rxOptionTable.initialize($(options.cssSelector));
}
});
it('should ' + (options.visible ? 'be' : 'not be') + ' visible', function () {
expect(component.isDisplayed()).to.eventually.eq(options.visible);
});
if (options.empty) {
it('should be empty', function () {
expect(component.isEmpty()).to.eventually.be.true;
});
it('should have a "table empty" error message', function () {
expect(component.emptyMessage).to.eventually.not.be.null;
});
} else {
it('should not be empty', function () {
expect(component.isEmpty()).to.eventually.be.false;
});
it('should not have a "table empty" error message', function () {
expect(component.emptyMessage).to.eventually.be.null;
});
}
};
};
var rxRadio = require('./index').rxRadio;

@@ -770,199 +586,2 @@

var rxMultiSelect = require('./index').rxMultiSelect;
/**
rxMultiSelect exercises.
@exports encore.exercise.rxMultiSelect
@param {Object} [options=] - Test options. Used to build valid tests.
@param {rxMultiSelect} [options.instance=] - Component to exercise.
@param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with.
@param {Object} [options.inputs=[]] - The options of the select input.
@example
```js
describe('default exercises', encore.exercise.rxMultiSelect({
instance: myPage.subscriptionList, // select one of many widgets from your page objects
}));
```
*/
exports.rxMultiSelect = function (options) {
if (options === undefined) {
options = {};
}
options = _.defaults(options, {
inputs: []
});
return function () {
var component;
before(function () {
if (options.instance !== undefined) {
component = options.instance;
} else {
component = rxMultiSelect.main;
}
if (options.cssSelector !== undefined) {
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`');
component = rxMultiSelect.initialize($(options.cssSelector));
}
});
it('hides the menu initially', function () {
expect(component.isOpen()).to.eventually.be.false;
});
it('shows the menu when clicked', function () {
component.openMenu();
expect(component.isOpen()).to.eventually.be.true;
});
it('selects no options', function () {
component.deselect(['Select All']);
expect(component.selectedOptions).to.eventually.be.empty;
expect(component.preview).to.eventually.equal('None');
});
it('selects a single option', function () {
var input = _.first(options.inputs);
component.select([input]);
expect(component.selectedOptions).to.eventually.eql([input]);
expect(component.preview).to.eventually.equal(input);
});
if (options.inputs.length > 2) {
it('selects multiple options', function () {
var inputs = options.inputs.slice(0, 2);
component.select(inputs);
expect(component.selectedOptions).to.eventually.eql(inputs);
expect(component.preview).to.eventually.equal('2 Selected');
});
}
it('selects all options', function () {
component.select(['Select All']);
expect(component.selectedOptions).to.eventually.eql(['Select All'].concat(options.inputs));
expect(component.preview).to.eventually.equal('All Selected');
});
it('deselects all options', function () {
component.deselect(['Select All']);
expect(component.selectedOptions).to.eventually.be.empty;
expect(component.preview).to.eventually.equal('None');
});
it('hides the menu when another element is clicked', function () {
component.rootElement.element(by.xpath('../..')).click();
expect(component.isOpen()).to.eventually.be.false;
});
};
};
var rxTags = require('./index').rxTags;
/**
* rxTags exercises
* @exports encore.exercise.rxTags
* @param {Object} [options=] - Test options. Used to build valid tests.
* @param {rxTags} [options.instance=] - Component to Exercise.
* @param {string} options.sampleText - A tag that can be added.
* @example
* <pre>
* describe('default exercises', encore.exercise.rxTags({
* instance: encore.rxTags.initialize('.demo rx-tags') // select one of many widgets on page
* }));
* </pre>
*/
exports.rxTags = function (options) {
if (options === undefined) {
options = {};
}
options = _.defaults(options, {
sampleText: undefined
});
return function () {
var component, tag, numTags;
before(function () {
if (options.instance !== undefined) {
component = options.instance;
} else {
component = rxTags.main;
}
component.count().then(function (num) {
numTags = num;
});
});
if (!_.isUndefined(options.sampleText)) {
describe('after adding tag', function () {
before(function () {
tag = component.addTag(options.sampleText);
});
it('should have expected value', function () {
expect(tag.text).to.eventually.equal(options.sampleText);
});
it('should increment total tags by 1', function () {
expect(component.count()).to.eventually.equal(numTags + 1);
});
it('should not focus last tag', function () {
expect(tag.isFocused()).to.eventually.be.false;
});
describe('and clicking the tag X', function () {
before(function () {
tag.remove();
});
it('should no longer exist', function () {
expect(tag.exists()).to.eventually.be.false;
});
it('should decrement total tags by 1', function () {
expect(component.count()).to.eventually.equal(numTags);
});
});
});
describe('after adding temporary tag for removal', function () {
before(function () {
tag = component.addTag(options.sampleText);
});
describe('and typing backspace from input', function () {
before(function () {
component.sendBackspace();
});
it('should focus the last tag', function () {
expect(tag.isFocused()).to.eventually.be.true;
});
describe('and typing backspace with focused tag', function () {
before(function () {
tag.sendBackspace();
});
it('should no longer exist', function () {
expect(component.byText(options.sampleText).exists()).to.eventually.be.false;
});
it('should decrement count by 1', function () {
expect(component.count()).to.eventually.equal(numTags);
});
});
});
});
}
};
};
var rxToggleSwitch = require('./index').rxToggleSwitch;

@@ -977,2 +596,6 @@

@param {boolean} [options.disabled=false] - Determines if the switch can be toggled
@param {boolean} [options.enabledAtStart=null] Beginning state of toggle switch. The value will be detected
automatically if not given.
@param {boolean} [options.enabledAtEnd=null] End state of toggle switch. The value will be detected automatically
if not given.
@example

@@ -991,3 +614,5 @@ ```js

options = _.defaults(options, {
disabled: false
disabled: false,
enabledAtStart: null, // begins 'OFF'
enabledAtEnd: null // ends 'ON'
});

@@ -997,3 +622,4 @@

var component;
var initialState;
var enabledAtStart;
var enabledAtEnd;

@@ -1023,3 +649,7 @@ var getText = function (isEnabled) {

component.isEnabled().then(function (isEnabled) {
initialState = isEnabled;
// use option if available, otherwise use detected state
enabledAtStart = _.isNull(options.enabledAtStart) ? isEnabled : options.enabledAtStart;
// use option if available, otherwise use inverse of enabledAtStart
enabledAtEnd = _.isNull(options.enabledAtEnd) ? !enabledAtStart : options.enabledAtEnd;
});

@@ -1035,20 +665,20 @@ });

toggle();
expect(component.isEnabled()).to.eventually.equal(initialState);
expect(component.text).to.eventually.equal(getText(initialState));
expect(component.isEnabled()).to.eventually.equal(enabledAtStart);
expect(component.text).to.eventually.equal(getText(enabledAtStart));
});
} else {
it('is in the ' + getText(initialState) + ' state', function () {
expect(component.text).to.eventually.equal(getText(initialState));
it('begins in the ' + getText(enabledAtStart) + ' state', function () {
expect(component.text).to.eventually.equal(getText(enabledAtStart));
});
it('changes to ' + getText(!initialState) + ' when clicked', function () {
it('changes to ' + getText(enabledAtEnd) + ' when clicked', function () {
toggle();
expect(component.isEnabled()).to.eventually.equal(!initialState);
expect(component.text).to.eventually.equal(getText(!initialState));
expect(component.isEnabled()).to.eventually.equal(enabledAtEnd);
expect(component.text).to.eventually.equal(getText(enabledAtEnd));
});
it('returns to the ' + getText(initialState) + ' when clicked again', function () {
it('returns to the ' + getText(enabledAtStart) + ' when clicked again', function () {
toggle();
expect(component.isEnabled()).to.eventually.equal(initialState);
expect(component.text).to.eventually.equal(getText(initialState));
expect(component.isEnabled()).to.eventually.equal(enabledAtStart);
expect(component.text).to.eventually.equal(getText(enabledAtStart));
});

@@ -1272,3 +902,243 @@ }

var rxMetadata = require('./index').rxMetadata;
/**
* rxMetadata exercises
* @exports encore.exercise.rxMetadata
* @param {Object} [options=] Test options. Used to build valid tests.
* @param {string} [options.cssSelector=] Fallback selector string to initialize widget with.
* @param {Boolean} [options.present=true] Determines if the metadata is present in the DOM
* @param {Boolean} [options.visible=true] Determines if the metadata is visible
* @param {Object} [transformFns=] - Transformation functions to be passed to rxMetadata
* @param {Object} [options.terms=] The expected label text of each metadata entry
* @example
* ```js
* describe('metadata', encore.exercise.rxMetadata({
* transformFns: {
* 'Signup Date': function (elem) {
* return elem.getText().then(function (text) {
* return new Date(text);
* });
* },
* 'Overdue Balance': function (elem) {
* return elem.getText().then(encore.rxMisc.currencyToPennies);
* },
* 'Current Due': function (elem) {
* return elem.getText().then(encore.rxMisc.currencyToPennies);
* },
* 'Expiration Date' function (elem) {
* return elem.getText().then(function (text) {
* return new Date(text);
* });
* }
* },
* terms: {
* 'Signup Date': new Date('March 1st, 2011'),
* 'Overdue Balance': 13256,
* 'Current Due': 64400,
* 'Expiration Date': new Date('January 1st, 2021')
* }
* }));
* ```
*/
exports.rxMetadata = function (options) {
if (options === undefined) {
options = {};
}
options = _.defaults(options, {
present: true,
visible: true,
});
return function () {
var component;
before(function () {
if (options.cssSelector === undefined) {
// don't use main -- you need to be able to supply `transformFns` via `initialize`
component = rxMetadata.initialize($('rx-metadata'), options.transformFns);
} else {
component = rxMetadata.initialize($(options.cssSelector), options.transformFns);
}
});
it('should ' + (options.present ? 'be' : 'not be') + ' present', function () {
expect(component.isPresent()).to.eventually.eq(options.present);
});
it('should ' + (options.visible ? 'be' : 'not be') + ' visible', function () {
expect(component.isDisplayed()).to.eventually.eq(options.visible);
});
it('should have every term present and in the correct order', function () {
expect(component.terms).to.eventually.eql(Object.keys(options.terms));
});
_.forEach(options.terms, function (definition, term) {
it('should have the correct definition for ' + term, function () {
if (_.isObject(definition) || _.isArray(definition)) {
expect(component.term(term)).to.eventually.eql(definition);
} else {
expect(component.term(term)).to.eventually.equal(definition);
}
});
});
};
};
var rxMultiSelect = require('./index').rxMultiSelect;
/**
rxMultiSelect exercises.
@exports encore.exercise.rxMultiSelect
@param {Object} [options=] - Test options. Used to build valid tests.
@param {rxMultiSelect} [options.instance=] - Component to exercise.
@param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with.
@param {Object} [options.inputs=[]] - The options of the select input.
@example
```js
describe('default exercises', encore.exercise.rxMultiSelect({
instance: myPage.subscriptionList, // select one of many widgets from your page objects
}));
```
*/
exports.rxMultiSelect = function (options) {
if (options === undefined) {
options = {};
}
options = _.defaults(options, {
inputs: []
});
return function () {
var component;
before(function () {
if (options.instance !== undefined) {
component = options.instance;
} else {
component = rxMultiSelect.main;
}
if (options.cssSelector !== undefined) {
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`');
component = rxMultiSelect.initialize($(options.cssSelector));
}
});
it('hides the menu initially', function () {
expect(component.isOpen()).to.eventually.be.false;
});
it('shows the menu when clicked', function () {
component.openMenu();
expect(component.isOpen()).to.eventually.be.true;
});
it('selects no options', function () {
component.deselect(['Select All']);
expect(component.selectedOptions).to.eventually.be.empty;
expect(component.preview).to.eventually.equal('None');
});
it('selects a single option', function () {
var input = _.first(options.inputs);
component.select([input]);
expect(component.selectedOptions).to.eventually.eql([input]);
expect(component.preview).to.eventually.equal(input);
});
if (options.inputs.length > 2) {
it('selects multiple options', function () {
var inputs = options.inputs.slice(0, 2);
component.select(inputs);
expect(component.selectedOptions).to.eventually.eql(inputs);
expect(component.preview).to.eventually.equal('2 Selected');
});
}
it('selects all options', function () {
component.select(['Select All']);
expect(component.selectedOptions).to.eventually.eql(['Select All'].concat(options.inputs));
expect(component.preview).to.eventually.equal('All Selected');
});
it('deselects all options', function () {
component.deselect(['Select All']);
expect(component.selectedOptions).to.eventually.be.empty;
expect(component.preview).to.eventually.equal('None');
});
it('hides the menu when another element is clicked', function () {
component.rootElement.element(by.xpath('../..')).click();
expect(component.isOpen()).to.eventually.be.false;
});
};
};
var rxOptionTable = require('./index').rxOptionTable;
/**
* rxOptionTable exercises.
* @exports encore.exercise.rxOptionTable
* @param {Object} [options=] - Test options. Used to build valid tests.
* @param {rxOptionTable} [options.instance=] - Component to exercise.
* @param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with.
* @param {string} [options.visible=true] - Determines if the option table is visible
* @param {string} [options.empty=false] - Determines if the option table is empty
*/
exports.rxOptionTable = function (options) {
if (options === undefined) {
options = {};
}
options = _.defaults(options, {
visible: true,
empty: false
});
return function () {
var component;
before(function () {
if (options.instance !== undefined) {
component = options.instance;
} else {
component = rxOptionTable.main;
}
if (options.cssSelector !== undefined) {
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`');
component = rxOptionTable.initialize($(options.cssSelector));
}
});
it('should ' + (options.visible ? 'be' : 'not be') + ' visible', function () {
expect(component.isDisplayed()).to.eventually.eq(options.visible);
});
if (options.empty) {
it('should be empty', function () {
expect(component.isEmpty()).to.eventually.be.true;
});
it('should have a "table empty" error message', function () {
expect(component.emptyMessage).to.eventually.not.be.null;
});
} else {
it('should not be empty', function () {
expect(component.isEmpty()).to.eventually.be.false;
});
it('should not have a "table empty" error message', function () {
expect(component.emptyMessage).to.eventually.be.null;
});
}
};
};
var rxPaginate = require('./index').rxPaginate;

@@ -1455,1 +1325,106 @@

};
var rxTags = require('./index').rxTags;
/**
* rxTags exercises
* @exports encore.exercise.rxTags
* @param {Object} [options=] - Test options. Used to build valid tests.
* @param {rxTags} [options.instance=] - Component to Exercise.
* @param {string} options.sampleText - A tag that can be added.
* @example
* <pre>
* describe('default exercises', encore.exercise.rxTags({
* instance: encore.rxTags.initialize('.demo rx-tags') // select one of many widgets on page
* }));
* </pre>
*/
exports.rxTags = function (options) {
if (options === undefined) {
options = {};
}
options = _.defaults(options, {
sampleText: undefined
});
return function () {
var component, tag, numTags;
before(function () {
if (options.instance !== undefined) {
component = options.instance;
} else {
component = rxTags.main;
}
component.count().then(function (num) {
numTags = num;
});
});
if (!_.isUndefined(options.sampleText)) {
describe('after adding tag', function () {
before(function () {
tag = component.addTag(options.sampleText);
});
it('should have expected value', function () {
expect(tag.text).to.eventually.equal(options.sampleText);
});
it('should increment total tags by 1', function () {
expect(component.count()).to.eventually.equal(numTags + 1);
});
it('should not focus last tag', function () {
expect(tag.isFocused()).to.eventually.be.false;
});
describe('and clicking the tag X', function () {
before(function () {
tag.remove();
});
it('should no longer exist', function () {
expect(tag.exists()).to.eventually.be.false;
});
it('should decrement total tags by 1', function () {
expect(component.count()).to.eventually.equal(numTags);
});
});
});
describe('after adding temporary tag for removal', function () {
before(function () {
tag = component.addTag(options.sampleText);
});
describe('and typing backspace from input', function () {
before(function () {
component.sendBackspace();
});
it('should focus the last tag', function () {
expect(tag.isFocused()).to.eventually.be.true;
});
describe('and typing backspace with focused tag', function () {
before(function () {
tag.sendBackspace();
});
it('should no longer exist', function () {
expect(component.byText(options.sampleText).exists()).to.eventually.be.false;
});
it('should decrement count by 1', function () {
expect(component.count()).to.eventually.equal(numTags);
});
});
});
});
}
};
};

@@ -5,3 +5,3 @@ {

"description": "Midway test page objects for all of the Encore UI components",
"version": "1.36.0",
"version": "1.37.0",
"main": "index.js",

@@ -8,0 +8,0 @@ "license": "Apache License, Version 2.0",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc