= Evergreen Angular App Cheatsheet == Basics [source,sh] --------------------------------------------------------------------- npm update npm install ng lint # check code formatting npm run test # unit tests # run end-to-end tests using Firefox ng e2e # end-to-end tests, be sure to set # MOZ_HEADLESS=1 if you aren't # running x11 # run end-to-end tests using Chrome npm install --save-dev chromedriver # install ChromeDrive; you may # need to tack on "@VERSION" # to match the version of Chromium # available to you ng e2e --env chrome # ... if you have X11 ng e2e --env chrome-headless # ... if you don't have X11 ng build --watch # compile dev mode ng build --configuration=production # compile production mode --------------------------------------------------------------------- == OPTIONAL: Adding a Locale * Using cs-CZ as an example. * A cs-CZ configuration is supplied by default. Additional configs must be added where needed. * Currently translation builds are only available on --prod build mode. * Uncomment the locale lines in eg_vhost.conf and restart apache. * TODO: expand docs on package.json file changes required to add locales. === Exporting Source Strings [source,sh] --------------------------------------------------------------------- npm run export-strings --------------------------------------------------------------------- * Then upload the messages.xmb file to the translation service === Import and Build the Translation 1. Edit the "locales" array ./src/environments/environment.prod.ts to include cs-CZ. 2. Export translations as ".XTB" files from translation service. 3. Put the file in src/locale/messages.cs-CZ.xtb 4. Build the application for the selected locale by running: [source,sh] --------------------------------------------------------------------- npm run build-cs-CZ --------------------------------------------------------------------- === Working with the e2e tests * e2e tests run on https://nightwatchjs.org/[Nightwatch] * New tests go into nightwatch/src and its subdirectories. Their filenames must end in .spec.ts to be picked up by the test runner. * To run a single e2e test file, `npx nightwatch nightwatch/src/rest/of/path/my_spec.ts`. You can add the `--verbose` flag, which is especially useful if you are troubleshooting a selector. * Also useful when you are troubleshooting: On a machine with a GUI, add `browser.pause()` to your test just before the point where it is failing, then run `npx nightwatch`. This will provide you with a breakpoint and a firefox browser you can use to investigate. * The e2e tests do not have to be run on an Evergreen server. You can run them locally and point them to any non-production Evergreen server you'd like, as long as it has the concerto data set loaded. They default to looking for Evergreen URLs on localhost, but you can change the domain by modifiying the "evergreenRoot" setting in nightwatch.conf.js. * These tests make real requests and do real work in the database. Probably a good idea to reload the database between runs if you have the time to do so: turn off opensrf, rerun the eg_db_config support script, and turn opensrf back on. * If you have some good hardware, you can run `npx nightwatch --parallel` to run the tests in parallel and save some time. * If you get the error "Profile not found" while running Firefox installed from a snap package, you may be experiencing this known issue with geckodriver: https://github.com/mozilla/geckodriver/releases/tag/v0.31.0 -- `mkdir $HOME/tmp; TMPDIR=$HOME/tmp ng e2e` should work.