Skip to content

DLTS Enhanced Networked Monographs - search application built using Vue.js and D3

License

Notifications You must be signed in to change notification settings

NYULibraries/dlts-enm-search-application

Repository files navigation

DLTS Enhanced Networked Monographs: Search

Topics and full-text search for the DLTS Enhanced Networked Monographs website.

Overview

Prerequisites

  • 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.

Installing dependencies

# Install dependencies including devDependencies
# If NODE_ENV is not set to production, can leave out --production=false
yarn install --production=false

Compile and hot-reload for development

# Serve development version with hot reload at localhost:8080
# Uses environment variables from .env.development
yarn serve

Compile and minify for development, stage, and production

# 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 tests

# Run all unit and browser tests
yarn test

Browser (e2e) tests

# 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

Run unit tests

yarn test:unit

Lint and fix files

yarn lint

Lint but do not fix files

yarn lint --no-fix

Customize configuration

See Configuration Reference and Environment Variables and Modes.

Notes on tests

Solr fake

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.

Update Solr fixture data

To update the files in tests/browser/fixtures/solr-fake/:

  1. Make any desired changes to the Solr requests in the tests, if any. This may involve editing the golden files.

  2. 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.

  3. 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.

Golden files

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.

Query parameters

solr: Solr override

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: intentionally produce Solr request errors for testing purposes

  • ?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.

Deployment

# 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:

  1. Builds the specified version of the search application
  2. Copies it to the appropriate AWS S3 bucket
  3. Invalidates the CloudFront cache for path /search/*
  4. 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.

ENM project Github repos

Built With

License

This project is licensed under the Apache License Version 2.0 - see the LICENSE file for details.