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