Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@serenity-js/web

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serenity-js/web - npm Package Compare versions

Comparing version 3.0.0-rc.34 to 3.0.0-rc.35

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [3.0.0-rc.35](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.34...v3.0.0-rc.35) (2022-11-25)
### Bug Fixes
* **web:** marked PageElement methods returning a MetaQuestion ([6f78186](https://github.com/serenity-js/serenity-js/commit/6f78186c8c11c603ec447f89007009ea75e80b89))
# [3.0.0-rc.34](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.33...v3.0.0-rc.34) (2022-11-21)

@@ -8,0 +19,0 @@

20

lib/expectations/ElementExpectation.js

@@ -83,12 +83,2 @@ "use strict";

class ElementExpectation extends core_1.Expectation {
constructor(description, fn) {
super(description, async (actor, actual) => {
const pageElement = await actor.answer(actual);
const result = await fn(pageElement);
return result
? new core_1.ExpectationMet(this.toString(), undefined, pageElement)
: new core_1.ExpectationNotMet(this.toString(), undefined, pageElement);
});
this.fn = fn;
}
/**

@@ -136,4 +126,14 @@ * Instantiates a custom {@apilink PageElement}-specific {@apilink Expectation}

}
constructor(description, fn) {
super(description, async (actor, actual) => {
const pageElement = await actor.answer(actual);
const result = await fn(pageElement);
return result
? new core_1.ExpectationMet(this.toString(), undefined, pageElement)
: new core_1.ExpectationNotMet(this.toString(), undefined, pageElement);
});
this.fn = fn;
}
}
exports.ElementExpectation = ElementExpectation;
//# sourceMappingURL=ElementExpectation.js.map

@@ -81,5 +81,2 @@ "use strict";

class BrowseTheWeb {
constructor(session) {
this.session = session;
}
/**

@@ -95,2 +92,5 @@ * Used to access the {@apilink Actor}'s {@apilink Ability|ability} to {@apilink BrowseTheWeb}

}
constructor(session) {
this.session = session;
}
/**

@@ -97,0 +97,0 @@ * Returns a {@apilink Page} representing the currently active browser tab.

@@ -58,6 +58,2 @@ "use strict";

class Clear extends PageElementInteraction_1.PageElementInteraction {
constructor(field) {
super((0, core_1.d) `#actor clears the value of ${field}`);
this.field = field;
}
/**

@@ -74,2 +70,6 @@ * Instantiates an {@apilink Interaction|interaction}

}
constructor(field) {
super((0, core_1.d) `#actor clears the value of ${field}`);
this.field = field;
}
/**

@@ -76,0 +76,0 @@ * @inheritDoc

@@ -52,6 +52,2 @@ "use strict";

class Click extends PageElementInteraction_1.PageElementInteraction {
constructor(element) {
super((0, core_1.d) `#actor clicks on ${element}`);
this.element = element;
}
/**

@@ -66,2 +62,6 @@ * Instantiates this {@apilink Interaction}.

}
constructor(element) {
super((0, core_1.d) `#actor clicks on ${element}`);
this.element = element;
}
/**

@@ -68,0 +68,0 @@ * @inheritDoc

@@ -75,6 +75,2 @@ "use strict";

class DoubleClick extends PageElementInteraction_1.PageElementInteraction {
constructor(pageElement) {
super((0, core_1.d) `#actor double-clicks on ${pageElement}`);
this.pageElement = pageElement;
}
/**

@@ -89,2 +85,6 @@ * Instantiates this {@apilink Interaction}.

}
constructor(pageElement) {
super((0, core_1.d) `#actor double-clicks on ${pageElement}`);
this.pageElement = pageElement;
}
/**

@@ -91,0 +91,0 @@ * @inheritDoc

@@ -50,7 +50,2 @@ "use strict";

class Enter extends PageElementInteraction_1.PageElementInteraction {
constructor(values, field /* todo | Question<AlertPromise> | AlertPromise */) {
super((0, core_1.d) `#actor enters ${values.join(', ')} into ${field}`);
this.values = values;
this.field = field;
}
/**

@@ -67,2 +62,7 @@ * Instantiates this {@apilink Interaction}.

}
constructor(values, field /* todo | Question<AlertPromise> | AlertPromise */) {
super((0, core_1.d) `#actor enters ${values.join(', ')} into ${field}`);
this.values = values;
this.field = field;
}
/**

@@ -69,0 +69,0 @@ * @inheritDoc

@@ -56,6 +56,2 @@ "use strict";

class Hover extends PageElementInteraction_1.PageElementInteraction {
constructor(element) {
super((0, core_1.d) `#actor hovers the mouse over ${element}`);
this.element = element;
}
/**

@@ -70,2 +66,6 @@ * Instantiates this {@apilink Interaction}

}
constructor(element) {
super((0, core_1.d) `#actor hovers the mouse over ${element}`);
this.element = element;
}
/**

@@ -72,0 +72,0 @@ * @inheritDoc

@@ -65,10 +65,2 @@ "use strict";

/**
* @param keys
* A sequence of one or more keys to press
*/
constructor(keys) {
super((0, core_1.d) `#actor presses ${keys}`);
this.keys = keys;
}
/**
* Instantiates an {@apilink Interaction|interaction}

@@ -96,2 +88,10 @@ * that instructs the {@apilink Actor|actor}

/**
* @param keys
* A sequence of one or more keys to press
*/
constructor(keys) {
super((0, core_1.d) `#actor presses ${keys}`);
this.keys = keys;
}
/**
* @inheritDoc

@@ -139,2 +139,5 @@ */

class KeySequence extends core_1.Question {
static of(keys) {
return new KeySequence(keys);
}
constructor(keys) {

@@ -145,5 +148,2 @@ super();

}
static of(keys) {
return new KeySequence(keys);
}
async answeredBy(actor) {

@@ -150,0 +150,0 @@ const keys = await (0, io_1.asyncMap)(this.keys, key => actor.answer(key));

@@ -71,6 +71,2 @@ "use strict";

class RightClick extends PageElementInteraction_1.PageElementInteraction {
constructor(pageElement) {
super((0, core_1.d) `#actor right-clicks on ${pageElement}`);
this.pageElement = pageElement;
}
/**

@@ -85,2 +81,6 @@ * Instantiates this {@apilink Interaction}.

}
constructor(pageElement) {
super((0, core_1.d) `#actor right-clicks on ${pageElement}`);
this.pageElement = pageElement;
}
/**

@@ -87,0 +87,0 @@ * @inheritDoc

@@ -53,6 +53,2 @@ "use strict";

class Scroll extends core_1.Interaction {
constructor(element) {
super((0, core_1.d) `#actor scrolls to ${element}`);
this.element = element;
}
/**

@@ -67,2 +63,6 @@ * Instantiates this {@apilink Interaction}.

}
constructor(element) {
super((0, core_1.d) `#actor scrolls to ${element}`);
this.element = element;
}
/**

@@ -69,0 +69,0 @@ * @inheritDoc

@@ -104,6 +104,2 @@ "use strict";

class Switch extends core_1.Interaction {
constructor(switchable) {
super(`#actor switches to ${switchable}`);
this.switchable = switchable;
}
/**

@@ -119,2 +115,6 @@ * Instructs the {@apilink Actor}

}
constructor(switchable) {
super(`#actor switches to ${switchable}`);
this.switchable = switchable;
}
/**

@@ -121,0 +121,0 @@ * Instructs the {@apilink Actor}

@@ -36,6 +36,2 @@ "use strict";

class TakeScreenshot extends core_1.Interaction {
constructor(name) {
super((0, core_1.d) `#actor takes a screenshot of ${name}`);
this.name = name;
}
/**

@@ -50,2 +46,6 @@ * Instantiates this {@apilink Interaction}.

}
constructor(name) {
super((0, core_1.d) `#actor takes a screenshot of ${name}`);
this.name = name;
}
/**

@@ -52,0 +52,0 @@ * @inheritDoc

@@ -17,6 +17,2 @@ "use strict";

class Cookie {
constructor(cookieName) {
this.cookieName = cookieName;
(0, tiny_types_1.ensure)('browser', cookieName, (0, tiny_types_1.isDefined)());
}
/**

@@ -68,2 +64,6 @@ * Creates a {@apilink QuestionAdapter} that resolves to {@apilink Cookie} identified by `name`.

}
constructor(cookieName) {
this.cookieName = cookieName;
(0, tiny_types_1.ensure)('browser', cookieName, (0, tiny_types_1.isDefined)());
}
/**

@@ -164,3 +164,3 @@ * Returns the name of this cookie.

function ensureIfPresent(data, property, ...predicates) {
return data[property] !== undefined
return data[property]
? (0, tiny_types_1.ensure)(`Cookie.set(cookieData.${property})`, data[property], ...predicates)

@@ -167,0 +167,0 @@ : undefined;

@@ -21,2 +21,6 @@ "use strict";

class Key {
static isKey(maybeKey) {
return !!maybeKey
&& maybeKey instanceof Key;
}
constructor(devtoolsName, utf16codePoint, isModifier = false) {

@@ -27,6 +31,2 @@ this.devtoolsName = devtoolsName;

}
static isKey(maybeKey) {
return !!maybeKey
&& maybeKey instanceof Key;
}
toString() {

@@ -33,0 +33,0 @@ return this.devtoolsName.replace(/([a-z])([\dA-Z])/g, '$1 $2');

@@ -121,12 +121,2 @@ "use strict";

class Page {
constructor(session, rootLocator, modalDialogHandler, id) {
this.session = session;
this.rootLocator = rootLocator;
this.modalDialogHandler = modalDialogHandler;
this.id = id;
(0, tiny_types_1.ensure)('session', session, (0, tiny_types_1.isDefined)());
(0, tiny_types_1.ensure)('rootLocator', rootLocator, (0, tiny_types_1.isDefined)());
(0, tiny_types_1.ensure)('modalDialogHandler', modalDialogHandler, (0, tiny_types_1.isDefined)());
(0, tiny_types_1.ensure)('id', id, (0, tiny_types_1.isDefined)());
}
/**

@@ -221,2 +211,12 @@ * Creates a {@apilink QuestionAdapter} representing the currently active {@apilink Page}.

}
constructor(session, rootLocator, modalDialogHandler, id) {
this.session = session;
this.rootLocator = rootLocator;
this.modalDialogHandler = modalDialogHandler;
this.id = id;
(0, tiny_types_1.ensure)('session', session, (0, tiny_types_1.isDefined)());
(0, tiny_types_1.ensure)('rootLocator', rootLocator, (0, tiny_types_1.isDefined)());
(0, tiny_types_1.ensure)('modalDialogHandler', modalDialogHandler, (0, tiny_types_1.isDefined)());
(0, tiny_types_1.ensure)('id', id, (0, tiny_types_1.isDefined)());
}
/**

@@ -223,0 +223,0 @@ * Switches the current browsing context to the given page

@@ -1,2 +0,2 @@

import { Answerable, Optional, QuestionAdapter } from '@serenity-js/core';
import { Answerable, MetaQuestion, Optional, QuestionAdapter } from '@serenity-js/core';
import { Locator } from './Locator';

@@ -20,4 +20,4 @@ import { SelectOption } from './SelectOption';

readonly locator: Locator<Native_Element_Type>;
static located<NET>(selector: Answerable<Selector>): QuestionAdapter<PageElement<NET>>;
static of<NET>(childElement: Answerable<PageElement<NET>>, parentElement: Answerable<PageElement<NET>>): QuestionAdapter<PageElement<NET>>;
static located<NET>(selector: Answerable<Selector>): QuestionAdapter<PageElement<NET>> & MetaQuestion<PageElement, PageElement>;
static of<NET>(childElement: Answerable<PageElement<NET>>, parentElement: Answerable<PageElement<NET>>): QuestionAdapter<PageElement<NET>> & MetaQuestion<PageElement, PageElement>;
constructor(locator: Locator<Native_Element_Type>);

@@ -24,0 +24,0 @@ abstract of(parentElement: PageElement<Native_Element_Type>): PageElement<Native_Element_Type>;

@@ -19,6 +19,2 @@ "use strict";

class PageElement {
constructor(locator) {
this.locator = locator;
(0, tiny_types_1.ensure)('native element locator', locator, (0, tiny_types_1.isDefined)());
}
static located(selector) {

@@ -38,2 +34,6 @@ return core_1.Question.about((0, core_1.d) `page element located ${selector}`, async (actor) => {

}
constructor(locator) {
this.locator = locator;
(0, tiny_types_1.ensure)('native element locator', locator, (0, tiny_types_1.isDefined)());
}
/**

@@ -40,0 +40,0 @@ * An "escape hatch" providing access to the integration tool-specific implementation of a Web element.

@@ -19,2 +19,5 @@ "use strict";

class PageElements extends core_1.List {
static located(selector) {
return new PageElements(relativeToDocumentRoot(selector));
}
/**

@@ -27,5 +30,2 @@ * @param locator

}
static located(selector) {
return new PageElements(relativeToDocumentRoot(selector));
}
of(parent) {

@@ -32,0 +32,0 @@ return new PageElements(relativeToParent(this.locator, parent))

@@ -19,2 +19,8 @@ "use strict";

class SelectOption extends tiny_types_1.TinyType {
static withLabel(label) {
return new SelectOption(label);
}
static withValue(value) {
return new SelectOption(undefined, value);
}
constructor(label, value, selected, disabled) {

@@ -27,8 +33,2 @@ super();

}
static withLabel(label) {
return new SelectOption(label);
}
static withValue(value) {
return new SelectOption(undefined, value);
}
toString() {

@@ -35,0 +35,0 @@ return `<option /> element with label: ${this.label}, value: ${this.value}`;

@@ -99,10 +99,2 @@ "use strict";

class Attribute extends core_1.Question {
constructor(name, element) {
super();
this.name = name;
this.element = element;
this.subject = element
? (0, core_1.d) `${name} attribute of ${element}`
: (0, core_1.d) `${name} attribute`;
}
/**

@@ -119,2 +111,10 @@ * Instantiates a {@apilink Question} that uses

}
constructor(name, element) {
super();
this.name = name;
this.element = element;
this.subject = element
? (0, core_1.d) `${name} attribute of ${element}`
: (0, core_1.d) `${name} attribute`;
}
/**

@@ -121,0 +121,0 @@ * Resolves to the value of an HTML attribute of the `pageElement`.

@@ -100,7 +100,2 @@ "use strict";

class CssClasses extends core_1.Question {
constructor(pageElement) {
super();
this.pageElement = pageElement;
this.subject = (0, core_1.d) `CSS classes of ${pageElement}`;
}
/**

@@ -120,2 +115,7 @@ * Instantiates a {@apilink Question} that uses

}
constructor(pageElement) {
super();
this.pageElement = pageElement;
this.subject = (0, core_1.d) `CSS classes of ${pageElement}`;
}
/**

@@ -122,0 +122,0 @@ * Instantiates a {@apilink Question} that uses

@@ -120,2 +120,5 @@ "use strict";

class TextOfSingleElement extends core_1.Question {
static of(element) {
return core_1.Question.createAdapter(new TextOfSingleElement(element));
}
constructor(element) {

@@ -126,5 +129,2 @@ super();

}
static of(element) {
return core_1.Question.createAdapter(new TextOfSingleElement(element));
}
of(parent) {

@@ -155,2 +155,5 @@ return new TextOfSingleElement(models_1.PageElement.of(this.element, parent));

class TextOfMultipleElements extends core_1.Question {
static of(elements) {
return core_1.Question.createAdapter(new TextOfMultipleElements(elements));
}
constructor(elements) {

@@ -161,5 +164,2 @@ super();

}
static of(elements) {
return core_1.Question.createAdapter(new TextOfMultipleElements(elements));
}
of(parent) {

@@ -166,0 +166,0 @@ return new TextOfMultipleElements(this.elements.of(parent));

@@ -61,7 +61,2 @@ "use strict";

class Value extends core_1.Question {
constructor(element) {
super();
this.element = element;
this.subject = (0, core_1.d) `the value of ${element}`;
}
/**

@@ -80,2 +75,7 @@ * Instantiates a {@apilink Question} that uses

}
constructor(element) {
super();
this.element = element;
this.subject = (0, core_1.d) `the value of ${element}`;
}
/**

@@ -82,0 +82,0 @@ * Instantiates a {@apilink Question} that uses

@@ -118,6 +118,2 @@ "use strict";

class Photographer {
constructor(photoTakingStrategy, stage) {
this.photoTakingStrategy = photoTakingStrategy;
this.stage = stage;
}
/**

@@ -133,2 +129,6 @@ * Instantiates a new {@apilink Photographer} configured to take photos (screenshots)

}
constructor(photoTakingStrategy, stage) {
this.photoTakingStrategy = photoTakingStrategy;
this.stage = stage;
}
/**

@@ -135,0 +135,0 @@ * Assigns this {@apilink StageCrewMember} to a given {@apilink Stage}.

{
"name": "@serenity-js/web",
"version": "3.0.0-rc.34",
"version": "3.0.0-rc.35",
"description": "Serenity/JS Screenplay Pattern APIs for the Web",

@@ -47,4 +47,4 @@ "author": {

"dependencies": {
"@serenity-js/assertions": "3.0.0-rc.34",
"@serenity-js/core": "3.0.0-rc.34",
"@serenity-js/assertions": "3.0.0-rc.35",
"@serenity-js/core": "3.0.0-rc.35",
"tiny-types": "^1.19.0"

@@ -55,9 +55,9 @@ },

"@types/chai": "^4.3.4",
"@types/mocha": "^9.1.1",
"mocha": "^10.0.0",
"@types/mocha": "^10.0.0",
"mocha": "^10.1.0",
"nyc": "15.1.0",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
"typescript": "^4.9.3"
},
"gitHead": "5b0ad14a0b673fdb541ec89ac67dc631db562018"
"gitHead": "632f7c62c31321cfb7641ee834b5636e1eefa442"
}

@@ -197,5 +197,5 @@ import { Answerable, d, Interaction, Optional, Question, QuestionAdapter, Timestamp } from '@serenity-js/core';

function ensureIfPresent<K extends keyof CookieData>(data: CookieData, property: K, ...predicates: Array<Predicate<CookieData[K]>>): CookieData[K] | undefined {
return data[property] !== undefined
return data[property]
? ensure(`Cookie.set(cookieData.${property})`, data[property], ...predicates)
: undefined;
}

@@ -1,2 +0,2 @@

import { Answerable, d, Optional, Question, QuestionAdapter } from '@serenity-js/core';
import { Answerable, d, MetaQuestion, Optional, Question, QuestionAdapter } from '@serenity-js/core';
import { ensure, isDefined } from 'tiny-types';

@@ -24,3 +24,3 @@

static located<NET>(selector: Answerable<Selector>): QuestionAdapter<PageElement<NET>> {
static located<NET>(selector: Answerable<Selector>): QuestionAdapter<PageElement<NET>> & MetaQuestion<PageElement, PageElement> {
return Question.about(d`page element located ${ selector }`, async actor => {

@@ -31,6 +31,6 @@ const bySelector = await actor.answer(selector);

return currentPage.locate(bySelector);
});
}) as QuestionAdapter<PageElement<NET>> & MetaQuestion<PageElement, PageElement>;
}
static of<NET>(childElement: Answerable<PageElement<NET>>, parentElement: Answerable<PageElement<NET>>): QuestionAdapter<PageElement<NET>> {
static of<NET>(childElement: Answerable<PageElement<NET>>, parentElement: Answerable<PageElement<NET>>): QuestionAdapter<PageElement<NET>> & MetaQuestion<PageElement, PageElement> {
return Question.about(d`${ childElement } of ${ parentElement }`, async actor => {

@@ -41,3 +41,3 @@ const child = await actor.answer(childElement);

return child.of(parent);
});
}) as QuestionAdapter<PageElement<NET>> & MetaQuestion<PageElement, PageElement>;
}

@@ -44,0 +44,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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