Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
yarn-error.log
/packages/*/dist
/packages/*/build
/packages/*/docs
*.tsbuildinfo
.node-version
Expand Down
21 changes: 21 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"workspace": [
"./packages/core",
"./packages/globals",
"./packages/html",
"./packages/keyboard",
"./packages/material-ui"
],
"compilerOptions": {
"lib": [
"deno.ns",
"esnext",
"dom",
"dom.iterable",
"dom.asynciterable"
]
},
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.3"
}
}
2,831 changes: 2,831 additions & 0 deletions deno.lock

Large diffs are not rendered by default.

56 changes: 0 additions & 56 deletions package.json

This file was deleted.

3 changes: 0 additions & 3 deletions packages/core/.mocharc.json

This file was deleted.

44 changes: 44 additions & 0 deletions packages/core/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "@interactors/core",
"version": "1.0.0",
"tasks": {
"test": "deno test --allow-run=deno --allow-env --allow-read",
"build:npm": "deno run -A tasks/build-npm.ts",
"docs": "rm -rf docs && mkdir -p docs/api/v1 && deno doc --html --output=docs/api/v1 mod.ts"
},
"exports": "./mod.ts",
"imports": {
"@effection/core": "npm:@effection/core@2.2.0",
"@std/expect": "jsr:@std/expect@^1.0.0",
"@std/testing": "jsr:@std/testing@^1.0.0",
"@testing-library/dom": "npm:@testing-library/dom@^8.18.1",
"@testing-library/user-event": "npm:@testing-library/user-event@^14.5.2",
"change-case": "npm:change-case@^4.1.1",
"element-is-visible": "npm:element-is-visible@^1.0.0",
"jsdom": "npm:jsdom@^24.0.0",
"lodash.isequal": "npm:lodash.isequal@^4.5.0",
"performance-api": "npm:performance-api@^1.0.0"
},
"lint": {
"rules": {
"exclude": ["prefer-const", "require-yield", "no-explicit-any"]
},
"exclude": [
"build",
"docs"
]
},
"fmt": {
"exclude": [
"build",
"docs",
"README.md"
]
},
"test": {
"exclude": [
"build",
"docs"
]
}
}
1 change: 1 addition & 0 deletions packages/core/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/index.ts'
63 changes: 10 additions & 53 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,19 @@
{
"name": "@interactors/core",
"version": "1.0.0",
"version": "0.0.0",
"description": "Composable page objects for components",
"main": "dist/cjs/index.js",
"browser": "dist/esm/index.js",
"types": "dist/index.d.ts",
"repository": "https://github.com/thefrontside/interactors.git",
"license": "MIT",
"homepage": "https://frontside.com/interactors",
"author": "Frontside Engineering <engineering@frontside.com>",
"license": "MIT",
"files": [
"dist/**/*",
"src/**/*",
"README.md"
],
"exports": {
".": {
"require": "./dist/cjs/index.js",
"default": "./dist/esm/index.js"
}
},
"scripts": {
"clean": "rm -rf dist *.tsbuildinfo",
"lint": "eslint \"{src,test}/**/*.ts\"",
"check:types": "tsc --noEmit",
"test:unit": "tsx --test --test-reporter spec --no-deprecation test/**/*.test.ts",
"test:types": "tsd -f ./types/*.test-d.ts",
"test": "yarn test:unit && yarn test:types",
"docs": "rm -rf docs && yarn typedoc --options typedoc.json",
"prepack": "tsc --build ./tsconfig.build.json && yarn prepack:es2015 && yarn prepack:commonjs",
"prepack:es2015": "tsc --project ./tsconfig.build.json --outdir dist/esm --module es2015",
"prepack:commonjs": "tsc --project ./tsconfig.build.json --outdir dist/cjs --module commonjs"
"repository": {
"type": "git",
"url": "git+https://github.com/thefrontside/interactors.git"
},
"dependencies": {
"@effection/core": "2.2.0",
"@interactors/globals": "1.0.0",
"@testing-library/dom": "^8.18.1",
"@testing-library/user-event": "^13.2.1",
"change-case": "^4.1.1",
"element-is-visible": "^1.0.0",
"lodash.isequal": "^4.5.0",
"performance-api": "^1.0.0"
"bugs": {
"url": "https://github.com/thefrontside/interactors/issues"
},
"devDependencies": {
"@frontside/tsconfig": "^1.2.0",
"@types/express": "^4.17.6",
"@types/jsdom": "^16.2.3",
"@types/lodash.isequal": "^4.5.5",
"@types/node": "^20.11.25",
"expect": "^24.9.0",
"express": "^4.17.1",
"jsdom": "^24.0.0",
"tsd": "^0.31.0",
"tsx": "^4.7.1",
"typedoc": "^0.25.13",
"typescript": "~5.4.5"
"engines": {
"node": ">= 16"
},
"volta": {
"extends": "../../package.json"
}
"sideEffects": false
}
30 changes: 15 additions & 15 deletions packages/core/src/constructor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import { converge } from './converge';
import { MergeObjects } from './merge-objects';
import {
import { converge } from './converge.ts';
import type { MergeObjects } from './merge-objects.ts';
import type {
InteractorOptions,
ActionMethods,
InteractorConstructor,
Expand All @@ -14,16 +14,16 @@ import {
FilterMethods,
InteractorSpecification,
FilterObject,
} from './specification';
import { FilterSet } from './filter-set';
import { Locator } from './locator';
import { MatchFilter, applyFilter } from './match';
import { formatDescription } from './format';
import { FilterNotMatchingError } from './errors';
import { createInteraction, AssertionInteraction, ActionInteraction } from './interaction';
import { isMatcher } from './matcher';
import { matching } from './matchers/matching';
import { hasMatchMatching, resolveEmpty, resolveFirst, resolveUnique, unsafeSyncResolveParent, unsafeSyncResolveUnique } from './resolvers';
} from './specification.ts';
import { FilterSet } from './filter-set.ts';
import { Locator } from './locator.ts';
import { MatchFilter, applyFilter } from './match.ts';
import { formatDescription } from './format.ts';
import { FilterNotMatchingError } from './errors.ts';
import { createInteraction, type AssertionInteraction, type ActionInteraction } from './interaction.ts';
import { isMatcher } from './matcher.ts';
import { matching } from './matchers/matching.ts';
import { hasMatchMatching, resolveEmpty, resolveFirst, resolveUnique, unsafeSyncResolveParent, unsafeSyncResolveUnique } from './resolvers.ts';

const defaultLocator: FilterDefinition<string, Element> = (element) => element.textContent || "";

Expand Down Expand Up @@ -137,7 +137,7 @@ export function instantiateInteractor<E extends Element, F extends Filters<E>, A
};

for (let [actionName, action] of Object.entries(options.specification.actions || {})) {
if (!interactor.hasOwnProperty(actionName)) {
if (!Object.prototype.hasOwnProperty.call(interactor, actionName)) {
Object.defineProperty(interactor, actionName, {
value: function(...args: unknown[]) {
let actionDescription = actionName;
Expand All @@ -160,7 +160,7 @@ export function instantiateInteractor<E extends Element, F extends Filters<E>, A
}

for (let [filterName, filter] of Object.entries(options.specification.filters || {})) {
if (!interactor.hasOwnProperty(filterName)) {
if (!Object.prototype.hasOwnProperty.call(interactor, filterName)) {
Object.defineProperty(interactor, filterName, {
value: function() {
return createInteraction('assertion', {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/converge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Operation, sleep } from '@effection/core';
import { type Operation, sleep } from '@effection/core';
import { performance } from 'performance-api';
import { globals } from '@interactors/globals'

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/create-interactor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EmptyObject, InteractorConstructor } from './specification';
import { createConstructor } from './constructor';
import type { EmptyObject, InteractorConstructor } from './specification.ts';
import { createConstructor } from './constructor.ts';

/**
* Create a custom interactor with the given name.
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/element/click.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import userEvent from '@testing-library/user-event'
// @ts-ignore 123
import { userEvent } from '@testing-library/user-event'

export function click(element: Element, init?: MouseEventInit) {
return userEvent.click(element, init);
export function click(...args: Parameters<typeof userEvent.click>): ReturnType<typeof userEvent.click> {
return userEvent.click(...args);
}
5 changes: 2 additions & 3 deletions packages/core/src/filter-set.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Filters, FilterFn, FilterObject, FilterParams, InteractorSpecification } from './specification';
import type { Filters, FilterFn, FilterObject, FilterParams, InteractorSpecification } from './specification.ts';
import { noCase } from 'change-case';
import { matcherDescription } from './matcher';
import { matcherDescription } from './matcher.ts';

export class FilterSet<E extends Element, F extends Filters<E>> {
constructor(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public specification: InteractorSpecification<E, F, any>,
public filters: FilterParams<E, F>,
) {};
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/format.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Match } from "./match";
import { InteractorOptions } from "./specification";
import type { Match } from "./match.ts";
import type { InteractorOptions } from "./specification.ts";

export interface TableOptions {
headers: string[];
Expand Down
31 changes: 16 additions & 15 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
export { Interactor, InteractorConstructor, InteractorSpecification, EmptyObject, FilterMethods, ActionMethods } from './specification';
export { Interaction, ActionInteraction, AssertionInteraction, isInteraction } from './interaction';
export { createInteractor } from './create-interactor';
export { createInspector } from './inspector'
export type { Interactor, InteractorConstructor, InteractorSpecification, EmptyObject, FilterMethods, ActionMethods } from './specification.ts';
export type { Interaction, ActionInteraction, AssertionInteraction } from './interaction.ts';
export { isInteraction } from './interaction.ts'
export { createInteractor } from './create-interactor.ts';
export { createInspector } from './inspector.ts'
export { isVisible } from 'element-is-visible';
export { Matcher } from './matcher';
export type { Matcher } from './matcher.ts';

export { including } from './matchers/including';
export { matching } from './matchers/matching';
export { and } from './matchers/and';
export { or } from './matchers/or';
export { not } from './matchers/not';
export { some } from './matchers/some';
export { every } from './matchers/every';
export { including } from './matchers/including.ts';
export { matching } from './matchers/matching.ts';
export { and } from './matchers/and.ts';
export { or } from './matchers/or.ts';
export { not } from './matchers/not.ts';
export { some } from './matchers/some.ts';
export { every } from './matchers/every.ts';

export { click } from './element/click';
export { MergeObjects } from './merge-objects'
export { MaybeMatcher } from './matcher'
export { click } from './element/click.ts';
export type { MergeObjects } from './merge-objects.ts'
export type { MaybeMatcher } from './matcher.ts'
6 changes: 3 additions & 3 deletions packages/core/src/inspector.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import { instantiateInteractor } from "./constructor";
import { findElements, unsafeSyncResolveParent } from './resolvers'
import { Interactor, Filters, InteractorConstructor, FilterParams } from "./specification";
import { instantiateInteractor } from "./constructor.ts";
import { findElements, unsafeSyncResolveParent } from './resolvers.ts'
import type { Interactor, Filters, InteractorConstructor, FilterParams } from "./specification.ts";

type GetElement<I extends InteractorConstructor<any, any, any, any>> = I extends InteractorConstructor<infer E, any, any, any> ? E : never
type GetFilters<I extends InteractorConstructor<any, any, any, any>> = I extends InteractorConstructor<any, infer F, any, any> ? F : never
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/interaction.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Operation, Task, run, Symbol } from '@effection/core';
import { InteractionOptions as SerializedInteractionOptions, globals, InteractionType } from '@interactors/globals';
import type { Interactor, FilterObject, FilterFn, FilterParams } from './specification';
import { serializeInteractionOptions } from './serialize';
import { type Operation, type Task, run, Symbol } from '@effection/core';
import { type InteractionOptions as SerializedInteractionOptions, globals, type InteractionType } from '@interactors/globals';
import type { Interactor, FilterObject, FilterFn, FilterParams } from './specification.ts';
import { serializeInteractionOptions } from './serialize.ts';

const interactionSymbol: unique symbol = Symbol.for('interaction') as any;

Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/locator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FilterDefinition } from './specification';
import { matcherDescription, MaybeMatcher } from './matcher';
import { applyFilter } from './match';
import type { FilterDefinition } from './specification.ts';
import { matcherDescription, type MaybeMatcher } from './matcher.ts';
import { applyFilter } from './match.ts';

export class Locator<E extends Element> {
constructor(private definition: FilterDefinition<string, E>, public value: MaybeMatcher<string>) {}
Expand Down
Loading