Open source frontend for abakus.no
Issues: We track issues in the main repo of LEGO
$ yarn # Install dependencies $ yarn start:staging # Start webserver with development backend
Everything should be up and running on localhost:3000. The
:staging suffix points the webserver at a hosted development backend.
Running with local backend
First, you need to have the
django backend running, see webkom/lego.
$ yarn start # Start webserver with local backend
Server side rendering (Optional)
In production (live) we use server side rendering. Due to bad hot reloading, we don't use it by default in dev. The server side renderer can be started by running:
$ yarn build $ yarn ssr # or yarn ssr:staging
webserver running the frontend can take many optional environment variables. Docs can be found at
config/environment.md, and default can be found at
- prettier for JS code formatter.
We recommend getting plugins/extensions in
Vim so the code auto-formats, and automatically prompts you with errors. When you submit code to Github the CI server will automatically run all the commands above to check that your code is up to par.
Start dev server (with hot reload), and go to localhost:6060.
$ yarn styleguide
To build a static version of the documentation, run:
$ yarn styleguide:build
Unit tests (jest)
Run all the tests and check for lint errors with the command:
$ yarn test
For development you can run the tests continuously by using:
$ yarn test:watch
A coverage report can be generated by running
yarn test -- --coverage.
Cypress E2E (End-to-end tests)
End to end tests (cypress)
In order to run end to end tests, you need to run both lego-webapp and lego. Lego can be found here: https://github.com/webkom/lego. Lego is assumed to have a clean development database, follow the steps below to achieve that.
$ cd ../lego $ docker-compose up -d # Start all services that lego depends on $ python manage.py initialize_development # Initialize and load data sources (postgres) $ docker-compose restart lego_cypress_helper # The cypress helper resets database between every test and might need this restart to function correctly $ python manage.py runserver
If you already have the backend setup, make sure your database is clean
python manage.py reset_db python manage.py migrate python manage.py load_fixtures docker-compose restart lego_cypress_helper # Make sure the copy is of the clean database
Start up the node server
$ yarn start
And start cypress in another terminal
$ yarn cypress open
Alternative: You can also run the node server with server side rendering enabled. This is how the tests are run on CI. To do this, you build and start the server
$ yarn build $ yarn ssr
And you run cypress headlessly (no visible browser) in another terminal
yarn cypress run
$ BUNDLE_ANALYZER=true yarn build
Since the repo is public and we use a lot of secrets in the pipeline, we require the pipeline to be verified with a signature from drone. To obtain this, use the cli:
drone sign webkom/lego-webapp
You need to login to retrieve the signature. Get the login data from your user settings.