Socket
Socket
Sign inDemoInstall

ember-cli-page-object

Package Overview
Dependencies
Maintainers
4
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-page-object - npm Package Compare versions

Comparing version 1.13.0 to 1.14.0

.sass-cache/76371a535183a7fb8e803338d663f60713b19496/_bootstrap.scssc

8

addon/-private/context.js

@@ -0,1 +1,3 @@

import { deprecate } from '@ember/application/deprecations';
/**

@@ -20,2 +22,8 @@ * @public

export function render(template) {
deprecate('PageObject.render() is deprecated. Please use "htmlbars-inline-precompile" instead.', false, {
id: 'ember-cli-page-object.page-render',
until: '2.0.0',
url: 'https://gist.github.com/san650/17174e4b7b1fd80b049a47eb456a7cdc#file-page-render-js',
});
if (!this.context) {

@@ -22,0 +30,0 @@ let message = 'You must set a context on the page object before calling calling `render()`';

2

addon/-private/dsl.js

@@ -13,3 +13,3 @@ import { as } from './properties/as';

import { value } from './properties/value';
import wait from 'ember-test-helpers/wait';
import { wait } from './compatibility';

@@ -16,0 +16,0 @@ const thenDescriptor = {

import ExecutionContext from './native-events-context';
import wait from 'ember-test-helpers/wait';
import { wait } from '../compatibility';

@@ -4,0 +4,0 @@ import {

import Ember from 'ember';
import Ceibo from 'ceibo';
import { deprecate } from '@ember/application/deprecations';

@@ -36,2 +37,10 @@ const { assert, get, isPresent } = Ember;

deprecate(
'Usage of comma separated selectors is deprecated in ember-cli-page-object', selector.indexOf(',') === -1, {
"id": "ember-cli-page-object.comma-separated-selectors",
"until": "2.0.0",
"url": "https://gist.github.com/san650/17174e4b7b1fd80b049a47eb456a7cdc#file-comma-separated-selectors-js",
}
);
return selector;

@@ -38,0 +47,0 @@ }

@@ -1,112 +0,26 @@

/* global Symbol */
import Ember from 'ember';
import { buildSelector, assign as mergeFunction } from '../helpers';
import { create } from '../create';
import { count } from './count';
import Ceibo from 'ceibo';
import { deprecate } from '@ember/application/deprecations';
import { warn } from '@ember/debug';
const arrayDelegateMethods = ['map', 'filter', 'mapBy', 'filterBy', 'forEach'];
import { collection as mainCollection } from './collection/main';
import { collection as legacyCollection } from './collection/legacy';
function merge(target, ...objects) {
objects.forEach((o) => mergeFunction(target, o));
return target;
}
function generateEnumerable(node, definition, item, key) {
let enumerable = merge({}, definition);
if (typeof (enumerable.count) === 'undefined') {
enumerable.count = count(item.itemScope);
}
if (typeof (enumerable.toArray) === 'undefined') {
enumerable.toArray = toArrayMethod(node, item, key);
arrayDelegateMethods.forEach((method) => delegateToArray(enumerable, method));
}
let collection = create(enumerable, { parent: node });
if (typeof (Symbol) !== 'undefined' && Symbol.iterator) {
collection[Symbol.iterator] = iteratorMethod;
}
// Change the key of the root node
Ceibo.meta(collection).key = `${key}()`;
return collection;
}
function generateItem(node, index, definition, key) {
let filters = merge({}, { scope: definition.scope, at: index });
let scope = buildSelector({}, definition.itemScope, filters);
let tree = create(
merge(
{
testContainer: definition.testContainer
},
definition.item,
{
scope,
resetScope: definition.resetScope
}
), { parent: node });
// Change the key of the root node
Ceibo.meta(tree).key = `${key}(${index})`;
return tree;
}
function toArrayMethod(node, definition, key) {
return function() {
let array = Ember.A();
let index;
let count;
for (index = 0, count = this.count; index < count; index++) {
array.push(generateItem(node, index, definition, key));
}
return array;
};
}
function delegateToArray(enumerable, method) {
if (typeof (enumerable[method]) === 'undefined') {
enumerable[method] = function(...args) {
return this.toArray()[method](...args);
};
}
}
function iteratorMethod() {
let i = 0;
let items = this.toArray();
let next = () => ({ done: i >= items.length, value: items[i++] });
return { next };
}
/**
* @public
*
* Creates a component that represents a collection of items. The collection is zero-indexed.
* Creates a enumerable that represents a collection of items. The collection is zero-indexed
* and has the following public methods and properties:
*
* When called with an index, the method returns the matching item.
* IMPORTANT: You can use Array accessors only on browsers that support Proxy.
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#Browser_compatibility
*
* When called without an index, the the object returned behaves as a regular PageObject with a few additional properties and methods:
*
* - `count` - the number of items in the collection
* - `length` - The number of items in the collection.
* - `objectAt()` - Returns the page for the item at the specified index.
* - `filter()` - Filters the items in the array and returns the ones which match the predicate function.
* - `filterBy()` - Filters the items of the array by the specified property, returning all that are truthy or that match an optional value.
* - `forEach()` - Runs a function for each item in the collection
* - `map()` - maps over the elements of the collection
* - `mapBy()` - maps over the elements of the collecton by the specified property
* - `toArray()` - returns an array containing all the items in the collection
* - `[Symbol.iterator]()` - if supported by the environment, this allows the collection to be iterated with `for/of` and spread with `...` like a normal array
*
* Collection objects also delegate the following methods to `toArray()` for ease of consumption:
* - `map`
* - `mapBy`
* - `filter`
* - `filterBy`
* - `forEach`
*
* @example

@@ -129,18 +43,11 @@ *

* const page = PageObject.create({
* users: collection({
* itemScope: 'table tr',
*
* item: {
* firstName: text('td', { at: 0 }),
* lastName: text('td', { at: 1 })
* },
*
* caption: text('caption')
* users: collection('table tr', {
* firstName: text('td', { at: 0 }),
* lastName: text('td', { at: 1 })
* })
* });
*
* assert.equal(page.users().count, 2);
* assert.equal(page.users().caption, 'List of users');
* assert.equal(page.users(1).firstName, 'John');
* assert.equal(page.users(1).lastName, 'Doe');
* assert.equal(page.users.length, 2);
* assert.equal(page.users.objectAt(1).firstName, 'John');
* assert.equal(page.users.objectAt(1).lastName, 'Doe');
*

@@ -170,15 +77,11 @@ * @example

* const page = PageObject.create({
* users: collection({
* scope: '.admins',
* scope: '.admins',
*
* itemScope: 'table tr',
*
* item: {
* firstName: text('td', { at: 0 }),
* lastName: text('td', { at: 1 })
* }
* users: collection('table tr', {
* firstName: text('td', { at: 0 }),
* lastName: text('td', { at: 1 })
* })
* });
*
* assert.equal(page.users().count, 2);
* assert.equal(page.users.length, 2);
*

@@ -191,4 +94,9 @@ * @example

* // <tr>
* // <td>Doe</td>
* // </tr>
* // <td>Mary<td>
* // <td>Watson</td>
* // </tr>
* // <tr>
* // <td>John<td>
* // <td>Doe</td>
* // </tr>
* // </tbody>

@@ -198,50 +106,58 @@ * // </table>

* const page = PageObject.create({
* users: PageObject.collection({
* scope: 'table',
* itemScope: 'tr',
* scope: 'table',
*
* item: {
* firstName: text('td', { at: 0 })
* },
*
* caption: PageObject.text('caption')
* users: PageObject.collection('tr', {
* firstName: text('td', { at: 0 }),
* lastName: text('td', { at: 1 }),
* })
* });
*
* assert.equal(page.users().caption, 'User Index');
* let john = page.users.filter((item) => item.firstName === 'John' )[0];
* assert.equal(john.lastName, 'Doe');
*
* @param {Object} definition - Collection definition
* @param {string} definition.scope - Nests provided scope within parent's scope
* @param {boolean} definition.resetScope - Override parent's scope
* @param {string} definition.itemScope - CSS selector
* @param {Object} definition.item - Item definition
* @example if the browser you run tests supports Proxy, you can use array accessors to access elements by index
*
* // <table>
* // <tr>
* // <td>Mary<td>
* // </tr>
* // <tr>
* // <td>John<td>
* // </tr>
* // </table>
*
* const page = PageObject.create({
* users: PageObject.collection('tr')
* });
*
* // This only works on browsers that support `Proxy`
* assert.equal(page.users[0].text, 'Mary');
* assert.equal(page.users[1].text, 'John');
*
*
* @param {String} scopeOrDefinition - Selector to define the items of the collection
* @param {Object} [definitionOrNothing] - Object with the definition of item properties
* @return {Descriptor}
*/
export function collection(definition) {
definition = mergeFunction({}, definition);
export function collection(scopeOrDefinition, definitionOrNothing) {
let item = {
scope: definition.scope,
itemScope: definition.itemScope,
resetScope: definition.resetScope,
item: definition.item,
testContainer: definition.testContainer
};
if (typeof scopeOrDefinition === 'string') {
return mainCollection(scopeOrDefinition, definitionOrNothing);
}
delete definition.item;
delete definition.itemScope;
deprecate('You are currently using the legacy collection API, check the documentation to see how to upgrade to the new API.', false, {
id: 'ember-cli-page-object.old-collection-api',
until: '2.0.0',
url: 'https://gist.github.com/san650/17174e4b7b1fd80b049a47eb456a7cdc#file-old-collection-api-js',
});
return {
isDescriptor: true,
warn(
'Legacy page object collection definition is invalid. Please, make sure you include a `itemScope` selector.',
scopeOrDefinition.itemScope,
{
id: 'ember-cli-page-object.legacy-collection-missing-item-scope'
}
);
get(key) {
return (index) => {
if (typeof (index) === 'number') {
return generateItem(this, index, item, key);
} else {
return generateEnumerable(this, definition, item, key);
}
};
}
};
return legacyCollection(scopeOrDefinition);
}

@@ -44,3 +44,3 @@ 'use strict';

function parseSourceFile(filePath) {
return execCmd('node ./node_modules/documentation/bin/documentation "' + filePath + '" --format "md" --github --shallow');
return execCmd('node ./node_modules/documentation/bin/documentation build "' + filePath + '" -f md --shallow');
}

@@ -47,0 +47,0 @@

{
"name": "ember-cli-page-object",
"version": "1.13.0",
"version": "1.14.0",
"description": "This ember-cli addon eases the construction of page objects on your acceptance and integration tests",

@@ -40,3 +40,2 @@ "keywords": [

"ember-native-dom-helpers": "^0.5.3",
"ember-test-helpers": "^0.6.3",
"jquery": "^3.2.1",

@@ -67,2 +66,3 @@ "rsvp": "^4.7.0"

"ember-load-initializers": "^1.0.0",
"ember-qunit-assert-helpers": "^0.2.1",
"ember-qunit-nice-errors": "^1.1.2",

@@ -69,0 +69,0 @@ "ember-qunit-source-map": "1.1.0",

@@ -0,1 +1,3 @@

import { deprecate } from '@ember/application/deprecations';
import {

@@ -78,1 +80,7 @@ alias,

export { buildSelector, findElementWithAssert, findElement, getContext, fullScope } from 'ember-cli-page-object';
deprecate(`Importing from "test-support" is now deprecated. Please import directly from the "ember-cli-page-object" module instead.`, false, {
id: 'ember-cli-page-object.import-from-test-support',
until: "2.0.0",
url: "https://gist.github.com/san650/17174e4b7b1fd80b049a47eb456a7cdc#file-import-from-test-support-js"
})
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