Socket
Socket
Sign inDemoInstall

@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.2.0 to 0.3.0

dist/locators/byCssClass.d.ts

6

dist/ComponentDriver.d.ts

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

import { IClickOption, IComponentDriver, IComponentDriverOption, IInteractor, LocatorChain, PartName, ScenePart, ScenePartDriver, StepFunction } from './types';
import { IComponentDriver, IComponentDriverOption, IInteractor, LocatorChain, Optional, PartName, ScenePart, ScenePartDriver, StepFunction } from './types';
export declare abstract class ComponentDriver<T extends ScenePart = {}> implements IComponentDriver<T> {

@@ -7,3 +7,3 @@ readonly interactor: IInteractor;

private readonly _parts;
constructor(locator: LocatorChain, interactor: IInteractor, option?: IComponentDriverOption<T>);
constructor(locator: LocatorChain, interactor: IInteractor, option?: Partial<IComponentDriverOption<T>>);
get parts(): ScenePartDriver<T>;

@@ -14,5 +14,5 @@ get locator(): LocatorChain;

getMissingPartNames(partName: PartName<T> | ReadonlyArray<PartName<T>>): Promise<readonly PartName<T>[]>;
click(option?: IClickOption): Promise<void>;
getText(): Promise<Optional<string>>;
abstract get driverName(): string;
}
export declare function getPartFromDefinition<T extends ScenePart>(partDefinition: T, parentLocator: LocatorChain, interactor: IInteractor, option: Partial<IComponentDriverOption<T>>): ScenePartDriver<T>;

@@ -64,6 +64,4 @@ "use strict";

}
click(option) {
return __awaiter(this, void 0, void 0, function* () {
yield this.interactor.click(this._locator, option);
});
getText() {
return this.interactor.getText(this.locator);
}

@@ -70,0 +68,0 @@ }

@@ -1,4 +0,15 @@

export interface IInputDriver<T> {
export interface IFormFieldDriver<T> {
getValue(): Promise<T>;
}
export interface IInputDriver<T> extends IFormFieldDriver<T> {
setValue(value: T): Promise<boolean>;
}
export interface IToggleDriver {
isSelected(): Promise<boolean>;
setSelected(selected: boolean): Promise<void>;
}
export interface IClickOption {
}
export interface IClickableDriver {
click(option?: IClickOption): Promise<void>;
}
export { ComponentDriver } from './ComponentDriver';
export { defaultOnFinishUpdate, defaultStep } from './defaultValues';
export type { IInputDriver } from './driverTypes';
export type { IClickableDriver, IClickOption, IFormFieldDriver, IInputDriver, IToggleDriver } from './driverTypes';
export { TooManyMatchingElementError, TooManyMatchingElementErrorId } from './errors/TooManyMatchingElementError';
export * from './example/types';
export * from './locators/';
export { byDataTestId } from './locators/byDataTestId';
export { TestEngine } from './TestEngine';
export type { IClickOption, IComponentDriverOption, IInteractor, LocatorChain, Nullable, Optional, ScenePart, ScenePartDriver, StepFunction, } from './types';
export type { IComponentDriverOption, IInteractor, LocatorChain, Nullable, Optional, ScenePart, ScenePartDefinition, ScenePartDriver, StepFunction, } from './types';
export * as collectionUtil from './utils/collectionUtil';

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

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.timingUtil = exports.locatorUtil = exports.domUtil = exports.collectionUtil = exports.TestEngine = exports.byDataTestId = exports.TooManyMatchingElementErrorId = exports.TooManyMatchingElementError = exports.defaultStep = exports.defaultOnFinishUpdate = exports.ComponentDriver = void 0;
exports.timingUtil = exports.locatorUtil = exports.domUtil = exports.collectionUtil = exports.TestEngine = exports.TooManyMatchingElementErrorId = exports.TooManyMatchingElementError = exports.defaultStep = exports.defaultOnFinishUpdate = exports.ComponentDriver = void 0;
var ComponentDriver_1 = require("./ComponentDriver");

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

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

@@ -45,0 +43,0 @@ Object.defineProperty(exports, "TestEngine", { enumerable: true, get: function () { return TestEngine_1.TestEngine; } });

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

import { PartLocatorType } from './PartLocatorType';
export declare function byChecked(checked?: boolean): PartLocatorType;
import { LocatorRelativePosition, PartLocatorType } from './PartLocatorType';
export declare function byChecked(checked?: boolean, relative?: LocatorRelativePosition): PartLocatorType;

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

// to implementaiton other than CSS selector
function byChecked(checked = true) {
function byChecked(checked = true, relative = PartLocatorType_1.LocatorRelativePosition.Same) {
let selector = ':checked';

@@ -16,3 +16,3 @@ if (!checked) {

selector,
relative: PartLocatorType_1.LocatorRelativePosition.Same,
relative,
};

@@ -19,0 +19,0 @@ }

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

import 'css.escape';
export declare function byDataTestId(id: string | string[]): string;
import { LocatorRelativePosition, PartLocatorType } from './PartLocatorType';
export declare function byDataTestId(id: string | string[], relativeTo?: LocatorRelativePosition): PartLocatorType;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.byDataTestId = void 0;
require("css.escape");
function byDataTestId(id) {
const PartLocatorType_1 = require("./PartLocatorType");
function byDataTestId(id, relativeTo = PartLocatorType_1.LocatorRelativePosition.Descendent) {
const ids = Array.isArray(id) ? id : [id];
return ids.map((id) => `[data-testid="${id}"]`).join(' ');
const selector = ids.map((idVal) => `[data-testid="${idVal}"]`).join(' ');
return {
type: PartLocatorType_1.LocatorType.Css,
selector,
relative: relativeTo,
};
}
exports.byDataTestId = byDataTestId;
//# sourceMappingURL=byDataTestId.js.map
export { byChecked } from './byChecked';
export { byCssClass } from './byCssClass';
export { byDataTestId } from './byDataTestId';
export { byName } from './byName';
export { byTagName } from './byTagName';
export { byValue } from './byValue';
export { LocatorRelativePosition, LocatorType } from './PartLocatorType';
export type { CssLocator, PartLocatorType } from './PartLocatorType';
export { LocatorRelativePosition, LocatorType } from './PartLocatorType';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocatorType = exports.LocatorRelativePosition = exports.byValue = exports.byName = exports.byDataTestId = exports.byChecked = void 0;
exports.LocatorType = exports.LocatorRelativePosition = exports.byValue = exports.byTagName = exports.byName = exports.byDataTestId = exports.byCssClass = exports.byChecked = void 0;
var byChecked_1 = require("./byChecked");
Object.defineProperty(exports, "byChecked", { enumerable: true, get: function () { return byChecked_1.byChecked; } });
var byCssClass_1 = require("./byCssClass");
Object.defineProperty(exports, "byCssClass", { enumerable: true, get: function () { return byCssClass_1.byCssClass; } });
var byDataTestId_1 = require("./byDataTestId");

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

Object.defineProperty(exports, "byName", { enumerable: true, get: function () { return byName_1.byName; } });
var byTagName_1 = require("./byTagName");
Object.defineProperty(exports, "byTagName", { enumerable: true, get: function () { return byTagName_1.byTagName; } });
var byValue_1 = require("./byValue");

@@ -12,0 +16,0 @@ Object.defineProperty(exports, "byValue", { enumerable: true, get: function () { return byValue_1.byValue; } });

import { ComponentDriver } from './ComponentDriver';
import { IClickOption } from './driverTypes';
import { PartLocatorType } from './locators/PartLocatorType';

@@ -7,2 +8,16 @@ export type StepFunction = (work: () => Promise<void>) => Promise<void>;

export type PartName<T extends ScenePart> = keyof T;
export interface ScenePartDefinition<T extends ScenePart> {
/**
* The locator of the part
*/
locator?: PartLocatorType;
/**
* The class of driver which is used to interact with the element
*/
driver: typeof ComponentDriver<T>;
/**
* Option for the driver
*/
option?: Partial<IComponentDriverOption>;
}
/**

@@ -12,16 +27,3 @@ * Part name to driver definition map

export interface ScenePart {
[partName: string]: {
/**
* Query which is used to locate the element
*/
locator?: PartLocatorType;
/**
* The class of driver which is used to interact with the element
*/
driver: typeof ComponentDriver<any>;
/**
* Option for the driver
*/
option?: Partial<IComponentDriverOption>;
};
[partName: string]: ScenePartDefinition<any>;
}

@@ -32,5 +34,7 @@ export type ScenePartDriver<T extends ScenePart> = {

export type LocatorChain = readonly PartLocatorType[];
export interface IClickOption {
}
export interface IEnterTextOption {
/**
* Append text to the target, default to false
*/
append: boolean;
}

@@ -59,2 +63,6 @@ export interface IInteractor {

isChecked(locator: LocatorChain): Promise<boolean>;
isDisabled(locator: LocatorChain): Promise<boolean>;
isReadonly(locator: LocatorChain): Promise<boolean>;
hasCssClass(locator: LocatorChain, className: string): Promise<boolean>;
hasAttribute(locator: LocatorChain, name: string): Promise<boolean>;
clone(): IInteractor;

@@ -78,2 +86,3 @@ }

getMissingPartNames(partName?: PartName<T> | ReadonlyArray<PartName<T>>): Promise<ReadonlyArray<PartName<T>>>;
getText(): Promise<Optional<string>>;
}

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
document.querySelector('input');
//# sourceMappingURL=types.js.map

@@ -7,1 +7,2 @@ import { PartLocatorType } from '../locators/PartLocatorType';

export declare function toCssSelector(locator: LocatorChain): string;
export declare function getLocatorStatement(locator: PartLocatorType): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toCssSelector = exports.getEffectiveLocator = exports.findRootLocatorIndex = exports.append = void 0;
exports.getLocatorStatement = exports.toCssSelector = exports.getEffectiveLocator = exports.findRootLocatorIndex = exports.append = void 0;
const PartLocatorType_1 = require("../locators/PartLocatorType");

@@ -32,9 +32,5 @@ function append(locator, selector) {

let separator = ' ';
let statement = '';
if (typeof loc === 'string') {
statement = loc;
}
else {
const statement = getLocatorStatement(loc);
if (typeof loc !== 'string') {
const l = loc;
statement = l.selector;
if (l.relative === PartLocatorType_1.LocatorRelativePosition.Same) {

@@ -49,2 +45,14 @@ separator = '';

exports.toCssSelector = toCssSelector;
function getLocatorStatement(locator) {
let statement = '';
if (typeof locator === 'string') {
statement = locator;
}
else {
const l = locator;
statement = l.selector;
}
return statement;
}
exports.getLocatorStatement = getLocatorStatement;
//# sourceMappingURL=locatorUtil.js.map
{
"name": "@atomic-testing/core",
"version": "0.2.0",
"version": "0.3.0",
"description": "",

@@ -10,7 +10,2 @@ "main": "dist/index.js",

],
"scripts": {
"build": "tsc",
"postbuild": "node ../../scripts/postBuild.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Tianzhen Lin <tangent@usa.net>",

@@ -21,3 +16,3 @@ "keywords": [],

"type": "git",
"url": "https://github.com/tangentlin/testzilla.git"
"url": "https://github.com/tangentlin/atomic-testing.git"
},

@@ -35,3 +30,8 @@ "devDependencies": {

},
"peerDependencies": {}
}
"peerDependencies": {},
"scripts": {
"build": "tsc",
"postbuild": "node ../../scripts/postBuild.js",
"test": "echo \"Error: no test specified\" && exit 1"
}
}
import { defaultStep } from './defaultValues';
import { MissingPartError } from './errors/MissingPartError';
import {
IClickOption,
IComponentDriver,

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

LocatorChain,
Optional,
PartName,

@@ -21,3 +21,7 @@ ScenePart,

constructor(locator: LocatorChain, public readonly interactor: IInteractor, option?: IComponentDriverOption<T>) {
constructor(
locator: LocatorChain,
public readonly interactor: IInteractor,
option?: Partial<IComponentDriverOption<T>>,
) {
this._locator = locator;

@@ -71,4 +75,4 @@ this._perform = option?.perform ?? defaultStep;

async click(option?: IClickOption): Promise<void> {
await this.interactor.click(this._locator, option);
getText(): Promise<Optional<string>> {
return this.interactor.getText(this.locator);
}

@@ -75,0 +79,0 @@

@@ -1,4 +0,17 @@

export interface IInputDriver<T> {
export interface IFormFieldDriver<T> {
getValue(): Promise<T>;
}
export interface IInputDriver<T> extends IFormFieldDriver<T> {
setValue(value: T): Promise<boolean>;
}
export interface IToggleDriver {
isSelected(): Promise<boolean>;
setSelected(selected: boolean): Promise<void>;
}
export interface IClickOption {}
export interface IClickableDriver {
click(option?: IClickOption): Promise<void>;
}
export { ComponentDriver } from './ComponentDriver';
export { defaultOnFinishUpdate, defaultStep } from './defaultValues';
export type { IInputDriver } from './driverTypes';
export type { IClickableDriver, IClickOption, IFormFieldDriver, IInputDriver, IToggleDriver } from './driverTypes';
export { TooManyMatchingElementError, TooManyMatchingElementErrorId } from './errors/TooManyMatchingElementError';
export * from './example/types';
export * from './locators/';
export { byDataTestId } from './locators/byDataTestId';
export { TestEngine } from './TestEngine';
export type {
IClickOption,
IComponentDriverOption,

@@ -17,2 +15,3 @@ IInteractor,

ScenePart,
ScenePartDefinition,
ScenePartDriver,

@@ -19,0 +18,0 @@ StepFunction,

@@ -6,3 +6,6 @@ // TODO: Use descriptive selector instead of css selector so the selector can be reintepreted

// to implementaiton other than CSS selector
export function byChecked(checked = true): PartLocatorType {
export function byChecked(
checked = true,
relative: LocatorRelativePosition = LocatorRelativePosition.Same,
): PartLocatorType {
let selector = ':checked';

@@ -15,4 +18,4 @@ if (!checked) {

selector,
relative: LocatorRelativePosition.Same,
relative,
};
}

@@ -1,6 +0,15 @@

import 'css.escape';
import { LocatorRelativePosition, LocatorType, PartLocatorType } from './PartLocatorType';
export function byDataTestId(id: string | string[]): string {
export function byDataTestId(
id: string | string[],
relativeTo: LocatorRelativePosition = LocatorRelativePosition.Descendent,
): PartLocatorType {
const ids = Array.isArray(id) ? id : [id];
return ids.map((id) => `[data-testid="${id}"]`).join(' ');
const selector = ids.map((idVal) => `[data-testid="${idVal}"]`).join(' ');
return {
type: LocatorType.Css,
selector,
relative: relativeTo,
};
}
export { byChecked } from './byChecked';
export { byCssClass } from './byCssClass';
export { byDataTestId } from './byDataTestId';
export { byName } from './byName';
export { byTagName } from './byTagName';
export { byValue } from './byValue';
export type { CssLocator, PartLocatorType } from './PartLocatorType';
export { LocatorRelativePosition, LocatorType } from './PartLocatorType';
import { ComponentDriver } from './ComponentDriver';
import { IClickOption } from './driverTypes';
import { PartLocatorType } from './locators/PartLocatorType';

@@ -10,2 +11,19 @@

export interface ScenePartDefinition<T extends ScenePart> {
/**
* The locator of the part
*/
locator?: PartLocatorType;
/**
* The class of driver which is used to interact with the element
*/
driver: typeof ComponentDriver<T>;
/**
* Option for the driver
*/
option?: Partial<IComponentDriverOption>;
}
/**

@@ -15,18 +33,3 @@ * Part name to driver definition map

export interface ScenePart {
[partName: string]: {
/**
* Query which is used to locate the element
*/
locator?: PartLocatorType;
/**
* The class of driver which is used to interact with the element
*/
driver: typeof ComponentDriver<any>;
/**
* Option for the driver
*/
option?: Partial<IComponentDriverOption>;
};
[partName: string]: ScenePartDefinition<any>;
}

@@ -40,8 +43,16 @@

export interface IClickOption {}
export interface IEnterTextOption {}
export interface IEnterTextOption {
/**
* Append text to the target, default to false
*/
append: boolean;
}
document.querySelector('input');
export interface IInteractor {
//#region Potentially DOM mutative interactions
/**
* Click on the desired element
* @param locator
* @param option
*/
click(locator: LocatorChain, option?: Partial<IClickOption>): Promise<void>;

@@ -57,4 +68,4 @@

/**
*
* @param locator Select option by value from a select element
* Select option by value from a select element
* @param locator
* @param values

@@ -64,2 +75,10 @@ */

/**
* Perform a mouse hover on the desired element
* @param locator
*/
hover(locator: LocatorChain): Promise<void>;
//#endregion
//#region Read only interactions
getInputValue(locator: LocatorChain): Promise<Optional<string>>;

@@ -75,3 +94,9 @@ getSelectValues(locator: LocatorChain): Promise<Optional<readonly string[]>>;

isChecked(locator: LocatorChain): Promise<boolean>;
isDisabled(locator: LocatorChain): Promise<boolean>;
isReadonly(locator: LocatorChain): Promise<boolean>;
hasCssClass(locator: LocatorChain, className: string): Promise<boolean>;
hasAttribute(locator: LocatorChain, name: string): Promise<boolean>;
//#endregion
clone(): IInteractor;

@@ -100,2 +125,4 @@ }

getMissingPartNames(partName?: PartName<T> | ReadonlyArray<PartName<T>>): Promise<ReadonlyArray<PartName<T>>>;
getText(): Promise<Optional<string>>;
}

@@ -102,0 +129,0 @@

@@ -32,8 +32,5 @@ import { CssLocator, LocatorRelativePosition, PartLocatorType } from '../locators/PartLocatorType';

let separator = ' ';
let statement = '';
if (typeof loc === 'string') {
statement = loc;
} else {
const statement = getLocatorStatement(loc);
if (typeof loc !== 'string') {
const l = loc as CssLocator;
statement = l.selector;
if (l.relative === LocatorRelativePosition.Same) {

@@ -49,1 +46,13 @@ separator = '';

}
export function getLocatorStatement(locator: PartLocatorType): string {
let statement = '';
if (typeof locator === 'string') {
statement = locator;
} else {
const l = locator as CssLocator;
statement = l.selector;
}
return statement;
}

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