e44ed3f25ac1818272ba2a97a0a63dea4ca75aca
[evergreen-equinox.git] / Open-ILS / src / eg2 / CHEAT_SHEET.adoc
1 = Evergreen Angular App Cheatsheet
2
3 == Basics
4
5 [source,sh]
6 ---------------------------------------------------------------------
7 npm update
8 npm install
9 ng lint                              # check code formatting
10 npm run test                         # unit tests
11 ng e2e                               # end-to-end tests, be sure to set
12                                      # MOZ_HEADLESS=1 if you aren't
13                                      # running x11
14 ng build --watch                     # compile dev mode
15 ng build --configuration=production  # compile production mode
16 ---------------------------------------------------------------------
17
18 == OPTIONAL: Adding a Locale 
19
20 * Using cs-CZ as an example.
21 * A cs-CZ configuration is supplied by default.  Additional configs
22   must be added where needed.
23 * Currently translation builds are only available on --prod build mode.
24 * Uncomment the locale lines in eg_vhost.conf and restart apache.
25 * TODO: expand docs on package.json file changes required to add locales.
26
27 === Exporting Source Strings
28
29 [source,sh]
30 ---------------------------------------------------------------------
31 npm run export-strings
32 ---------------------------------------------------------------------
33
34 * Then upload the messages.xmb file to the translation service
35
36 === Import and Build the Translation
37
38 1. Edit the "locales" array ./src/environments/environment.prod.ts to 
39    include cs-CZ.
40 2. Export translations as ".XTB" files from translation service.
41 3. Put the file in src/locale/messages.cs-CZ.xtb
42 4. Build the application for the selected locale by running:
43 [source,sh]
44 ---------------------------------------------------------------------
45 npm run build-cs-CZ
46 ---------------------------------------------------------------------
47
48 === Working with the e2e tests
49
50 * e2e tests run on https://nightwatchjs.org/[Nightwatch]
51 * New tests go into nightwatch/src and its subdirectories.  Their
52 filenames must end in .spec.ts to be picked up by the test runner.
53 * To run a single e2e test file, `npx nightwatch nightwatch/src/rest/of/path/my_spec.ts`.
54 You can add the `--verbose` flag, which is especially useful if you are
55 troubleshooting a selector.
56 * Also useful when you are troubleshooting: On a machine with a GUI,
57 add `browser.pause()` to your test just before the point where it is
58 failing, then run `npx nightwatch`.  This will provide you with
59 a breakpoint and a firefox browser you can use to investigate.
60 * The e2e tests do not have to be run on an Evergreen server.  You can
61 run them locally and point them to any non-production Evergreen
62 server you'd like, as long as it has the concerto data set loaded.
63 They default to looking for Evergreen URLs on
64 localhost, but you can change the domain by modifiying the
65 "evergreenRoot" setting in nightwatch.conf.js.
66 * These tests make real requests and do real work in the database.
67 Probably a good idea to reload the database between runs if
68 you have the time to do so: turn off opensrf, rerun the eg_db_config
69 support script, and turn opensrf back on.
70 * If you have some good hardware, you can run `npx nightwatch --parallel`
71 to run the tests in parallel and save some time.
72 * If you get the error "Profile not found" while running Firefox
73 installed from a snap package, you may be experiencing this known
74 issue with geckodriver: https://github.com/mozilla/geckodriver/releases/tag/v0.31.0 --
75 `mkdir $HOME/tmp; TMPDIR=$HOME/tmp ng e2e` should work.