Topics and full-text search for the DLTS Enhanced Networked Monographs website.
- AWS CLI v2 - for deployment scripts.
- Node (at least Node 12.x recommended)
- Java (at least Java 8 recommended) - for Selenium tests
- yarn is recommended, but not required. All instructions
below assume
yarn
.
# Install dependencies including devDependencies
# If NODE_ENV is not set to production, can leave out --production=false
yarn install --production=false
# Serve development version with hot reload at localhost:8080
# Uses environment variables from .env.development
yarn serve
# Uses environment variables from .env.dev
yarn build:dev
# Uses environment variables from .env.stage
yarn build:stage
# Uses environment variables from .env.prod
yarn build:prod
# Run all unit and browser tests
yarn test
# Run Selenium tests headlessly against localhost ENM
yarn test:browser:local
# Debugging Selenium tests in Chrome only - not in headless mode
# Timeout is set to very hight value to allow for pausing at breakpoints
yarn test:browser:local:debug:chrome
# Debugging Selenium tests in Firefox only - not in headless mode
# Timeout is set to very hight value to allow for pausing at breakpoints
yarn test:browser:local:debug:firefox
# Run tests headlessly against live dev server ENM
yarn test:browser:dev
# Run tests headlessly against live staging server ENM
yarn test:browser:stage
# Run tests headlessly against live production server ENM
yarn test:browser:prod
yarn test:unit
yarn lint
yarn lint --no-fix
See Configuration Reference and Environment Variables and Modes.
The solr
query string parameter is used by the browser tests to make the application under test
send all Solr requests to a Solr fake running on localhost:3000.
The Solr Fake is currently a very basic in-house implementation included as an
NPM module:
NYULibraries/dlts-solr-fake.
The Solr fake is configured and started automatically in tests/browser/conf/wdio.main.conf.js
:
see the solrFake
top-level option and the onPrepare
hook.
The Solr responses served by the Solr fake are in tests/browser/fixtures/solr-fake/
.
The index.json
file maps Solr request query strings to response files.
To update the files in tests/browser/fixtures/solr-fake/
:
-
Make any desired changes to the Solr requests in the tests, if any. This may involve editing the golden files.
-
Make any desired changes to the production Solr index, if any. The production Solr index will be used to generate the new Solr fixture data.
-
Run
yarn test:browser:update:fixtures
.
The index.json
and Solr response files in tests/browser/fixtures/solr-fake/
will be updated
by the Solr fake.
The initial golden files were created by scripts which derived golden file data from the
verified (using dlts-enm-verifier)
live Solr indexes. The saved Solr responses generated by that script were later
used for the fixture data (tests/browser/fixtures/
) for the Solr fake which
was developed later.
In the future, if the fixture data for the Solr fake changes, the golden files
can be updated by running yarn test:browser:update:golden
.
Note that there may be some tests that do not verify against golden files but have expected values directly hardcoded into the scripts. These will need to be updated manually if they are broken by the data changes to the Solr fake.
The Solr server used for ENM Search can be overridden using the solr
query parameter.
Example:
http://dlib.nyu.edu/enm/search/?solr=http://stagediscovery.dlib.nyu.edu:8983/solr/enm-pages/
...informs the application that all Solr requests should be routed to the stage Solr server instead of the production Solr server.
?solrErrorSimulation=search
- Simulates Solr request error for initial topic/full-text search
?solrErrorSimulation=preview-epub
- Simulates Solr request error when selects an EPUB to preview. This can only happen if the initial Solr request for search results succeeds but the Solr request for EPUB details fails.
?solrErrorSimulation=preview-page
- Simulates Solr request error when selects a page in the bar chart in the preview. This can only happen if the initial Solr request for search results and the subsequent Solr request for EPUB preview succeed but the Solr request for a page to see the topics and page text fails.
# Build dev server version, copy to server, and run tests
yarn deploy:dev
# Build stage server version, copy to server, and run tests
yarn deploy:stage
# Build prod server version, copy to server, and run tests
yarn deploy:prod
A deploy script calls the scripts for the following tasks in order:
- Builds the specified version of the search application
- Copies it to the appropriate AWS S3 bucket
- Invalidates the CloudFront cache for path /search/*
- Runs all browser tests against the newly deployed application
Note that these scripts assume that the AWS CLI is installed, and that the config and credentials files have been set up appropriately.
- dlts-enm
- dlts-enm-search-application
- dlts-enm-tct-backend
- dlts-enm-tct-developer
- dlts-enm-tct-frontend
- dlts-enm-verifier
- dlts-enm-web
This project is licensed under the Apache License Version 2.0 - see the LICENSE file for details.