Code Monkey home page Code Monkey logo

platform-community-edition's Introduction

Community edition of the Visual Knight Platform

Visual Knight

The ecosystem contains 3 essential parts in Visual Knight.

  1. The database
  2. The web app
  3. The api backend

Database

We use for our data handling Prisma 2. It is an excellent modern ORM which provides a lot of tools like

  • Simplified & type-safe database access
  • Declarative migrations & data modeling
  • Powerful & visual data management

We use Postgres as database but you can use others too. Prisma supports following databases at the moment:

  • PostgreSQL
  • SQLite: unstable (photon releases required)
  • Mysql
  • MongoDB: coming soon (waiting for prisma2 photon support)

The web app

The web app is the graphical user interface in Visual Knight. Here you can manage your projects and users to handle all the test comfortably.

The api backend

This backend returns all the information for the web app based on Graphql. This API also provides the possibility to create new tests and return there status. It is used for communication with the testing tools like CodeceptJS. The backend framework is written with NestJS

Set up

  1. create docker-compose.yml NOTE: latest version available on dockerhub
version: '3.7'
services:
  api:
    image: visualknight/api:1.0.0
    ports: 
      - '${VK_API_PORT}:3333'
    environment: 
      VK_APP_SECRET: SOME_APP_SECRET
      VK_APP_DOMAIN: http://${VK_UI_DOMAIN}:${VK_UI_PORT}/
      VK_GRAPHQL_SCHEMA_PATH: apps/api/schema.graphql
      VK_DATABASE: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:${POSTGRES_PORT}/${VK_DB_NAME}
    depends_on:
      - postgres
  ui:
    image: visualknight/ui:1.0.0
    ports: 
      - '${VK_UI_PORT}:8080'
  postgres:
    image: postgres
    restart: always
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - '${POSTGRES_PORT}:5432'
    expose:
      - '${POSTGRES_PORT}'
    volumes:
      - postgres:/var/lib/postgresql/data
  migration:
    image: visualknight/migration:1.0.0
    depends_on:
      - postgres
    environment:
      VK_DATABASE: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:${POSTGRES_PORT}/${VK_DB_NAME}
      POSTGRES_SERVER: postgres
      POSTGRES_PORT: ${POSTGRES_PORT}
volumes:
  postgres:
  1. create .env
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
VK_DB_NAME=visual_knight
VK_UI_DOMAIN=localhost
VK_UI_PORT=4200
VK_API_PORT=3333
  1. run docker-compose up

  2. open url VK_UI_DOMAIN:VK_UI_PORT http://localhost:4200

  3. login [email protected]/yourPassw0rd!

Setup local env for development

Clone the repository

Set up env variables

Create .env file based on .envtemplate for:

  1. root derictory
  2. libs/api-interface

Fill your environment with your data!

Install dependencies

npm install

Prepare database

NOTE: working database is required for mysql or postgres

  1. go into libs/api-interface
  2. you can find a file with the name schema.prisma
  3. Setup your databse (Choose between Postgresql, Mysql and SQLite) NOTE: environments setup must be done!
  4. Lift up the database with the structure npx prisma2 migrate up --experimental
  5. Create the first user node postinstall.js NOTE: You'll see credentials and API key in console

Everything is done and we can start the UI and API Server ;)

Start the ui and api server (2 servers in parallel)

  1. Starting the api server: npx ng run api:serve NOTE: default http://localhost:3333/graphql
  2. Starting the ui server: npx ng run visual-knight:serve NOTE: default http://localhost:4200

Build docker images

docker-compose up --build

Create a build

NOTE: This is still experimental

  • api server: npx ng run api:build
  • ui static files: npx ng run visual-knight:build

You can find the files under the dist folder.

platform-community-edition's People

Contributors

dependabot[bot] avatar elena-dev-thought avatar mitkotschimev avatar pashidlos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wooodhead

platform-community-edition's Issues

Create test pipelines with github actions

I am happy that the community is helping with this project and to bring better help for the PR's we need a QA pipeline which github actions will provide the easiest way

Show tests only for specific project if it was selected from project list

As it's now tests for all projects are shown regardless /test?project_id url param

Steps:

  1. navigate to /project
  2. select any project

Actual result:
tests for all projects are shown

Expected result:
show tests only for specific project

@MitkoTschimev what do you think on this one?
was is as a part of functionality or it's something new?
should we also hide project filter in case project_id provided?

API. x-api-key header is not validated

Cannot reproduce if x-api-key header is not provided in request - Unauthorised error thrown

Steps:

mutation {
  invokeTestSession(
    project: "any"
    testname: "any"
    autoBaseline: false
    capabilities: {
      browserName: "Chrome",
      os: "Windows"
    }
    misMatchTolerance: 0.01
  )
}

  • set HTTP headers
{
  "x-api-key": "NOT_VALID"
}

Actual result:
No error is shown

Expected result:
Unauthorised error thrown

Cannot delete project that contains tests

Cannot reproduce for empty project

Steps

  • Create project
  • add at least one test
  • try removing it

Error

core.js:9110 ERROR Error: Uncaught (in promise): Error: GraphQL error: 
Invalid `prisma.project.delete()` invocation in
/api/webpack:/apps/api/src/app/project/project.service.ts:20:45

Error occurred during query execution:
InterpretationError("Error for binding \'3\': RelationViolation(RelationViolation { relation_name: \"ProjectToTest\", model_a_name: \"Project\", model_b_name: \"Test\" })")
Error: GraphQL error: 
Invalid `prisma.project.delete()` invocation in
/api/webpack:/apps/api/src/app/project/project.service.ts:20:45

Error occurred during query execution:
InterpretationError("Error for binding \'3\': RelationViolation(RelationViolation { relation_name: \"ProjectToTest\", model_a_name: \"Project\", model_b_name: \"Test\" })")
    at new ApolloError (bundle.esm.js:63)
    at Object.next (bundle.esm.js:1004)
    at notifySubscription (Observable.js:130)
    at onNotify (Observable.js:165)
    at SubscriptionObserver.next (Observable.js:219)
    at bundle.esm.js:866
    at Set.forEach (<anonymous>)
    at Object.next (bundle.esm.js:866)
    at notifySubscription (Observable.js:130)
    at onNotify (Observable.js:165)
    at SubscriptionObserver.next (Observable.js:219)
    at Object.next (bundle.esm.js:29)
    at notifySubscription (Observable.js:130)
    at onNotify (Observable.js:165)
    at SubscriptionObserver.next (Observable.js:219)
    at resolvePromise (zone-evergreen.js:797) [angular]
    at polyfills-es2015.js:3556:17 [angular]
    at SafeSubscriber._error (Observable.js:91) [angular]
    at SafeSubscriber.__tryOrUnsub (Subscriber.js:185) [angular]
    at SafeSubscriber.error (Subscriber.js:137) [angular]
    at Subscriber._error (Subscriber.js:75) [angular]
    at Subscriber.error (Subscriber.js:55) [angular]
    at vendor-es2015.js:167261:28 [angular]
    at Object.onInvoke (core.js:34201) [angular]
    at polyfills-es2015.js:3704:36 [angular]

Cannot install dependencies - npm fails with error

OS: WIndows 10
node: v10.16.0
npm: 6.9.0
prisma2: 2.0.0-preview016.1

Similar issue in prisma2: prisma/prisma#1232

npm log

PS C:\xxx> npm i

> [email protected] postinstall C:\xxx
> npm run generate:photon


> [email protected] generate:photon C:\xxx
> cd libs/api-interface && prisma2 generate

Error: Problem while parsing the query engine response at C:\xxx\node_modules\prisma2\query-engine-windows.exe. Please wait until the 'prisma query-engine' download completes!
SyntaxError: Unexpected token P in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.<anonymous> (C:\xxx\node_modules\prisma2\build\index.js:114955:25)
    at Generator.next (<anonymous>)
    at fulfilled (C:\xxx\node_modules\prisma2\build\index.js:114913:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Cannot start api service

node v12.14.1
npm 6.13.4

Steps:

  1. clone repo
  2. npm i
  3. npx ng serve api
PS C:\work\platform-community-edition> npx ng serve api
Starting type checking service...
Using 6 workers with 2048MB memory limit
Type checking in progress...
Hash: 5875a0559989f54eca86
Built at: 04/07/2020 3:00:58 PM
Entrypoint main = main.js main.js.map
chunk {main} main.js, main.js.map (main) 107 KiB [entry] [rendered]
Debugger listening on ws://localhost:7777/7d635fbc-96ab-456f-af52-46b5df70172c
Debugger listening on ws://localhost:7777/7d635fbc-96ab-456f-af52-46b5df70172c
For help, see: https://nodejs.org/en/docs/inspector
[Nest] 20888   - 04/07/2020, 3:01 PM   [NestFactory] Starting Nest application...
[Nest] 20888   - 04/07/2020, 3:01 PM   [ExceptionHandler] Nest cannot export a provider/module that is not a part of the currently processed module (SharedModule). Please verify whether each exported unit is available in this particular context. +52ms
Error: Nest cannot export a provider/module that is not a part of the currently processed module (SharedModule). Please verify whether each exported unit is available in this particular context.
    at Module.validateExportedProvider (C:\work\platform-community-edition\node_modules\@nestjs\core\injector\module.js:251:19)
    at Module.addCustomExportedProvider (C:\work\platform-community-edition\node_modules\@nestjs\core\injector\module.js:235:43)
    at Module.addExportedProvider (C:\work\platform-community-edition\node_modules\@nestjs\core\injector\module.js:221:25)
    at NestContainer.addExportedProvider (C:\work\platform-community-edition\node_modules\@nestjs\core\injector\container.js:112:16)
    at DependenciesScanner.insertExportedProvider (C:\work\platform-community-edition\node_modules\@nestjs\core\scanner.js:177:24)
    at C:\work\platform-community-edition\node_modules\@nestjs\core\scanner.js:104:50
    at Array.forEach (<anonymous>)
    at DependenciesScanner.reflectExports (C:\work\platform-community-edition\node_modules\@nestjs\core\scanner.js:104:17)
    at DependenciesScanner.scanModulesForDependencies (C:\work\platform-community-edition\node_modules\@nestjs\core\scanner.js:57:18)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)

Cannot accept first screenshot as baseline - no accept or decline buttons are shown

Core library keep throwing error

TypeError: Cannot read property 'misMatchTolerance' of null

      at VisualKnightCore.<anonymous> (node_modules/@visual-knight/core/src/process-screenshot.ts:49:61)
      at fulfilled (node_modules/@visual-knight/core/lib/process-screenshot.js:4:58)

1

Expected result:

  • Error in console has link to test session where baseline needs to be accepted
  • Accept and decline buttons are present
  • Status is UNRESOLVED

Workaround for now
Set autoBaseline: true - current image is taken as baseline

API. PayloadTooLargeError: request entity too large

When I send image around 100 KB
Example image
large

Error

api_1        | [Nest] 19   - 04/09/2020, 9:40 PM   [ExceptionsHandler] request entity too large +47937ms
api_1        | PayloadTooLargeError: request entity too large
api_1        |     at readStream (/api/node_modules/raw-body/index.js:155:17)
api_1        |     at getRawBody (/api/node_modules/raw-body/index.js:108:12)
api_1        |     at read (/api/node_modules/body-parser/lib/read.js:77:3)
api_1        |     at jsonParser (/api/node_modules/body-parser/lib/types/json.js:135:5)
api_1        |     at Layer.handle [as handle_request] (/api/node_modules/express/lib/router/layer.js:95:5)
api_1        |     at trim_prefix (/api/node_modules/express/lib/router/index.js:317:13)
api_1        |     at /api/node_modules/express/lib/router/index.js:284:7
api_1        |     at Function.process_params (/api/node_modules/express/lib/router/index.js:335:12)
api_1        |     at next (/api/node_modules/express/lib/router/index.js:275:10)
api_1        |     at expressInit (/api/node_modules/express/lib/middleware/init.js:40:5)

Temp workaround
https://stackoverflow.com/questions/52783959/nest-js-request-entity-too-large-payloadtoolargeerror-request-entity-too-larg

I guess it should be implemented as configuration setting

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.