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

@atomic-testing/core

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atomic-testing/core - npm Package Compare versions

Comparing version 0.24.0 to 0.25.0

dist/drivers/driverHelper.d.ts

31

dist/drivers/ComponentDriver.d.ts

@@ -10,2 +10,9 @@ import { Optional } from '../dataTypes';

private readonly _parts;
/**
* Option passed to the constructor includes both universal options which can be shared across
* all component driver tree, and component specific options which are only applicable to the component.
*
* Commutable option is the option that can be shared across all component driver tree.
*/
readonly commutableOption: IComponentDriverOption<T>;
constructor(locator: LocatorChain, interactor: Interactor, option?: Partial<IComponentDriverOption<T>>);

@@ -34,6 +41,26 @@ /**

overrideLocatorRelativePosition(): Optional<LocatorRelativePosition>;
/**
* Return driver instance of all the named parts
*/
get parts(): ScenePartDriver<T>;
/**
* Return the locator of the component
*/
get locator(): LocatorChain;
enforcePartExistence(partName: PartName<T> | ReadonlyArray<PartName<T>>): Promise<void>;
getMissingPartNames(partName: PartName<T> | ReadonlyArray<PartName<T>>): Promise<readonly PartName<T>[]>;
/**
* Check the specified parts' existences, and throw MissPartError if any of the part is found not existence.
* Existence is defined by the part's existence in the DOM regardless of its visibility on the screen
* @param partName Single or array of the names of the parts to be enforced
*/
protected enforcePartExistence(partName: PartName<T> | ReadonlyArray<PartName<T>>): Promise<void>;
/**
* Get the names of parts not in the DOM
* @param partName Single or array of the names of the parts to be examined
* @returns
*/
protected getMissingPartNames(partName: PartName<T> | ReadonlyArray<PartName<T>>): Promise<readonly PartName<T>[]>;
/**
* Get the combined text content of the component
* @returns If the component exists and has content, it should return the text or otherwise undefined
*/
getText(): Promise<Optional<string>>;

@@ -40,0 +67,0 @@ /**

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

this._parts = (0, driverUtil_1.getPartFromDefinition)((_a = option === null || option === void 0 ? void 0 : option.parts) !== null && _a !== void 0 ? _a : {}, this._locator, interactor, option !== null && option !== void 0 ? option : {});
this.commutableOption = Object.assign(Object.assign({}, option), { parts: {} });
}

@@ -75,8 +76,19 @@ /**

}
/**
* Return driver instance of all the named parts
*/
get parts() {
return this._parts;
}
/**
* Return the locator of the component
*/
get locator() {
return this._locator;
}
/**
* Check the specified parts' existences, and throw MissPartError if any of the part is found not existence.
* Existence is defined by the part's existence in the DOM regardless of its visibility on the screen
* @param partName Single or array of the names of the parts to be enforced
*/
enforcePartExistence(partName) {

@@ -91,2 +103,7 @@ return __awaiter(this, void 0, void 0, function* () {

}
/**
* Get the names of parts not in the DOM
* @param partName Single or array of the names of the parts to be examined
* @returns
*/
getMissingPartNames(partName) {

@@ -115,2 +132,6 @@ return __awaiter(this, void 0, void 0, function* () {

}
/**
* Get the combined text content of the component
* @returns If the component exists and has content, it should return the text or otherwise undefined
*/
getText() {

@@ -117,0 +138,0 @@ return this.interactor.getText(this.locator);

3

dist/drivers/index.d.ts
export { ComponentDriver } from './ComponentDriver';
export { ContainerDriver } from './ContainerDriver';
export * as driverHelper from './driverHelper';
export type { IClickableDriver, IFormFieldDriver, IInputDriver, IToggleDriver } from './driverTypes';
export * from './WaitForOption';
export type { IClickableDriver, IFormFieldDriver, IInputDriver, IToggleDriver } from './driverTypes';

@@ -13,2 +13,14 @@ "use strict";

}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {

@@ -18,3 +30,3 @@ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);

Object.defineProperty(exports, "__esModule", { value: true });
exports.ContainerDriver = exports.ComponentDriver = void 0;
exports.driverHelper = exports.ContainerDriver = exports.ComponentDriver = void 0;
var ComponentDriver_1 = require("./ComponentDriver");

@@ -24,3 +36,4 @@ Object.defineProperty(exports, "ComponentDriver", { enumerable: true, get: function () { return ComponentDriver_1.ComponentDriver; } });

Object.defineProperty(exports, "ContainerDriver", { enumerable: true, get: function () { return ContainerDriver_1.ContainerDriver; } });
exports.driverHelper = __importStar(require("./driverHelper"));
__exportStar(require("./WaitForOption"), exports);
//# sourceMappingURL=index.js.map

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

export { TestEngine } from './TestEngine';
export type { Nullable, Optional } from './dataTypes';

@@ -9,2 +8,3 @@ export * from './drivers';

export type { IComponentDriverOption, IContainerDriverOption, ScenePart, ScenePartDefinition, ScenePartDriver, } from './partTypes';
export { TestEngine } from './TestEngine';
export * as collectionUtil from './utils/collectionUtil';

@@ -11,0 +11,0 @@ export * as domUtil from './utils/domUtil';

@@ -30,4 +30,2 @@ "use strict";

exports.timingUtil = exports.locatorUtil = exports.escapeUtil = exports.domUtil = exports.collectionUtil = exports.TestEngine = void 0;
var TestEngine_1 = require("./TestEngine");
Object.defineProperty(exports, "TestEngine", { enumerable: true, get: function () { return TestEngine_1.TestEngine; } });
__exportStar(require("./drivers"), exports);

@@ -37,2 +35,4 @@ __exportStar(require("./errors"), exports);

__exportStar(require("./locators/"), exports);
var TestEngine_1 = require("./TestEngine");
Object.defineProperty(exports, "TestEngine", { enumerable: true, get: function () { return TestEngine_1.TestEngine; } });
exports.collectionUtil = __importStar(require("./utils/collectionUtil"));

@@ -39,0 +39,0 @@ exports.domUtil = __importStar(require("./utils/domUtil"));

import { Optional } from './dataTypes';
import { ComponentDriver } from './drivers/ComponentDriver';
import { ContainerDriver } from './drivers/ContainerDriver';
import { WaitForOption } from './drivers/WaitForOption';
import { LocatorChain } from './locators/LocatorChain';

@@ -51,2 +52,5 @@ import { PartLocatorType } from './locators/PartLocatorType';

export interface IComponentDriver<T extends ScenePart = {}> {
/**
* Return driver instance of all the named parts
*/
readonly parts: ScenePartDriver<T>;

@@ -57,5 +61,33 @@ /**

readonly locator: LocatorChain;
enforcePartExistence(partName: PartName<T> | ReadonlyArray<PartName<T>>): Promise<void>;
getMissingPartNames(partName?: PartName<T> | ReadonlyArray<PartName<T>>): Promise<ReadonlyArray<PartName<T>>>;
/**
* Get the combined text content of the component
* @returns If the component exists and has content, it should return the text or otherwise undefined
*/
getText(): Promise<Optional<string>>;
/**
* Whether the component exists/attached to the DOM
* @returns true if the component is attached to the DOM, false otherwise
*/
exists(): Promise<boolean>;
/**
* Whether the component is visible. Visibility is defined
* that the component does not have the CSS property `display: none`,
* `visibility: hidden`, or `opacity: 0`. However this does not
* check wether the component is within the viewport.
*
* @returns true if the component is visible, false otherwise
*/
isVisible(): Promise<boolean>;
/**
* Wait until the component is in the expected state such as
* the component's visibility or existence. If the component has
* not reached the expected state within the timeout, it will throw
* an error.
*
* By default it waits until the component is attached to the DOM
* within 30 seconds.
*
* @param option The option to configure the wait behavior
*/
waitUntil(option?: Partial<Readonly<WaitForOption>>): Promise<void>;
}

@@ -62,0 +94,0 @@ export interface ITestEngine<T extends ScenePart = {}> extends IComponentDriver<T> {

import type { LocatorChain } from '../locators/LocatorChain';
import { LocatorRelativePosition, PartLocatorType } from '../locators/PartLocatorType';
export declare function append(locator: Readonly<LocatorChain> | Readonly<PartLocatorType>, selector: PartLocatorType): LocatorChain;
export declare function append(locatorBase: Readonly<LocatorChain> | Readonly<PartLocatorType>, ...locatorsToAppend: (PartLocatorType | Readonly<LocatorChain>)[]): LocatorChain;
export declare function findRootLocatorIndex(locator: LocatorChain): number;

@@ -5,0 +5,0 @@ export declare function getEffectiveLocator(locator: LocatorChain): LocatorChain;

@@ -5,5 +5,8 @@ "use strict";

const PartLocatorType_1 = require("../locators/PartLocatorType");
function append(locator, selector) {
const baseLocator = Array.isArray(locator) ? locator : [locator];
return baseLocator.concat(selector);
function append(locatorBase, ...locatorsToAppend) {
const baseLocator = Array.isArray(locatorBase) ? locatorBase : [locatorBase];
const toAppend = locatorsToAppend.reduce((acc, locator) => {
return acc.concat(locator);
}, []);
return baseLocator.concat(toAppend);
}

@@ -10,0 +13,0 @@ exports.append = append;

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

}
yield wait(nextStart - currentTime);
yield wait(nextStart);
}

@@ -61,0 +61,0 @@ return val;

{
"name": "@atomic-testing/core",
"version": "0.24.0",
"version": "0.25.0",
"description": "Core library for atomic-testing",

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

@@ -15,2 +15,10 @@ import { Optional } from '../dataTypes';

/**
* Option passed to the constructor includes both universal options which can be shared across
* all component driver tree, and component specific options which are only applicable to the component.
*
* Commutable option is the option that can be shared across all component driver tree.
*/
public readonly commutableOption: IComponentDriverOption<T>;
constructor(

@@ -23,2 +31,6 @@ locator: LocatorChain,

this._parts = getPartFromDefinition<T>(option?.parts ?? ({} as T), this._locator, interactor, option ?? {});
this.commutableOption = {
...option,
parts: {} as T,
};
}

@@ -54,2 +66,5 @@

/**
* Return driver instance of all the named parts
*/
get parts(): ScenePartDriver<T> {

@@ -59,2 +74,5 @@ return this._parts;

/**
* Return the locator of the component
*/
get locator(): LocatorChain {

@@ -64,3 +82,8 @@ return this._locator;

async enforcePartExistence(partName: PartName<T> | ReadonlyArray<PartName<T>>): Promise<void> {
/**
* Check the specified parts' existences, and throw MissPartError if any of the part is found not existence.
* Existence is defined by the part's existence in the DOM regardless of its visibility on the screen
* @param partName Single or array of the names of the parts to be enforced
*/
protected async enforcePartExistence(partName: PartName<T> | ReadonlyArray<PartName<T>>): Promise<void> {
const missingPartNames = await this.getMissingPartNames(partName);

@@ -73,3 +96,10 @@ if (missingPartNames.length > 0) {

async getMissingPartNames(partName: PartName<T> | ReadonlyArray<PartName<T>>): Promise<readonly PartName<T>[]> {
/**
* Get the names of parts not in the DOM
* @param partName Single or array of the names of the parts to be examined
* @returns
*/
protected async getMissingPartNames(
partName: PartName<T> | ReadonlyArray<PartName<T>>,
): Promise<readonly PartName<T>[]> {
let partNames: ReadonlyArray<keyof T>;

@@ -97,2 +127,6 @@ if (partName == null) {

/**
* Get the combined text content of the component
* @returns If the component exists and has content, it should return the text or otherwise undefined
*/
getText(): Promise<Optional<string>> {

@@ -99,0 +133,0 @@ return this.interactor.getText(this.locator);

export { ComponentDriver } from './ComponentDriver';
export { ContainerDriver } from './ContainerDriver';
export * as driverHelper from './driverHelper';
export type { IClickableDriver, IFormFieldDriver, IInputDriver, IToggleDriver } from './driverTypes';
export * from './WaitForOption';
export type { IClickableDriver, IFormFieldDriver, IInputDriver, IToggleDriver } from './driverTypes';

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

export { TestEngine } from './TestEngine';
export type { Nullable, Optional } from './dataTypes';

@@ -15,2 +14,3 @@ export * from './drivers';

} from './partTypes';
export { TestEngine } from './TestEngine';
export * as collectionUtil from './utils/collectionUtil';

@@ -17,0 +17,0 @@ export * as domUtil from './utils/domUtil';

import { Optional } from './dataTypes';
import { ComponentDriver } from './drivers/ComponentDriver';
import { ContainerDriver } from './drivers/ContainerDriver';
import { WaitForOption } from './drivers/WaitForOption';
import { LocatorChain } from './locators/LocatorChain';

@@ -64,2 +65,5 @@ import { PartLocatorType } from './locators/PartLocatorType';

export interface IComponentDriver<T extends ScenePart = {}> {
/**
* Return driver instance of all the named parts
*/
readonly parts: ScenePartDriver<T>;

@@ -72,6 +76,36 @@

enforcePartExistence(partName: PartName<T> | ReadonlyArray<PartName<T>>): Promise<void>;
getMissingPartNames(partName?: PartName<T> | ReadonlyArray<PartName<T>>): Promise<ReadonlyArray<PartName<T>>>;
/**
* Get the combined text content of the component
* @returns If the component exists and has content, it should return the text or otherwise undefined
*/
getText(): Promise<Optional<string>>;
getText(): Promise<Optional<string>>;
/**
* Whether the component exists/attached to the DOM
* @returns true if the component is attached to the DOM, false otherwise
*/
exists(): Promise<boolean>;
/**
* Whether the component is visible. Visibility is defined
* that the component does not have the CSS property `display: none`,
* `visibility: hidden`, or `opacity: 0`. However this does not
* check wether the component is within the viewport.
*
* @returns true if the component is visible, false otherwise
*/
isVisible(): Promise<boolean>;
/**
* Wait until the component is in the expected state such as
* the component's visibility or existence. If the component has
* not reached the expected state within the timeout, it will throw
* an error.
*
* By default it waits until the component is attached to the DOM
* within 30 seconds.
*
* @param option The option to configure the wait behavior
*/
waitUntil(option?: Partial<Readonly<WaitForOption>>): Promise<void>;
}

@@ -78,0 +112,0 @@

@@ -5,7 +5,11 @@ import type { LocatorChain } from '../locators/LocatorChain';

export function append(
locator: Readonly<LocatorChain> | Readonly<PartLocatorType>,
selector: PartLocatorType,
locatorBase: Readonly<LocatorChain> | Readonly<PartLocatorType>,
...locatorsToAppend: (PartLocatorType | Readonly<LocatorChain>)[]
): LocatorChain {
const baseLocator: LocatorChain = Array.isArray(locator) ? locator : [locator];
return baseLocator.concat(selector);
const baseLocator: LocatorChain = Array.isArray(locatorBase) ? locatorBase : [locatorBase];
const toAppend: PartLocatorType[] = locatorsToAppend.reduce((acc: PartLocatorType[], locator) => {
return acc.concat(locator);
}, []);
return baseLocator.concat(toAppend);
}

@@ -12,0 +16,0 @@

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

const elapsed = currentTime - startMs;
if (elapsed >= timeoutMs) {

@@ -56,4 +57,3 @@ return val;

}
await wait(nextStart - currentTime);
await wait(nextStart);
}

@@ -60,0 +60,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

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