Socket
Socket
Sign inDemoInstall

@bigtest/interactor

Package Overview
Dependencies
22
Maintainers
1
Versions
809
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.28.2-48be5e74 to 0.28.2-48ce3532

dist/cjs/read.js

6

dist/cjs/constructor.js
"use strict";
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true });
exports.createConstructor = exports.instantiateInteractor = exports.instantiateBaseInteractor = exports.unsafeSyncResolveParent = exports.resolveEmpty = exports.resolveNonEmpty = exports.resolveUnique = exports.findElements = void 0;
exports.createConstructor = exports.instantiateInteractor = exports.instantiateBaseInteractor = exports.unsafeSyncResolveUnique = exports.unsafeSyncResolveParent = exports.resolveEmpty = exports.resolveNonEmpty = exports.resolveUnique = exports.findElements = void 0;
const globals_1 = require("@bigtest/globals");

@@ -30,2 +30,5 @@ const converge_1 = require("./converge");

function findMatches(parentElement, interactor) {
if (!interactor.name) {
throw new Error('An interactor used for this test was not given a label. Please provide a name for your interactor:\n\tHTML.extend(\'my interactor\') || createInteractor(\'my interactor\')');
}
return findElements(parentElement, interactor).map((e) => new match_2.Match(e, interactor.filter, interactor.locator));

@@ -102,2 +105,3 @@ }

}
exports.unsafeSyncResolveUnique = unsafeSyncResolveUnique;
function instantiateBaseInteractor(options, resolver) {

@@ -104,0 +108,0 @@ let interactor = {

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

const element_is_visible_1 = require("element-is-visible");
const dispatch_1 = require("../dispatch");
const form_field_1 = require("./form-field");

@@ -11,2 +12,3 @@ const CheckBoxInteractor = form_field_1.FormField.extend('check box')

checked: (element) => element.checked,
indeterminate: (element) => element.indeterminate,
visible: {

@@ -18,7 +20,20 @@ apply: (element) => element_is_visible_1.isVisible(element) || (element.labels && Array.from(element.labels).some(element_is_visible_1.isVisible)),

.actions({
check: ({ perform }) => perform((element) => { if (!element.checked)
element.click(); }),
uncheck: ({ perform }) => perform((element) => { if (element.checked)
element.click(); }),
toggle: ({ perform }) => perform((element) => { element.click(); }),
check: ({ perform }) => perform((element) => {
if ((!element.checked || element.indeterminate))
if (dispatch_1.dispatchClick(element))
element.indeterminate = false;
}),
uncheck: ({ perform }) => perform((element) => {
if ((element.checked || element.indeterminate))
if (dispatch_1.dispatchClick(element))
element.indeterminate = false;
}),
toggle: ({ perform }) => perform((element) => {
if (dispatch_1.dispatchClick(element))
element.indeterminate = false;
}),
click: ({ perform }) => perform((element) => {
if (dispatch_1.dispatchClick(element))
element.indeterminate = false;
}),
});

@@ -47,2 +62,3 @@ /**

* - `checked`: *boolean* – Filter by whether the checkbox is checked.
* - `indeterminate`: *boolean* - Filter by whether the checkbox has indeterminate state.
* - `disabled`: *boolean* – Filter by whether the checkbox is disabled. Defaults to `false`.

@@ -49,0 +65,0 @@ * - `focused`: *boolean* – Filter by whether the checkbox is focused. See {@link focused}.

2

dist/cjs/definitions/text-field.js

@@ -27,3 +27,3 @@ "use strict";

*
* The text fied is located by the text of its label.
* The text field is located by the text of its label.
*

@@ -30,0 +30,0 @@ * ### Example

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dispatchKeyUp = exports.dispatchKeyDown = exports.dispatchInput = exports.dispatchChange = void 0;
exports.dispatchClick = exports.dispatchKeyUp = exports.dispatchKeyDown = exports.dispatchInput = exports.dispatchChange = void 0;
function dispatchChange(element) {

@@ -28,2 +28,8 @@ var _a;

exports.dispatchKeyUp = dispatchKeyUp;
function dispatchClick(element, options = {}) {
var _a;
let MouseEvent = ((_a = element.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.MouseEvent) || window.MouseEvent;
return element.dispatchEvent(new MouseEvent('click', Object.assign({ bubbles: true, cancelable: true }, options)));
}
exports.dispatchClick = dispatchClick;
//# sourceMappingURL=dispatch.js.map

@@ -30,3 +30,3 @@ "use strict";

else {
return `with ${change_case_1.noCase(key)} ${matcher_1.formatMatcher(value)}`;
return `with ${change_case_1.noCase(key)} ${matcher_1.matcherDescription(value)}`;
}

@@ -47,3 +47,3 @@ }).join(' and ');

asTableHeader() {
return Object.entries(this.all).map(([key, value]) => `${key}: ${matcher_1.formatMatcher(value)}`);
return Object.entries(this.all).map(([key, value]) => `${key}: ${matcher_1.matcherDescription(value)}`);
}

@@ -50,0 +50,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.every = exports.some = exports.not = exports.or = exports.and = exports.matching = exports.including = exports.MultiSelect = exports.Select = exports.RadioButton = exports.CheckBox = exports.TextField = exports.Button = exports.Heading = exports.Link = exports.FormField = exports.HTML = exports.isVisible = exports.blur = exports.focus = exports.focused = exports.fillIn = exports.perform = exports.App = exports.Page = exports.createInspector = exports.createInteractor = void 0;
exports.every = exports.some = exports.not = exports.or = exports.and = exports.matching = exports.including = exports.MultiSelect = exports.Select = exports.RadioButton = exports.CheckBox = exports.TextField = exports.Button = exports.Heading = exports.Link = exports.FormField = exports.HTML = exports.isVisible = exports.blur = exports.focus = exports.focused = exports.fillIn = exports.perform = exports.read = exports.App = exports.Page = exports.createInspector = exports.createInteractor = void 0;
var create_interactor_1 = require("./create-interactor");

@@ -12,2 +12,4 @@ Object.defineProperty(exports, "createInteractor", { enumerable: true, get: function () { return create_interactor_1.createInteractor; } });

Object.defineProperty(exports, "App", { enumerable: true, get: function () { return app_1.App; } });
var read_1 = require("./read");
Object.defineProperty(exports, "read", { enumerable: true, get: function () { return read_1.read; } });
var perform_1 = require("./perform");

@@ -14,0 +16,0 @@ Object.defineProperty(exports, "perform", { enumerable: true, get: function () { return perform_1.perform; } });

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

function createInspector(constructor, parentElement) {
// NOTE: Wait for https://github.com/thefrontside/bigtest/pull/895 to use specification instead
let options = constructor().options;

@@ -9,0 +10,0 @@ return {

@@ -11,3 +11,3 @@ "use strict";

get description() {
return matcher_1.formatMatcher(this.value);
return matcher_1.matcherDescription(this.value);
}

@@ -14,0 +14,0 @@ }

@@ -26,3 +26,3 @@ "use strict";

if (this.matchLocator) {
return [this.matchLocator.format(), ...this.matchFilter.asTableRow()];
return [this.matchLocator.description(), ...this.matchFilter.asTableRow()];
}

@@ -57,3 +57,3 @@ else {

}
format() {
description() {
return `${check(this.matches)} ${this.formatActual()}`;

@@ -76,3 +76,3 @@ }

asTableRow() {
return this.items.map((f) => f.format());
return this.items.map((f) => f.description());
}

@@ -111,5 +111,5 @@ get sortWeight() {

formatExpected() {
return matcher_1.formatMatcher(this.expected);
return matcher_1.matcherDescription(this.expected);
}
format() {
description() {
return `${check(this.matches)} ${this.formatActual()}`;

@@ -116,0 +116,0 @@ }

@@ -6,10 +6,18 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.applyMatcher = exports.formatMatcher = exports.isMatcher = void 0;
exports.applyMatcher = exports.matcherDescription = exports.isDeprecatedMatcher = exports.isMatcher = void 0;
const lodash_isequal_1 = __importDefault(require("lodash.isequal"));
function isMatcher(value) {
return value && typeof value.match === 'function' && typeof value.description === 'function';
}
exports.isMatcher = isMatcher;
function isDeprecatedMatcher(value) {
return value && typeof value.match === 'function' && typeof value.format === 'function';
}
exports.isMatcher = isMatcher;
function formatMatcher(value) {
exports.isDeprecatedMatcher = isDeprecatedMatcher;
function matcherDescription(value) {
if (isMatcher(value)) {
return value.description();
}
else if (isDeprecatedMatcher(value)) {
console.warn('DEPRECATION: format() is deprecated, use description() instead');
return value.format();

@@ -21,5 +29,5 @@ }

}
exports.formatMatcher = formatMatcher;
exports.matcherDescription = matcherDescription;
function applyMatcher(value, actual) {
if (isMatcher(value)) {
if (isMatcher(value) || isDeprecatedMatcher(value)) {
return value.match(actual);

@@ -26,0 +34,0 @@ }

@@ -10,4 +10,4 @@ "use strict";

},
format() {
return args.map(matcher_1.formatMatcher).join(' and ');
description() {
return args.map(matcher_1.matcherDescription).join(' and ');
},

@@ -14,0 +14,0 @@ };

@@ -10,4 +10,4 @@ "use strict";

},
format() {
return `every item ${matcher_1.formatMatcher(expected)}`;
description() {
return `every item ${matcher_1.matcherDescription(expected)}`;
},

@@ -14,0 +14,0 @@ };

@@ -9,3 +9,3 @@ "use strict";

},
format() {
description() {
return `including ${JSON.stringify(subString)}`;

@@ -12,0 +12,0 @@ },

@@ -9,3 +9,3 @@ "use strict";

},
format() {
description() {
return `matching ${regexp}`;

@@ -12,0 +12,0 @@ },

@@ -10,4 +10,4 @@ "use strict";

},
format() {
return `not ${matcher_1.formatMatcher(matcher)}`;
description() {
return `not ${matcher_1.matcherDescription(matcher)}`;
},

@@ -14,0 +14,0 @@ };

@@ -10,4 +10,4 @@ "use strict";

},
format() {
return args.map(matcher_1.formatMatcher).join(' or ');
description() {
return args.map(matcher_1.matcherDescription).join(' or ');
},

@@ -14,0 +14,0 @@ };

@@ -10,4 +10,4 @@ "use strict";

},
format() {
return `some item ${matcher_1.formatMatcher(expected)}`;
description() {
return `some item ${matcher_1.matcherDescription(expected)}`;
},

@@ -14,0 +14,0 @@ };

@@ -7,2 +7,3 @@ import { InteractorOptions, ActionMethods, InteractorConstructor, Interactor, Filters, Actions, FilterParams, InteractorSpecification, BaseInteractor } from './specification';

export declare function unsafeSyncResolveParent(options: InteractorOptions<any, any, any>): Element;
export declare function unsafeSyncResolveUnique<E extends Element>(options: InteractorOptions<E, any, any>): E;
export declare function instantiateBaseInteractor<E extends Element, F extends Filters<E>, A extends Actions<E>>(options: InteractorOptions<E, F, A>, resolver: (options: InteractorOptions<E, F, A>) => E): BaseInteractor<E, FilterParams<E, F>> & ActionMethods<E, A>;

@@ -9,0 +10,0 @@ export declare function instantiateInteractor<E extends Element, F extends Filters<E>, A extends Actions<E>>(options: InteractorOptions<E, F, A>): Interactor<E, FilterParams<E, F>> & ActionMethods<E, A>;

@@ -33,11 +33,11 @@ /**

export declare const Button: import("..").InteractorConstructor<HTMLButtonElement | HTMLInputElement, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, {
text?: string | import("..").Matcher<string> | undefined;
title?: string | import("..").Matcher<string> | undefined;
id?: string | import("..").Matcher<string> | undefined;
visible?: boolean | import("..").Matcher<boolean> | undefined;
className?: string | import("..").Matcher<string> | undefined;
classList?: string[] | import("..").Matcher<string[]> | undefined;
focused?: boolean | import("..").Matcher<boolean> | undefined;
text?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
title?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
id?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
visible?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
className?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
classList?: string[] | import("../matcher").NewMatcher<string[]> | import("../matcher").OldMatcher<string[]> | undefined;
focused?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
disabled?: boolean | import("..").Matcher<boolean> | undefined;
disabled?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, import("../merge-objects").MergeObjects<Record<never, never>, import("../specification").ActionMethods<HTMLElement, {

@@ -44,0 +44,0 @@ click: ({ perform }: import("..").Interactor<HTMLElement, Record<never, never>>) => import("..").Interaction<void>;

@@ -23,2 +23,3 @@ /**

* - `checked`: *boolean* – Filter by whether the checkbox is checked.
* - `indeterminate`: *boolean* - Filter by whether the checkbox has indeterminate state.
* - `disabled`: *boolean* – Filter by whether the checkbox is disabled. Defaults to `false`.

@@ -39,54 +40,19 @@ * - `focused`: *boolean* – Filter by whether the checkbox is focused. See {@link focused}.

export declare const CheckBox: import("..").InteractorConstructor<HTMLInputElement, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, {
text?: string | import("..").Matcher<string> | undefined;
title?: string | import("..").Matcher<string> | undefined;
id?: string | import("..").Matcher<string> | undefined;
visible?: boolean | import("..").Matcher<boolean> | undefined;
className?: string | import("..").Matcher<string> | undefined;
classList?: string[] | import("..").Matcher<string[]> | undefined;
focused?: boolean | import("..").Matcher<boolean> | undefined;
text?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
title?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
id?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
visible?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
className?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
classList?: string[] | import("../matcher").NewMatcher<string[]> | import("../matcher").OldMatcher<string[]> | undefined;
focused?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
valid?: boolean | import("..").Matcher<boolean> | undefined;
disabled?: boolean | import("..").Matcher<boolean> | undefined;
valid?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
disabled?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
checked?: boolean | import("..").Matcher<boolean> | undefined;
visible?: boolean | import("..").Matcher<boolean | null> | null | undefined;
checked?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
indeterminate?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
visible?: boolean | import("../matcher").NewMatcher<boolean | null> | import("../matcher").OldMatcher<boolean | null> | null | undefined;
}>, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, import("../specification").ActionMethods<HTMLElement, {
click: ({ perform }: import("..").Interactor<HTMLElement, Record<never, never>>) => import("..").Interaction<void>;
focus: ({ perform }: import("..").Interactor<HTMLElement, Record<never, never>>) => import("..").Interaction<void>;
/**
* Call this {@link InteractorConstructor} to initialize a checkbox {@link Interactor}.
* The checkbox interactor can be used to interact with checkboxes on the page and
* to assert on their state.
*
* The checkbox is located by the text of its label.
*
* ### Example
*
* ``` typescript
* await CheckBox('Submit').click();
* await CheckBox('Submit').is({ disabled: true });
* await CheckBox({ id: 'submit-button', disabled: true }).exists();
* ```
*
* ### Filters
*
* - `title`: *string* – Filter by title
* - `id`: *string* – Filter by id
* - `visible`: *boolean* – Filter by visibility. Defaults to `true`. See {@link isVisible}.
* - `valid`: *boolean* – Filter by whether the checkbox is valid.
* - `checked`: *boolean* – Filter by whether the checkbox is checked.
* - `disabled`: *boolean* – Filter by whether the checkbox is disabled. Defaults to `false`.
* - `focused`: *boolean* – Filter by whether the checkbox is focused. See {@link focused}.
*
* ### Actions
*
* - `click()`: *{@link Interaction}* – Click on the checkbox
* - `focus()`: *{@link Interaction}* – Focus the checkbox
* - `blur()`: *{@link Interaction}* – Blur the checkbox
* - `check()`: *{@link Interaction}* – Check the checkbox if it is not checked
* - `uncheck()`: *{@link Interaction}* – Uncheck the checkbox if it is checked
* - `toggle()`: *{@link Interaction}* – Toggle the checkbox
*
* @category Interactor
*/
blur: ({ perform }: import("..").Interactor<HTMLElement, Record<never, never>>) => import("..").Interaction<void>;

@@ -97,3 +63,4 @@ }>>, import("../specification").ActionMethods<HTMLInputElement, {

toggle: ({ perform }: import("..").Interactor<HTMLInputElement, Record<never, never>>) => import("..").Interaction<void>;
click: ({ perform }: import("..").Interactor<HTMLInputElement, Record<never, never>>) => import("..").Interaction<void>;
}>>>;
//# sourceMappingURL=check-box.d.ts.map

@@ -38,12 +38,12 @@ declare type FieldTypes = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | HTMLSelectElement;

export declare const FormField: import("..").InteractorConstructor<FieldTypes, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, {
text?: string | import("..").Matcher<string> | undefined;
title?: string | import("..").Matcher<string> | undefined;
id?: string | import("..").Matcher<string> | undefined;
visible?: boolean | import("..").Matcher<boolean> | undefined;
className?: string | import("..").Matcher<string> | undefined;
classList?: string[] | import("..").Matcher<string[]> | undefined;
focused?: boolean | import("..").Matcher<boolean> | undefined;
text?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
title?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
id?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
visible?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
className?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
classList?: string[] | import("../matcher").NewMatcher<string[]> | import("../matcher").OldMatcher<string[]> | undefined;
focused?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
valid?: boolean | import("..").Matcher<boolean> | undefined;
disabled?: boolean | import("..").Matcher<boolean> | undefined;
valid?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
disabled?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, import("../merge-objects").MergeObjects<Record<never, never>, import("../specification").ActionMethods<HTMLElement, {

@@ -50,0 +50,0 @@ click: ({ perform }: import("..").Interactor<HTMLElement, Record<never, never>>) => import("..").Interaction<void>;

@@ -20,11 +20,11 @@ /**

export declare const Heading: import("..").InteractorConstructor<HTMLHeadingElement, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, {
text?: string | import("..").Matcher<string> | undefined;
title?: string | import("..").Matcher<string> | undefined;
id?: string | import("..").Matcher<string> | undefined;
visible?: boolean | import("..").Matcher<boolean> | undefined;
className?: string | import("..").Matcher<string> | undefined;
classList?: string[] | import("..").Matcher<string[]> | undefined;
focused?: boolean | import("..").Matcher<boolean> | undefined;
text?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
title?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
id?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
visible?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
className?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
classList?: string[] | import("../matcher").NewMatcher<string[]> | import("../matcher").OldMatcher<string[]> | undefined;
focused?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
level?: number | import("..").Matcher<number> | undefined;
level?: number | import("../matcher").NewMatcher<number> | import("../matcher").OldMatcher<number> | undefined;
}>, import("../merge-objects").MergeObjects<Record<never, never>, import("../specification").ActionMethods<HTMLElement, {

@@ -31,0 +31,0 @@ click: ({ perform }: import("..").Interactor<HTMLElement, Record<never, never>>) => import("..").Interaction<void>;

@@ -36,9 +36,9 @@ export declare function innerText(element?: HTMLElement): string;

export declare const HTML: import("..").InteractorConstructor<HTMLElement, import("../merge-objects").MergeObjects<Record<never, never>, {
text?: string | import("..").Matcher<string> | undefined;
title?: string | import("..").Matcher<string> | undefined;
id?: string | import("..").Matcher<string> | undefined;
visible?: boolean | import("..").Matcher<boolean> | undefined;
className?: string | import("..").Matcher<string> | undefined;
classList?: string[] | import("..").Matcher<string[]> | undefined;
focused?: boolean | import("..").Matcher<boolean> | undefined;
text?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
title?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
id?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
visible?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
className?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
classList?: string[] | import("../matcher").NewMatcher<string[]> | import("../matcher").OldMatcher<string[]> | undefined;
focused?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, import("../merge-objects").MergeObjects<Record<never, never>, import("../specification").ActionMethods<HTMLElement, {

@@ -45,0 +45,0 @@ click: ({ perform }: import("..").Interactor<HTMLElement, Record<never, never>>) => import("..").Interaction<void>;

@@ -33,11 +33,11 @@ /**

export declare const Link: import("..").InteractorConstructor<HTMLLinkElement, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, {
text?: string | import("..").Matcher<string> | undefined;
title?: string | import("..").Matcher<string> | undefined;
id?: string | import("..").Matcher<string> | undefined;
visible?: boolean | import("..").Matcher<boolean> | undefined;
className?: string | import("..").Matcher<string> | undefined;
classList?: string[] | import("..").Matcher<string[]> | undefined;
focused?: boolean | import("..").Matcher<boolean> | undefined;
text?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
title?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
id?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
visible?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
className?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
classList?: string[] | import("../matcher").NewMatcher<string[]> | import("../matcher").OldMatcher<string[]> | undefined;
focused?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
href?: string | import("..").Matcher<string> | undefined;
href?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
}>, import("../merge-objects").MergeObjects<Record<never, never>, import("../specification").ActionMethods<HTMLElement, {

@@ -44,0 +44,0 @@ click: ({ perform }: import("..").Interactor<HTMLElement, Record<never, never>>) => import("..").Interaction<void>;

@@ -42,14 +42,14 @@ /**

export declare const MultiSelect: import("..").InteractorConstructor<HTMLSelectElement, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, {
text?: string | import("..").Matcher<string> | undefined;
title?: string | import("..").Matcher<string> | undefined;
id?: string | import("..").Matcher<string> | undefined;
visible?: boolean | import("..").Matcher<boolean> | undefined;
className?: string | import("..").Matcher<string> | undefined;
classList?: string[] | import("..").Matcher<string[]> | undefined;
focused?: boolean | import("..").Matcher<boolean> | undefined;
text?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
title?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
id?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
visible?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
className?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
classList?: string[] | import("../matcher").NewMatcher<string[]> | import("../matcher").OldMatcher<string[]> | undefined;
focused?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
valid?: boolean | import("..").Matcher<boolean> | undefined;
disabled?: boolean | import("..").Matcher<boolean> | undefined;
valid?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
disabled?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
values?: string[] | import("..").Matcher<string[]> | undefined;
values?: string[] | import("../matcher").NewMatcher<string[]> | import("../matcher").OldMatcher<string[]> | undefined;
}>, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, import("../specification").ActionMethods<HTMLElement, {

@@ -56,0 +56,0 @@ click: ({ perform }: import("..").Interactor<HTMLElement, Record<never, never>>) => import("..").Interaction<void>;

@@ -36,15 +36,15 @@ /**

export declare const RadioButton: import("..").InteractorConstructor<HTMLInputElement, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, {
text?: string | import("..").Matcher<string> | undefined;
title?: string | import("..").Matcher<string> | undefined;
id?: string | import("..").Matcher<string> | undefined;
visible?: boolean | import("..").Matcher<boolean> | undefined;
className?: string | import("..").Matcher<string> | undefined;
classList?: string[] | import("..").Matcher<string[]> | undefined;
focused?: boolean | import("..").Matcher<boolean> | undefined;
text?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
title?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
id?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
visible?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
className?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
classList?: string[] | import("../matcher").NewMatcher<string[]> | import("../matcher").OldMatcher<string[]> | undefined;
focused?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
valid?: boolean | import("..").Matcher<boolean> | undefined;
disabled?: boolean | import("..").Matcher<boolean> | undefined;
valid?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
disabled?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
checked?: boolean | import("..").Matcher<boolean> | undefined;
visible?: boolean | import("..").Matcher<boolean | null> | null | undefined;
checked?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
visible?: boolean | import("../matcher").NewMatcher<boolean | null> | import("../matcher").OldMatcher<boolean | null> | null | undefined;
}>, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, import("../specification").ActionMethods<HTMLElement, {

@@ -51,0 +51,0 @@ click: ({ perform }: import("..").Interactor<HTMLElement, Record<never, never>>) => import("..").Interaction<void>;

@@ -37,14 +37,14 @@ /**

export declare const Select: import("..").InteractorConstructor<HTMLSelectElement, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, {
text?: string | import("..").Matcher<string> | undefined;
title?: string | import("..").Matcher<string> | undefined;
id?: string | import("..").Matcher<string> | undefined;
visible?: boolean | import("..").Matcher<boolean> | undefined;
className?: string | import("..").Matcher<string> | undefined;
classList?: string[] | import("..").Matcher<string[]> | undefined;
focused?: boolean | import("..").Matcher<boolean> | undefined;
text?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
title?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
id?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
visible?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
className?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
classList?: string[] | import("../matcher").NewMatcher<string[]> | import("../matcher").OldMatcher<string[]> | undefined;
focused?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
valid?: boolean | import("..").Matcher<boolean> | undefined;
disabled?: boolean | import("..").Matcher<boolean> | undefined;
valid?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
disabled?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
value?: string | import("..").Matcher<string> | undefined;
value?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
}>, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, import("../specification").ActionMethods<HTMLElement, {

@@ -51,0 +51,0 @@ click: ({ perform }: import("..").Interactor<HTMLElement, Record<never, never>>) => import("..").Interaction<void>;

@@ -9,3 +9,3 @@ /**

*
* The text fied is located by the text of its label.
* The text field is located by the text of its label.
*

@@ -41,15 +41,15 @@ * ### Example

export declare const TextField: import("..").InteractorConstructor<HTMLInputElement | HTMLTextAreaElement, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, {
text?: string | import("..").Matcher<string> | undefined;
title?: string | import("..").Matcher<string> | undefined;
id?: string | import("..").Matcher<string> | undefined;
visible?: boolean | import("..").Matcher<boolean> | undefined;
className?: string | import("..").Matcher<string> | undefined;
classList?: string[] | import("..").Matcher<string[]> | undefined;
focused?: boolean | import("..").Matcher<boolean> | undefined;
text?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
title?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
id?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
visible?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
className?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
classList?: string[] | import("../matcher").NewMatcher<string[]> | import("../matcher").OldMatcher<string[]> | undefined;
focused?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
valid?: boolean | import("..").Matcher<boolean> | undefined;
disabled?: boolean | import("..").Matcher<boolean> | undefined;
valid?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
disabled?: boolean | import("../matcher").NewMatcher<boolean> | import("../matcher").OldMatcher<boolean> | undefined;
}>, {
value?: string | import("..").Matcher<string> | undefined;
placeholder?: string | import("..").Matcher<string> | undefined;
value?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
placeholder?: string | import("../matcher").NewMatcher<string> | import("../matcher").OldMatcher<string> | undefined;
}>, import("../merge-objects").MergeObjects<import("../merge-objects").MergeObjects<Record<never, never>, import("../specification").ActionMethods<HTMLElement, {

@@ -56,0 +56,0 @@ click: ({ perform }: import("..").Interactor<HTMLElement, Record<never, never>>) => import("..").Interaction<void>;

@@ -5,2 +5,3 @@ export declare function dispatchChange(element: HTMLElement): boolean;

export declare function dispatchKeyUp(element: HTMLElement, options?: KeyboardEventInit): boolean;
export declare function dispatchClick(element: HTMLElement, options?: MouseEventInit): boolean;
//# sourceMappingURL=dispatch.d.ts.map

@@ -26,2 +26,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

function findMatches(parentElement, interactor) {
if (!interactor.name) {
throw new Error('An interactor used for this test was not given a label. Please provide a name for your interactor:\n\tHTML.extend(\'my interactor\') || createInteractor(\'my interactor\')');
}
return findElements(parentElement, interactor).map((e) => new Match(e, interactor.filter, interactor.locator));

@@ -91,3 +94,3 @@ }

}
function unsafeSyncResolveUnique(options) {
export function unsafeSyncResolveUnique(options) {
return resolveUnique(unsafeSyncResolveParent(options), options);

@@ -94,0 +97,0 @@ }

import { isVisible } from 'element-is-visible';
import { dispatchClick } from '../dispatch';
import { FormField } from './form-field';

@@ -7,2 +8,3 @@ const CheckBoxInteractor = FormField.extend('check box')

checked: (element) => element.checked,
indeterminate: (element) => element.indeterminate,
visible: {

@@ -14,7 +16,20 @@ apply: (element) => isVisible(element) || (element.labels && Array.from(element.labels).some(isVisible)),

.actions({
check: ({ perform }) => perform((element) => { if (!element.checked)
element.click(); }),
uncheck: ({ perform }) => perform((element) => { if (element.checked)
element.click(); }),
toggle: ({ perform }) => perform((element) => { element.click(); }),
check: ({ perform }) => perform((element) => {
if ((!element.checked || element.indeterminate))
if (dispatchClick(element))
element.indeterminate = false;
}),
uncheck: ({ perform }) => perform((element) => {
if ((element.checked || element.indeterminate))
if (dispatchClick(element))
element.indeterminate = false;
}),
toggle: ({ perform }) => perform((element) => {
if (dispatchClick(element))
element.indeterminate = false;
}),
click: ({ perform }) => perform((element) => {
if (dispatchClick(element))
element.indeterminate = false;
}),
});

@@ -43,2 +58,3 @@ /**

* - `checked`: *boolean* – Filter by whether the checkbox is checked.
* - `indeterminate`: *boolean* - Filter by whether the checkbox has indeterminate state.
* - `disabled`: *boolean* – Filter by whether the checkbox is disabled. Defaults to `false`.

@@ -45,0 +61,0 @@ * - `focused`: *boolean* – Filter by whether the checkbox is focused. See {@link focused}.

@@ -24,3 +24,3 @@ import { fillIn } from '../index';

*
* The text fied is located by the text of its label.
* The text field is located by the text of its label.
*

@@ -27,0 +27,0 @@ * ### Example

@@ -21,2 +21,7 @@ export function dispatchChange(element) {

}
export function dispatchClick(element, options = {}) {
var _a;
let MouseEvent = ((_a = element.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.MouseEvent) || window.MouseEvent;
return element.dispatchEvent(new MouseEvent('click', Object.assign({ bubbles: true, cancelable: true }, options)));
}
//# sourceMappingURL=dispatch.js.map
import { noCase } from 'change-case';
import { formatMatcher } from './matcher';
import { matcherDescription } from './matcher';
export class Filter {

@@ -27,3 +27,3 @@ constructor(

else {
return `with ${noCase(key)} ${formatMatcher(value)}`;
return `with ${noCase(key)} ${matcherDescription(value)}`;
}

@@ -44,5 +44,5 @@ }).join(' and ');

asTableHeader() {
return Object.entries(this.all).map(([key, value]) => `${key}: ${formatMatcher(value)}`);
return Object.entries(this.all).map(([key, value]) => `${key}: ${matcherDescription(value)}`);
}
}
//# sourceMappingURL=filter.js.map

@@ -5,2 +5,3 @@ export { createInteractor } from './create-interactor';

export { App } from './app';
export { read } from './read';
export { perform } from './perform';

@@ -7,0 +8,0 @@ export { fillIn } from './fill-in';

/* eslint-disable @typescript-eslint/no-explicit-any */
import { instantiateBaseInteractor, findElements, unsafeSyncResolveParent } from "./constructor";
export function createInspector(constructor, parentElement) {
// NOTE: Wait for https://github.com/thefrontside/bigtest/pull/895 to use specification instead
let options = constructor().options;

@@ -5,0 +6,0 @@ return {

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

import { formatMatcher } from './matcher';
import { matcherDescription } from './matcher';
export class Locator {

@@ -8,5 +8,5 @@ constructor(locatorFn, value) {

get description() {
return formatMatcher(this.value);
return matcherDescription(this.value);
}
}
//# sourceMappingURL=locator.js.map
import { escapeHtml } from './escape-html';
import { applyMatcher, formatMatcher } from './matcher';
import { applyMatcher, matcherDescription } from './matcher';
const check = (value) => value ? "✓" : "⨯";

@@ -23,3 +23,3 @@ export class Match {

if (this.matchLocator) {
return [this.matchLocator.format(), ...this.matchFilter.asTableRow()];
return [this.matchLocator.description(), ...this.matchFilter.asTableRow()];
}

@@ -53,3 +53,3 @@ else {

}
format() {
description() {
return `${check(this.matches)} ${this.formatActual()}`;

@@ -71,3 +71,3 @@ }

asTableRow() {
return this.items.map((f) => f.format());
return this.items.map((f) => f.description());
}

@@ -105,5 +105,5 @@ get sortWeight() {

formatExpected() {
return formatMatcher(this.expected);
return matcherDescription(this.expected);
}
format() {
description() {
return `${check(this.matches)} ${this.formatActual()}`;

@@ -110,0 +110,0 @@ }

import isEqual from 'lodash.isequal';
export function isMatcher(value) {
return value && typeof value.match === 'function' && typeof value.description === 'function';
}
export function isDeprecatedMatcher(value) {
return value && typeof value.match === 'function' && typeof value.format === 'function';
}
export function formatMatcher(value) {
export function matcherDescription(value) {
if (isMatcher(value)) {
return value.description();
}
else if (isDeprecatedMatcher(value)) {
console.warn('DEPRECATION: format() is deprecated, use description() instead');
return value.format();

@@ -14,3 +21,3 @@ }

export function applyMatcher(value, actual) {
if (isMatcher(value)) {
if (isMatcher(value) || isDeprecatedMatcher(value)) {
return value.match(actual);

@@ -17,0 +24,0 @@ }

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

import { formatMatcher, applyMatcher } from '../matcher';
import { matcherDescription, applyMatcher } from '../matcher';
export function and(...args) {

@@ -7,4 +7,4 @@ return {

},
format() {
return args.map(formatMatcher).join(' and ');
description() {
return args.map(matcherDescription).join(' and ');
},

@@ -11,0 +11,0 @@ };

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

import { applyMatcher, formatMatcher } from '../matcher';
import { applyMatcher, matcherDescription } from '../matcher';
export function every(expected) {

@@ -7,4 +7,4 @@ return {

},
format() {
return `every item ${formatMatcher(expected)}`;
description() {
return `every item ${matcherDescription(expected)}`;
},

@@ -11,0 +11,0 @@ };

@@ -6,3 +6,3 @@ export function including(subString) {

},
format() {
description() {
return `including ${JSON.stringify(subString)}`;

@@ -9,0 +9,0 @@ },

@@ -6,3 +6,3 @@ export function matching(regexp) {

},
format() {
description() {
return `matching ${regexp}`;

@@ -9,0 +9,0 @@ },

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

import { formatMatcher, applyMatcher } from '../matcher';
import { matcherDescription, applyMatcher } from '../matcher';
export function not(matcher) {

@@ -7,4 +7,4 @@ return {

},
format() {
return `not ${formatMatcher(matcher)}`;
description() {
return `not ${matcherDescription(matcher)}`;
},

@@ -11,0 +11,0 @@ };

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

import { formatMatcher, applyMatcher } from '../matcher';
import { matcherDescription, applyMatcher } from '../matcher';
export function or(...args) {

@@ -7,4 +7,4 @@ return {

},
format() {
return args.map(formatMatcher).join(' or ');
description() {
return args.map(matcherDescription).join(' or ');
},

@@ -11,0 +11,0 @@ };

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

import { applyMatcher, formatMatcher } from '../matcher';
import { applyMatcher, matcherDescription } from '../matcher';
export function some(expected) {

@@ -7,4 +7,4 @@ return {

},
format() {
return `some item ${formatMatcher(expected)}`;
description() {
return `some item ${matcherDescription(expected)}`;
},

@@ -11,0 +11,0 @@ };

@@ -7,2 +7,3 @@ export { Interactor, InteractorSpecificationBuilder, InteractorConstructor, InteractorBuilder, InteractorSpecification } from './specification';

export { App } from './app';
export { read } from './read';
export { perform } from './perform';

@@ -9,0 +10,0 @@ export { fillIn } from './fill-in';

@@ -26,3 +26,3 @@ import { Locator } from './locator';

formatActual(): string;
format(): string;
description(): string;
get sortWeight(): number;

@@ -50,3 +50,3 @@ }

formatExpected(): string;
format(): string;
description(): string;
formatAsExpectation(): string;

@@ -53,0 +53,0 @@ get sortWeight(): number;

@@ -1,9 +0,17 @@

export interface Matcher<T> {
export declare type Matcher<T> = NewMatcher<T> | OldMatcher<T>;
export interface NewMatcher<T> {
match(actual: T): boolean;
description(): string;
format?(): never;
}
export interface OldMatcher<T> {
match(actual: T): boolean;
format(): string;
description?(): never;
}
export declare type MaybeMatcher<T> = Matcher<T> | T;
export declare function isMatcher<T>(value: MaybeMatcher<T>): value is Matcher<T>;
export declare function formatMatcher<T>(value: MaybeMatcher<T>): string;
export declare function isMatcher<T>(value: MaybeMatcher<T>): value is NewMatcher<T>;
export declare function isDeprecatedMatcher<T>(value: MaybeMatcher<T>): value is OldMatcher<T>;
export declare function matcherDescription<T>(value: MaybeMatcher<T>): string;
export declare function applyMatcher<T>(value: MaybeMatcher<T>, actual: T): boolean;
//# sourceMappingURL=matcher.d.ts.map

@@ -31,4 +31,4 @@ import { Interaction } from './interaction';

export declare const Page: import("./specification").Interactor<Element, {
title?: string | import("./matcher").Matcher<string> | undefined;
url?: string | import("./matcher").Matcher<string> | undefined;
title?: string | import("./matcher").NewMatcher<string> | import("./matcher").OldMatcher<string> | undefined;
url?: string | import("./matcher").NewMatcher<string> | import("./matcher").OldMatcher<string> | undefined;
}> & import("./specification").ActionMethods<Element, Record<never, never>> & {

@@ -35,0 +35,0 @@ visit(path?: string): Interaction<void>;

@@ -158,2 +158,5 @@ import { Filter } from './filter';

};
export declare type FilterReturn<F> = {
[P in keyof F]?: F[P] extends MaybeMatcher<infer T> ? T : never;
};
export declare type FilterParams<E extends Element, F extends Filters<E>> = keyof F extends never ? never : {

@@ -160,0 +163,0 @@ [P in keyof F]?: F[P] extends FilterFn<infer TArg, E> ? MaybeMatcher<TArg> : F[P] extends FilterObject<infer TArg, E> ? MaybeMatcher<TArg> : never;

{
"name": "@bigtest/interactor",
"version": "0.28.2-48be5e74",
"version": "0.28.2-48ce3532",
"description": "Interactors for working with applications",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",

@@ -41,2 +41,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

function findMatches(parentElement: Element, interactor: InteractorOptions<any, any, any>): Match<Element, any>[] {
if (!interactor.name) {
throw new Error('An interactor used for this test was not given a label. Please provide a name for your interactor:\n\tHTML.extend(\'my interactor\') || createInteractor(\'my interactor\')');
}
return findElements(parentElement, interactor).map((e) => new Match(e, interactor.filter, interactor.locator));

@@ -113,3 +116,3 @@ }

function unsafeSyncResolveUnique<E extends Element>(options: InteractorOptions<E, any, any>): E {
export function unsafeSyncResolveUnique<E extends Element>(options: InteractorOptions<E, any, any>): E {
return resolveUnique(unsafeSyncResolveParent(options), options) as E;

@@ -116,0 +119,0 @@ }

import { isVisible } from 'element-is-visible';
import { dispatchClick } from '../dispatch';
import { FormField } from './form-field';

@@ -8,2 +9,3 @@

checked: (element) => element.checked,
indeterminate: (element) => element.indeterminate,
visible: {

@@ -15,5 +17,20 @@ apply: (element) => isVisible(element) || (element.labels && Array.from(element.labels).some(isVisible)),

.actions({
check: ({ perform }) => perform((element) => { if(!element.checked) element.click(); }),
uncheck: ({ perform }) => perform((element) => { if(element.checked) element.click(); }),
toggle: ({ perform }) => perform((element) => { element.click(); }),
check: ({ perform }) => perform((element) => {
if((!element.checked || element.indeterminate))
if (dispatchClick(element))
element.indeterminate = false;
}),
uncheck: ({ perform }) => perform((element) => {
if((element.checked || element.indeterminate))
if (dispatchClick(element))
element.indeterminate = false;
}),
toggle: ({ perform }) => perform((element) => {
if (dispatchClick(element))
element.indeterminate = false;
}),
click: ({ perform }) => perform((element) => {
if (dispatchClick(element))
element.indeterminate = false;
}),
})

@@ -43,2 +60,3 @@

* - `checked`: *boolean* – Filter by whether the checkbox is checked.
* - `indeterminate`: *boolean* - Filter by whether the checkbox has indeterminate state.
* - `disabled`: *boolean* – Filter by whether the checkbox is disabled. Defaults to `false`.

@@ -45,0 +63,0 @@ * - `focused`: *boolean* – Filter by whether the checkbox is focused. See {@link focused}.

@@ -27,3 +27,3 @@ import { fillIn } from '../index';

*
* The text fied is located by the text of its label.
* The text field is located by the text of its label.
*

@@ -30,0 +30,0 @@ * ### Example

@@ -20,1 +20,6 @@ export function dispatchChange(element: HTMLElement): boolean {

}
export function dispatchClick(element: HTMLElement, options: MouseEventInit = {}): boolean {
let MouseEvent = element.ownerDocument.defaultView?.MouseEvent || window.MouseEvent;
return element.dispatchEvent(new MouseEvent('click', Object.assign({ bubbles: true, cancelable: true }, options)));
}
import { Filters, FilterFn, FilterObject, FilterParams, InteractorSpecification } from './specification';
import { noCase } from 'change-case';
import { formatMatcher } from './matcher';
import { matcherDescription } from './matcher';

@@ -25,3 +25,3 @@ export class Filter<E extends Element, F extends Filters<E>> {

} else {
return `with ${noCase(key)} ${formatMatcher(value)}`
return `with ${noCase(key)} ${matcherDescription(value)}`
}

@@ -44,4 +44,4 @@ }).join(' and ');

asTableHeader(): string[] {
return Object.entries(this.all).map(([key, value]) => `${key}: ${formatMatcher(value)}`);
return Object.entries(this.all).map(([key, value]) => `${key}: ${matcherDescription(value)}`);
}
}

@@ -7,2 +7,3 @@ export { Interactor, InteractorSpecificationBuilder, InteractorConstructor, InteractorBuilder, InteractorSpecification } from './specification';

export { App } from './app';
export { read } from './read';
export { perform } from './perform';

@@ -9,0 +10,0 @@ export { fillIn } from './fill-in';

@@ -26,2 +26,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

): Inspector<IC> {
// NOTE: Wait for https://github.com/thefrontside/bigtest/pull/895 to use specification instead
let options = constructor().options as ReturnType<IC>['options']

@@ -28,0 +29,0 @@ return {

import { LocatorFn } from './specification';
import { formatMatcher, MaybeMatcher } from './matcher';
import { matcherDescription, MaybeMatcher } from './matcher';

@@ -8,4 +8,4 @@ export class Locator<E extends Element> {

get description(): string {
return formatMatcher(this.value);
return matcherDescription(this.value);
}
}

@@ -5,3 +5,3 @@ import { Locator } from './locator';

import { escapeHtml } from './escape-html';
import { MaybeMatcher, applyMatcher, formatMatcher } from './matcher';
import { MaybeMatcher, applyMatcher, matcherDescription } from './matcher';

@@ -35,3 +35,3 @@ const check = (value: unknown): string => value ? "✓" : "⨯";

if(this.matchLocator) {
return [this.matchLocator.format(), ...this.matchFilter.asTableRow()]
return [this.matchLocator.description(), ...this.matchFilter.asTableRow()]
} else {

@@ -73,3 +73,3 @@ return this.matchFilter.asTableRow();

format(): string {
description(): string {
return `${check(this.matches)} ${this.formatActual()}`;

@@ -98,3 +98,3 @@ }

asTableRow(): string[] {
return this.items.map((f) => f.format());
return this.items.map((f) => f.description());
}

@@ -139,6 +139,6 @@

formatExpected(): string {
return formatMatcher(this.expected);
return matcherDescription(this.expected);
}
format(): string {
description(): string {
return `${check(this.matches)} ${this.formatActual()}`;

@@ -145,0 +145,0 @@ }

import isEqual from 'lodash.isequal';
export interface Matcher<T> {
export type Matcher<T> = NewMatcher<T> | OldMatcher<T>;
export interface NewMatcher<T> {
match(actual: T): boolean;
description(): string;
format?(): never;
}
export interface OldMatcher<T> {
match(actual: T): boolean;
format(): string;
description?(): never;
}

@@ -10,8 +19,15 @@

export function isMatcher<T>(value: MaybeMatcher<T>): value is Matcher<T> {
return value && typeof (value as Matcher<T>).match === 'function' && typeof (value as Matcher<T>).format === 'function';
export function isMatcher<T>(value: MaybeMatcher<T>): value is NewMatcher<T> {
return value && typeof (value as NewMatcher<T>).match === 'function' && typeof (value as NewMatcher<T>).description === 'function';
}
export function formatMatcher<T>(value: MaybeMatcher<T>): string {
export function isDeprecatedMatcher<T>(value: MaybeMatcher<T>): value is OldMatcher<T> {
return value && typeof (value as OldMatcher<T>).match === 'function' && typeof (value as OldMatcher<T>).format === 'function';
}
export function matcherDescription<T>(value: MaybeMatcher<T>): string {
if(isMatcher(value)) {
return value.description();
} else if (isDeprecatedMatcher(value)) {
console.warn('DEPRECATION: format() is deprecated, use description() instead')
return value.format();

@@ -24,3 +40,3 @@ } else {

export function applyMatcher<T>(value: MaybeMatcher<T>, actual: T): boolean {
if(isMatcher(value)) {
if(isMatcher(value) || isDeprecatedMatcher(value)) {
return value.match(actual);

@@ -27,0 +43,0 @@ } else {

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

import { Matcher, MaybeMatcher, formatMatcher, applyMatcher } from '../matcher';
import { Matcher, MaybeMatcher, matcherDescription, applyMatcher } from '../matcher';

@@ -8,6 +8,6 @@ export function and<T>(...args: MaybeMatcher<T>[]): Matcher<T> {

},
format(): string {
return args.map(formatMatcher).join(' and ');
description(): string {
return args.map(matcherDescription).join(' and ');
},
}
}

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

import { Matcher, MaybeMatcher, applyMatcher, formatMatcher } from '../matcher';
import { Matcher, MaybeMatcher, applyMatcher, matcherDescription } from '../matcher';

@@ -8,6 +8,6 @@ export function every<T>(expected: MaybeMatcher<T>): Matcher<Iterable<T>> {

},
format(): string {
return `every item ${formatMatcher(expected)}`;
description(): string {
return `every item ${matcherDescription(expected)}`;
},
}
}

@@ -8,3 +8,3 @@ import { Matcher } from '../matcher';

},
format(): string {
description(): string {
return `including ${JSON.stringify(subString)}`;

@@ -11,0 +11,0 @@ },

@@ -8,3 +8,3 @@ import { Matcher } from '../matcher';

},
format(): string {
description(): string {
return `matching ${regexp}`;

@@ -11,0 +11,0 @@ },

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

import { Matcher, MaybeMatcher, formatMatcher, applyMatcher } from '../matcher';
import { Matcher, MaybeMatcher, matcherDescription, applyMatcher } from '../matcher';

@@ -8,6 +8,6 @@ export function not<T>(matcher: MaybeMatcher<T>): Matcher<T> {

},
format(): string {
return `not ${formatMatcher(matcher)}`;
description(): string {
return `not ${matcherDescription(matcher)}`;
},
}
}

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

import { Matcher, MaybeMatcher, formatMatcher, applyMatcher } from '../matcher';
import { Matcher, MaybeMatcher, matcherDescription, applyMatcher } from '../matcher';

@@ -8,6 +8,6 @@ export function or<T>(...args: MaybeMatcher<T>[]): Matcher<T> {

},
format(): string {
return args.map(formatMatcher).join(' or ');
description(): string {
return args.map(matcherDescription).join(' or ');
},
}
}

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

import { Matcher, MaybeMatcher, applyMatcher, formatMatcher } from '../matcher';
import { Matcher, MaybeMatcher, applyMatcher, matcherDescription } from '../matcher';

@@ -8,6 +8,6 @@ export function some<T>(expected: MaybeMatcher<T>): Matcher<Iterable<T>> {

},
format(): string {
return `some item ${formatMatcher(expected)}`;
description(): string {
return `some item ${matcherDescription(expected)}`;
},
}
}

@@ -181,2 +181,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

export type FilterReturn<F> = {
[P in keyof F]?: F[P] extends MaybeMatcher<infer T> ? T : never;
}
export type FilterParams<E extends Element, F extends Filters<E>> = keyof F extends never ? never : {

@@ -183,0 +187,0 @@ [P in keyof F]?:

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc