Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Proof-of-Concept Interactors Inspector package #903

Closed
wants to merge 5 commits into from
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
13 changes: 13 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,25 @@ jobs:
executor:
type: executor
default: "linux"
nvm:
type: boolean
default: false
prepack:
type: boolean
default: true
environment:
DRIVER: <<parameters.driver>>
steps:
- checkout
- when:
condition: <<parameters.nvm>>
steps:
- run:
name: Install NodeJS from .nvmrc
command: |
type .\.nvmrc | %{$_ -replace "v",""} | %{nvm install $_}
type .\.nvmrc | %{$_ -replace "v",""} | %{nvm use $_}
npm install -g yarn
- yarn_install
- when:
condition: <<parameters.prepack>>
Expand Down Expand Up @@ -162,6 +174,7 @@ workflows:
requires:
- prepack
- test:
nvm: true
executor:
name: "win/default"
size: "medium"
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v12.13.0
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"packages/suite",
"packages/globals",
"packages/interactor",
"packages/inspector",
"packages/agent",
"packages/driver",
"packages/webdriver",
Expand Down Expand Up @@ -47,7 +48,7 @@
"prepack:all": "yarn prepack && yarn install:integrations && yarn prepack:integrations"
},
"volta": {
"node": "12.11.1",
"node": "12.13.0",
"yarn": "1.22.4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test": "mocha -r ts-node/register test/**/*.test.ts",
"mocha": "mocha -r ts-node/register",
"start": "parcel serve --out-dir dist/app app/index.html app/harness.ts",
"prepack:app": "parcel build --public-url ./ --no-minify --out-dir dist/app app/index.html app/test-frame.html app/harness.ts",
"prepack:app": "NODE_PATH=../../ parcel build --public-url ./ --no-minify --out-dir dist/app app/index.html app/test-frame.html app/harness.ts",
"prepack:tsc": "yarn tsc --build ./tsconfig.dist.json",
"prepack": "yarn prepack:tsc && yarn prepack:app",
"pretest:manifest": "parcel build test/fixtures/manifest.js test/fixtures/app.html --out-dir tmp/test --no-minify --global __bigtestManifest",
Expand Down
17 changes: 17 additions & 0 deletions packages/inspector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# @bigtest/inspector

## How to start

- `yarn prepack`

## How to use

- Add entry point to your app `@bigtest/inspector`
- In a browser devtools execute function `__BIGTEST_TOGGLE_INSPECTOR__` to show the inspector view
- On the left side are all matched built-in interactors to dom elements.
- On the right side you can write custom interactors by using `createInteractor` API or use built-in interactors to write action sequence

## What doesn't work yet

- Interactor actions execute synchronously, that blocks UI updates
- Add interactor snippets
40 changes: 40 additions & 0 deletions packages/inspector/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@bigtest/inspector",
"version": "0.1.0",
"description": "Inspector to investigate matched interactors and play around with actions editor",
"main": "dist/main.js",
"browser": "dist/main.js",
"repository": "https://github.com/thefrontside/bigtest.git",
"author": "Frontside Engineering <[email protected]>",
"license": "MIT",
"files": [
"dist/**/*",
"src/**/*",
"README.md"
],
"scripts": {
"clean": "rm -rf dist *.tsbuildinfo",
"lint": "eslint \"src/**/*.ts{,x}\"",
"prepack": "webpack build --mode production"
},
"devDependencies": {
"@bigtest/interactor": "^0.28.2",
"@medv/finder": "^2.0.0",
"@types/prismjs": "^1.16.3",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.1",
"autoprefixer": "^10.2.5",
"css-loader": "^5.1.1",
"effector": "^21.8.8",
"effector-react": "^21.2.1",
"postcss": "^8.2.7",
"postcss-loader": "^5.1.0",
"prismjs": "^1.23.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"style-loader": "^2.0.0",
"ts-loader": "^8.0.17",
"webpack": "^5.24.3",
"webpack-cli": "^4.5.0"
}
}
58 changes: 58 additions & 0 deletions packages/inspector/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { useStore } from "effector-react";
import { createInteractor } from "@bigtest/interactor";
import { useCallback } from "react";
import { InspectorView } from "./interactors/InspectorView";
import { ActionsEditor } from "./interactors/ActionsEditior";
import { $code, $interactors, $isLoading, end, refresh, start } from "./actions";
import {
Button,
CheckBox,
Heading,
Link,
MultiSelect,
RadioButton,
Select,
TextField,
} from "./interactors/getInteractors";

export function App(): JSX.Element {
let interactors = useStore($interactors);
let isLoading = useStore($isLoading);
let code = useStore($code);

let runHandler = useCallback(async () => {
start();
try {
await eval(
`async ({ Button, CheckBox, Heading, Link, MultiSelect, RadioButton, Select, TextField, createInteractor }) => { ${code} }`
)({ Button, CheckBox, Heading, Link, MultiSelect, RadioButton, Select, TextField, createInteractor });
} catch (error) {
throw error;
} finally {
refresh();
end();
}
}, [code]);

return (
<div className="relative flex bottom-8 left-8 bg-white p-4 w-max">
<div className="mr-4 flex-shrink-0">
<div className="max-w-lg min-w-32 min-h-64 max-h-128 overflow-y-auto rounded-lg border-black border p-2">
<InspectorView interactors={interactors} />
</div>
</div>
<div className="flex flex-col items-start">
<button
className="rounded border-gray-500 border shadow outline-none focus:outline-none mb-2"
onClick={runHandler}
>
<span className="m-1">Run</span>
</button>
<div className="rounded-lg border-black border p-1 h-full">
<ActionsEditor />
</div>
</div>
{isLoading ? <div className="top-0 left-0 absolute w-full h-full bg-gray-400 opacity-50" /> : null}
</div>
);
}
Loading