From ea3441cbbf530e88612dd51c081583e3f4614874 Mon Sep 17 00:00:00 2001 From: fbiagenthotmail Date: Wed, 10 Jun 2020 23:42:36 -0400 Subject: [PATCH 1/8] add url query for transmission --- src/actions/recomputeReduxState.js | 7 +++++++ src/middleware/changeURL.js | 5 +++++ src/reducers/controls.js | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/actions/recomputeReduxState.js b/src/actions/recomputeReduxState.js index 5fc361774..70baccd48 100644 --- a/src/actions/recomputeReduxState.js +++ b/src/actions/recomputeReduxState.js @@ -127,6 +127,13 @@ const modifyStateViaURLQuery = (state, query) => { if ("onlyPanels" in query) { state.showOnlyPanels = true; } + if (query.transmissions) { + if (query.transmissions === "show") { + state.showTransmissionLines = true; + } else if (query.transmissions === "hide") { + state.showTransmissionLines = false; + } + } return state; }; diff --git a/src/middleware/changeURL.js b/src/middleware/changeURL.js index 773a59838..d697be20a 100644 --- a/src/middleware/changeURL.js +++ b/src/middleware/changeURL.js @@ -75,6 +75,11 @@ export const changeURLMiddleware = (store) => (next) => (action) => { query.r = action.data === state.controls.defaults.geoResolution ? undefined : action.data; break; } + case types.TOGGLE_TRANSMISSION_LINES: { + if (action.data === state.controls.defaults.showTransmissionLines) query.transmissions = undefined; + else query.transmissions = action.data ? 'show' : 'hide'; + break; + } case types.CHANGE_LANGUAGE: { query.lang = action.data === state.general.defaults.language ? undefined : action.data; break; diff --git a/src/reducers/controls.js b/src/reducers/controls.js index b6f30df37..9b1cbb9be 100644 --- a/src/reducers/controls.js +++ b/src/reducers/controls.js @@ -21,7 +21,8 @@ export const getDefaultControlsState = () => { geoResolution: defaultGeoResolution, filters: {}, colorBy: defaultColorBy, - selectedBranchLabel: "none" + selectedBranchLabel: "none", + showTransmissionLines: true }; // a default sidebarOpen status is only set via JSON, URL query // _or_ if certain URL keywords are triggered From 73b1870bad19a46c95cf0b25bc4263aeffa597a8 Mon Sep 17 00:00:00 2001 From: james hadfield Date: Thu, 11 Jun 2020 17:50:18 +1200 Subject: [PATCH 2/8] Relax requirement for nodejs 10.8. Closes #1161. Auspice should work on a wide range of nodejs versions. Here I specified between 10.8 and 13.14 as they are the versions I've personally run auspice on without trouble. --- README.md | 5 +++-- docs-src/docs/introduction/install.md | 4 ++-- docs-src/docs/narratives/create-pdf.md | 2 +- package.json | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 498d280ac..baee20635 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ The following are helpful when beginning to use Auspice: ### Installation Install auspice for use as a global command. -This requires nodejs 10+. We recommend using a conda environment, but this is not the only way. +This requires nodejs. +We recommend using a conda environment, but this is not the only way. (See [here](https://nextstrain.github.io/auspice/introduction/install) for more installation methods & help). #### Install with conda (Recommended) @@ -40,7 +41,7 @@ This requires nodejs 10+. We recommend using a conda environment, but this is no Create and activate a [conda](https://docs.conda.io) environment: ```bash -conda create --name auspice nodejs=10 +conda create --name auspice nodejs=12 conda activate auspice ``` diff --git a/docs-src/docs/introduction/install.md b/docs-src/docs/introduction/install.md index 7bd3775a3..02125b2b6 100644 --- a/docs-src/docs/introduction/install.md +++ b/docs-src/docs/introduction/install.md @@ -4,7 +4,7 @@ title: Install Auspice ## Prerequisites Auspice is a JavaScript program, and requires [Node.js](https://nodejs.org/) to be installed on your system. -For best results, please use Node.js version 10. +We've had success running a range of different node versions between 10.8 and 13. We highly recommend using [Conda](https://conda.io/docs/) to manage environments, i.e. use Conda to create an environment with Node.js installed where you can use Auspice. It's possible to use other methods, but this documentation presupposes that you have Conda installed. @@ -16,7 +16,7 @@ You can also use the Windows Subsystem Linux for a fuller Linux environment. ## Create a Conda Environment ```bash -conda create --name auspice nodejs=10 +conda create --name auspice nodejs=12 conda activate auspice ``` diff --git a/docs-src/docs/narratives/create-pdf.md b/docs-src/docs/narratives/create-pdf.md index a7b430920..de5368c69 100644 --- a/docs-src/docs/narratives/create-pdf.md +++ b/docs-src/docs/narratives/create-pdf.md @@ -14,7 +14,7 @@ If you've followed the [auspice install instructions](../introduction/install) a If not, you can create the necessary conda environment via: ```bash -conda create --name auspice nodejs=10 +conda create --name auspice nodejs=12 ``` Install Decktape via: diff --git a/package.json b/package.json index ff2edcf7a..07bfbf187 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "repository": "github:nextstrain/auspice", "homepage": "https://www.npmjs.com/package/auspice", "engines": { - "node": "10.8.x", - "npm": "6.2.x" + "node": ">=10.8.0 <=13.14", + "npm": ">=6.2" }, "bin": { "auspice": "./auspice.js" From e301e7cb48238325bef61bc731c7387040cea46e Mon Sep 17 00:00:00 2001 From: james hadfield Date: Mon, 15 Jun 2020 14:58:50 +1200 Subject: [PATCH 3/8] [bugfix] allow narratives to simultaneously zoom and change color This fixes a bug where a narrative slide-change requests that the tree both zoom and change color. This was introduced by 0639da85c4e1e1c343acbbe8d3231280ea8b68ca which, as part of the (now disabled) push for SVG gradient rendering of branches, moved the d3 call to update the stroke (branch color) into a separate code block, in order that it can behave differently for "T" and "S" parts of a branch. This code-block is not run when the tree zooms (that is the bug). Here we partially revert that commit. This should be revisited when we re-enable SVG gradients. --- src/components/tree/phyloTree/change.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/components/tree/phyloTree/change.js b/src/components/tree/phyloTree/change.js index 958e58035..e6b0edc79 100644 --- a/src/components/tree/phyloTree/change.js +++ b/src/components/tree/phyloTree/change.js @@ -60,14 +60,9 @@ const svgSetters = { // only allow stroke to be set on individual branches ".branch": { "stroke-width": (d) => d["stroke-width"] + "px", // style - as per drawBranches() + stroke: (d) => strokeForBranch(d), // TODO: revisit if we bring back SVG gradients cursor: (d) => d.visibility === NODE_VISIBLE ? "pointer" : "default", visibility: getBranchVisibility - }, - ".branch.S": { - stroke: (d) => strokeForBranch(d, "S") - }, - ".branch.T": { - stroke: (d) => strokeForBranch(d, "T") } } }; @@ -123,7 +118,6 @@ const genericSelectAndModify = (svg, treeElem, updateCall, transitionTime) => { export const modifySVG = function modifySVG(elemsToUpdate, svgPropsToUpdate, transitionTime, extras) { let updateCall; const classesToPotentiallyUpdate = [".tip", ".vaccineDottedLine", ".vaccineCross", ".branch"]; /* order is respected */ - /* treat stem / branch specially, but use these to replace a normal .branch call if that's also to be applied */ if (elemsToUpdate.has(".branch.S") || elemsToUpdate.has(".branch.T")) { const applyBranchPropsAlso = elemsToUpdate.has(".branch"); @@ -136,11 +130,6 @@ export const modifySVG = function modifySVG(elemsToUpdate, svgPropsToUpdate, tra createUpdateCall(".branch", svgPropsToUpdate)(selection); /* the "normal" branch changes to apply */ selection.attr("d", (d) => d.branch[STidx]); /* change the path (differs between .S and .T) */ }; - } else if (svgPropsToUpdate.has("stroke")) { /* we seed to set stroke differently on T and S branches */ - updateCall = (selection) => { - createUpdateCall(`.branch${x}`, svgPropsToUpdate)(selection); - selection.attr("d", (d) => d.branch[STidx]); - }; } else { updateCall = (selection) => { selection.attr("d", (d) => d.branch[STidx]); @@ -295,7 +284,7 @@ export const change = function change({ and what SVG elements, node properties, svg props we actually change */ if (changeColorBy) { /* check that fill & stroke are defined */ - elemsToUpdate.add(".branch.S").add(".branch.T").add(".tip").add(".conf"); + elemsToUpdate.add(".branch").add(".tip").add(".conf"); svgPropsToUpdate.add("stroke").add("fill"); nodePropsToModify.branchStroke = branchStroke; nodePropsToModify.tipStroke = tipStroke; From b2a347a66f73e0c1bbecba895d7027469e33d91f Mon Sep 17 00:00:00 2001 From: james hadfield Date: Tue, 16 Jun 2020 14:08:42 +1200 Subject: [PATCH 4/8] Move to storing test narratives in the auspice repo This commit signifies a shift to storing a set of narrative files in this repo, as opposed to obtaining the nextstrain.org narratives via a script. The Nextstrain.org narratives are still obtainable (they are all stored in their own github repo) and the docs have been updated to show this. By storing and maintaining "test narratives" in the auspice repo we can both provide examples of the capability of narratives and use them to test functionality and fix bugs. As the are stored in the `narratives` directory, they are available via Nextstrain Community URLs at nextstrain.org/community/narratives/nextstrain/auspice/... --- .github/workflows/ci.yaml | 1 - .gitignore | 1 - DEV_DOCS.md | 4 +-- README.md | 9 +++++- docs-src/docs/introduction/how-to-run.md | 8 ++--- docs-src/docs/introduction/install.md | 3 +- narratives/test_parsing-error.md | 13 ++++++++ narratives/test_simultaneous-tree-updates.md | 34 ++++++++++++++++++++ package.json | 3 +- scripts/get-narratives.sh | 30 ----------------- 10 files changed, 63 insertions(+), 43 deletions(-) create mode 100644 narratives/test_parsing-error.md create mode 100644 narratives/test_simultaneous-tree-updates.md delete mode 100755 scripts/get-narratives.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 06ca33e52..ea996500d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,7 +30,6 @@ jobs: node-version: ${{ matrix.node }} - run: npm ci - run: npm run get-data - - run: npm run get-narratives - run: npm run smoke-test:ci lint: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 19a22f26e..c79b02489 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ big_flu /static/ s3/ /local_narratives/ -/narratives/ /datasets/ **/__diff_output__ diff --git a/DEV_DOCS.md b/DEV_DOCS.md index 3d8dc0184..9d10759cd 100644 --- a/DEV_DOCS.md +++ b/DEV_DOCS.md @@ -48,7 +48,7 @@ Run `npm run lint`. If there are issues run `npm run lint:fix`. > For integration tests to work, you'll need to have `git-lfs` installed (see below) as it stores the images that the snapshot tests will use. -1. Fetch the datasets with `npm run get-data` and `npm run get-narratives`. +1. Fetch the datasets with `npm run get-data`. 2. Ensure you are **not** currently running the site locally, then run `npm run integration-test:ci`. @@ -60,7 +60,7 @@ Run `npm run lint`. If there are issues run `npm run lint:fix`. #### For smoke tests -1. Fetch the datasets with `npm run get-data` and `npm run get-narratives`. +1. Fetch the datasets with `npm run get-data`. 2. Ensure you are **not** currently running the site locally, then run `npm run smoke-test:ci`. diff --git a/README.md b/README.md index baee20635..f37c660d0 100644 --- a/README.md +++ b/README.md @@ -78,9 +78,16 @@ If you've installed auspice from source, we have helper scripts to make all the ```bash # from the auspice src directory npm run get-data -npm run get-narratives ``` +### Obtain narratives to view locally + +This repository contains a number of "test narratives" which serve both to provide examples of the capability of narratives, as well as being used to test functionality and fix bugs. +These should work out of the box, assuming you have obtained the necessary datasets via the above script. + +If you wish to view the [nextstrain-maintained narratives](https://nextstrain.org/docs/contributing/sharing-data), then this can be done by checking out the [nextstrain/narratives github repo](github.com/nextstrain/narratives) and telling `auspice` to look for narratives there via the `--narrativeDir` argument. + + ### Run auspice ```bash diff --git a/docs-src/docs/introduction/how-to-run.md b/docs-src/docs/introduction/how-to-run.md index b997dc8aa..1180dc16a 100644 --- a/docs-src/docs/introduction/how-to-run.md +++ b/docs-src/docs/introduction/how-to-run.md @@ -120,9 +120,9 @@ For narratives, please see [Writing a Narrative](narratives/how-to-write.md) for ## Obtaining a Set of Input Files -If you'd like to download the datasets and narratives on [nextstrain.org](https://nextstrain.org) then there are two scripts which allow you to do this: +If you'd like to download the dataset JSONs which are behind the core-datasets shown on [nextstrain.org](https://nextstrain.org), then you can run [this script](https://github.com/nextstrain/auspice/blob/master/scripts/get-data.sh) which will create a `./data` directory for you. -* You can download the dataset JSONs by running [this script](https://github.com/nextstrain/auspice/blob/master/scripts/get-data.sh) which will create a `./data` directory for you. -* You can download the narrative Markdown files by running [this script](https://github.com/nextstrain/auspice/blob/master/scripts/get-narratives.sh) which will create a `./narratives` directory for you. +The nextstrain-maintained narratives are stored in the [nextstrain/narratives github repo](github.com/nextstrain/narratives). +You can obtain these by cloning that repo. -You can then run `auspice view --datasetDir data --narrativeDir narratives` to visualise all of the [nextstrain.org](https://nextstrain.org) datasets locally. +You can then run `auspice view --datasetDir data --narrativeDir ` to visualise all of the [nextstrain.org](https://nextstrain.org) datasets locally. diff --git a/docs-src/docs/introduction/install.md b/docs-src/docs/introduction/install.md index 02125b2b6..e26779055 100644 --- a/docs-src/docs/introduction/install.md +++ b/docs-src/docs/introduction/install.md @@ -62,9 +62,8 @@ auspice build auspice --version auspice --help -# Obtain datasets & narratives to view locally (optional) +# Obtain nextstrain.org datasets to view locally (optional) npm run get-data -npm run get-narratives ``` Updating Auspice should only require pulling the new version from GitHub -- it shouldn't require any `npm` commands. diff --git a/narratives/test_parsing-error.md b/narratives/test_parsing-error.md new file mode 100644 index 000000000..b74a43697 --- /dev/null +++ b/narratives/test_parsing-error.md @@ -0,0 +1,13 @@ +--- +title: "Example of a narrative which can't be parsed" +date: "June 2020" +dataset: "https://nextstrain.org/zika" +abstract: "This narrative in incorrectly parsed by auspice v2.16.0 (and earlier) such that it doesn't even render." +--- + +# [Summary](https://nextstrain.org/community/andersen-lab/HCoV-19-Genomics-Nextstrain/hCoV-19/usa/sandiego?c=region&d=tree&legend=open&onlyPanels&p=full&sidebar=closed) + +The problem is the following lines -- adding a character(s) to each line following the link syntax fixes the problem. + +Table of Contents: +1. [Some link](https://nextstrain.org) diff --git a/narratives/test_simultaneous-tree-updates.md b/narratives/test_simultaneous-tree-updates.md new file mode 100644 index 000000000..b9c1ed287 --- /dev/null +++ b/narratives/test_simultaneous-tree-updates.md @@ -0,0 +1,34 @@ +--- +title: Simultaneous Updates to Tree State +authors: + - James Hadfield +authorLinks: + - https://twitter.com/hamesjadfield +affiliations: "Fred Hutch" +dataset: "http://localhost:4000/flu/seasonal/h3n2/ha/3y?d=tree" +date: June 2020 +abstract: "A narrative to explore simultaneous changes to tree state. The aim is both to reveal what's possible, and to prevent future regressions via automated testing." +--- + + +# [P1: Change color-by to num_date]("http://localhost:4000/flu/seasonal/h3n2/ha/3y?d=tree&c=num_date) +Check that both the branches and tips update. + +# [P2: Zoom into clade A1]("http://localhost:4000/flu/seasonal/h3n2/ha/3y?d=tree&c=num_date&label=clade:A1) + +# [P3: Zoom into clade A1b _and_ change color]("http://localhost:4000/flu/seasonal/h3n2/ha/3y?d=tree&label=clade:A1b) +Check that the coloring of the branches and tips update as we zoom in. + +# [P4: Lots of simultaneous changes](http://localhost:4000/flu/seasonal/h3n2/ha/3y?c=lbi&d=tree&dmin=2017-01-01&f_region=North%20America&label=clade:3c2.A&m=div) +* Zoomed out to near the root (clade 3c2.A) +* Changed the horizontal scale to divergence +* Changed the color-by to LBI (and legend should be open) +* Filtered to North American Samples (i.e. the majority of tips are not visible). +* Time slice excludes pre-2017 samples (note that we don't have the grey overlay here since the axis is divergence) + +# [P5: Layout change (and others)](http://localhost:4000/flu/seasonal/h3n2/ha/3y?branchLabel=none&d=tree&l=radial&m=div) +Underneath, this uses a different set of d3 calls where instead of transitioning all elements (branches, tips etc), which is too slow, we do a "in-parts" update: we hide the branches, transition the tips, then redraw the branches in their new position. +This slide should +* switch to radial view +* zoom out to show the entire tree, and remove filters so all tips should be shown +* change the coloring to clade \ No newline at end of file diff --git a/package.json b/package.json index 07bfbf187..cd9b86742 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,7 @@ "lint": "eslint src", "lint:fix": "eslint --fix src", "get-data": "env bash ./scripts/get-data.sh", - "get-narratives": "env bash ./scripts/get-narratives.sh", - "heroku-postbuild": "npm run build && npm run get-data && npm run get-narratives", + "heroku-postbuild": "npm run build && npm run get-data", "rebuild-docker-image": "env bash ./scripts/rebuild-docker-image.sh", "gzip-and-upload": "env bash ./scripts/gzip-and-upload.sh", "build-docs": "echo 'see ./docs-src/README.md'", diff --git a/scripts/get-narratives.sh b/scripts/get-narratives.sh deleted file mode 100755 index 31ae50369..000000000 --- a/scripts/get-narratives.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -function errorFound { - echo -e "\nScript Failed at line $1\n" - exit 2 -} -trap 'errorFound $LINENO' ERR - -if ! [ -d "narratives" ]; then - echo "Creating empty \"narratives\" directory" - mkdir narratives -fi - -if [ "$(ls -A narratives)" ]; then - echo "The \"narratives\" directory is not empty." - echo "This command will overwrite any local changes to narratives which are also in github.com/nextstrain/narratives" - read -p "Do you want to continue? (press y to continue, any other key to exit) " -n 1 -r # $REPLY is automatically set since no variable name is supplied - echo - if [[ ! $REPLY =~ ^[Yy]$ ]] - then - exit 0 - fi -fi - -echo "Downloding narratives from github.com/nextstrain/narratives" -curl -L http://github.com/nextstrain/narratives/archive/master.zip --compressed -o narratives/master.zip -unzip -o -j narratives/master.zip -d narratives -rm narratives/master.zip - -echo "Done. Locally available narratives should be accessible from the splash page (normally localhost:4000)" From a9a60cd4f1890206f6ca9c4bac232a57375b9211 Mon Sep 17 00:00:00 2001 From: james hadfield Date: Tue, 16 Jun 2020 17:51:58 +1200 Subject: [PATCH 5/8] Add a narratives snapshot test This builds on our previous efforts to develop snapshot testing (not being run automatically at the moment). Here we dynamically compare snapshots for each page within a test-narrative. This code may be refactored so that we can easily test a wide range of narratives in this fashion. Changes to the content of the narrative, including the addition of slides, should cause this test to fail, however the screenshots can be regenerated (see DEV_DOCS) without the need to modify the test script itself. --- ...simultaneous-tree-updates-slide-0-snap.png | 3 + ...simultaneous-tree-updates-slide-1-snap.png | 3 + ...simultaneous-tree-updates-slide-2-snap.png | 3 + ...simultaneous-tree-updates-slide-3-snap.png | 3 + ...simultaneous-tree-updates-slide-4-snap.png | 3 + ...simultaneous-tree-updates-slide-5-snap.png | 3 + ...simultaneous-tree-updates-slide-6-snap.png | 3 + test/integration/narratives.test.js | 71 +++++++++++++++++++ 8 files changed, 92 insertions(+) create mode 100644 test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-0-snap.png create mode 100644 test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-1-snap.png create mode 100644 test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-2-snap.png create mode 100644 test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-3-snap.png create mode 100644 test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-4-snap.png create mode 100644 test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-5-snap.png create mode 100644 test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-6-snap.png create mode 100644 test/integration/narratives.test.js diff --git a/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-0-snap.png b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-0-snap.png new file mode 100644 index 000000000..9f9e0705d --- /dev/null +++ b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-0-snap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:66b12f3a86c32147975d385f8401faa8cc1e51476168f355add20707c97d2130 +size 359656 diff --git a/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-1-snap.png b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-1-snap.png new file mode 100644 index 000000000..dd445bbaf --- /dev/null +++ b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-1-snap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1e07b30a4cae21f1e68ba23d4ea16a8592a721a8f17ff8249db2027e79f058d6 +size 330372 diff --git a/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-2-snap.png b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-2-snap.png new file mode 100644 index 000000000..666caa285 --- /dev/null +++ b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-2-snap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4fe9f78c1694bf2880033e7d58461626c7fd6bc80475b3d3f593f135cb36f167 +size 315406 diff --git a/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-3-snap.png b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-3-snap.png new file mode 100644 index 000000000..444bf8ec9 --- /dev/null +++ b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-3-snap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:864a560bea1f346662826f542d29920ada465aabdfc2b582040d20de8afae488 +size 344098 diff --git a/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-4-snap.png b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-4-snap.png new file mode 100644 index 000000000..bc2c4b7b7 --- /dev/null +++ b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-4-snap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f676708c915676dbdfd9997702cc4c12bcbd8b51ed656f9b2cfcf98e4f1ce765 +size 190285 diff --git a/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-5-snap.png b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-5-snap.png new file mode 100644 index 000000000..6c1e0367f --- /dev/null +++ b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-5-snap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:397b9f6bc31b91ca725a851d53c8852d69c77cd9103170e7086df566df470104 +size 500053 diff --git a/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-6-snap.png b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-6-snap.png new file mode 100644 index 000000000..2145769df --- /dev/null +++ b/test/integration/__image_snapshots__/narratives-simultaneous-tree-updates-slide-6-snap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:abfabba1d2fb95843a5cd7f1d43a6b464792704867c0ab58127dcb26e203a80a +size 475448 diff --git a/test/integration/narratives.test.js b/test/integration/narratives.test.js new file mode 100644 index 000000000..1a80f14d3 --- /dev/null +++ b/test/integration/narratives.test.js @@ -0,0 +1,71 @@ +/* eslint-disable no-await-in-loop */ +import { toMatchImageSnapshot } from './helpers'; + +const fetch = require('node-fetch'); + +/** + * The first snapshot test of a narrative. Hopefully there can + * be many more to come -- narratives are a great way to expose + * test lots of functionality and are also useful to explain + * bugs. + */ + +describe("Simultaneous Tree Updates", () => { + + /** + * If we let jest retry tests then understanding the order-of-events gets rather complicated. + * These tests may also take a long time due to the sequential design & the `waitFor` calls. + */ + jest.retryTimes(0); + jest.setTimeout(120000); + + let numberPagesInNarrative; // not including the title page (n=0) or the final page, inserted by the client + beforeAll(async () => { + numberPagesInNarrative = await fetch(`${BASE_URL}/charon/getNarrative?prefix=test/simultaneous-tree-updates`) + .then((res) => res.json()) + .then((res) => res.length); + }); + + beforeEach(async () => { + // Note: The docs https://jestjs.io/docs/en/puppeteer indicate that we should be able to run this set-up + // code in the `beforeAll` block, however this doesn't work for us (reason unknown). + await page.goto(`${BASE_URL}/narratives/test/simultaneous-tree-updates`, { waitUntil: "networkidle2" }); + await expect(page).toMatchElement("#PhylogenyCard"); + }); + + /* note that we cannot dynamically create `it` tests (i.e. in a for loop) -- https://github.com/facebook/jest/issues/1619 */ + it(`Checking that each page in the narrative matches the screenshot`, async () => { + for (let i=0; i<=numberPagesInNarrative; i++) { + // console.log(`-----------------------\nnarratives-simultaneous-tree-updates-slide-${i}`) + await matchScreenshot(`narratives-simultaneous-tree-updates-slide-${i}`); + await page.keyboard.press("ArrowDown"); // move to next slide in preparation for next slide's screenshot + // because transitions happen when navigating between pages, if we don't wait a while then the screenshot + // will be created mid-transition! Ideally this would only run when we're updating screenshots (where is + // this flag stored?), as the comparison function will retry a few times until it matches. + await page.waitFor(5000); + } + }); + +}); + + +async function matchScreenshot(id) { + + await toMatchImageSnapshot( + async () => { + const image = await page.screenshot(); + /** + * (tihuan): Apply `blur` to ignore minor noises. + * Also `customSnapshotIdentifier` is needed, since we use `jest.retryTimes()` + * https://github.com/americanexpress/jest-image-snapshot/pull/122/files + * https://github.com/americanexpress/jest-image-snapshot#%EF%B8%8F-api + */ + const SNAPSHOT_CONFIG = { + blur: 2, + customSnapshotIdentifier: id + }; + expect(image).toMatchImageSnapshot(SNAPSHOT_CONFIG); + } + ); +} + From f599c5159d6424a8a877dd09ef788cfe3c0a9258 Mon Sep 17 00:00:00 2001 From: james hadfield Date: Fri, 19 Jun 2020 15:39:40 +1200 Subject: [PATCH 6/8] changelog --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7430598e9..1d10faf59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,25 @@ title: Changelog --- +* You can now toggle whether the data in the frequencies panel is normalized. +See [PR 1158](https://github.com/nextstrain/auspice/pull/1158). +* You can now set the starting state of the transmissions-line toggle via the JSON or a URL query. +See [PR 1152](https://github.com/nextstrain/auspice/pull/1152) and [PR 1165](https://github.com/nextstrain/auspice/pull/1129). +* Improve the caching settings for the auspice server. +See [PR 1146](https://github.com/nextstrain/auspice/pull/1146). +* The performance of Auspice is improved when transmission lines are not rendered. +See [PR 1153](https://github.com/nextstrain/auspice/pull/1153). +* The "narratives" folder is now part of this repo and contains a number of test narratives. +See [PR 1170](https://github.com/nextstrain/auspice/pull/1170) for more details. +* A bug was fixed where narrative slides would sometimes fail to update the tree as expected. +See [PR 1169](https://github.com/nextstrain/auspice/pull/1169). +* A bug was fixed where loading a tree zoomed to a clade would prevent zooming out. +See [PR 1156](https://github.com/nextstrain/auspice/pull/1156). +* A bug was fixed where numeric branch labels couldn't be used as URL queries. +See [PR 1157](https://github.com/nextstrain/auspice/pull/1157). +* The list of allowed nodejs versions was expanded. +See [PR 1166](https://github.com/nextstrain/auspice/pull/1166). + ## version 2.16.0 - 2020/05/29 #### Features From 18dfb6bde4f7453eec5c7f13c1fde59af3ee1932 Mon Sep 17 00:00:00 2001 From: james hadfield Date: Fri, 19 Jun 2020 15:40:23 +1200 Subject: [PATCH 7/8] version bump to 2.17.0 for release --- CHANGELOG.md | 3 +++ package.json | 2 +- src/version.js | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d10faf59..2c0e8da82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ title: Changelog --- +## version 2.17.0 - 2020/06/19 + + * You can now toggle whether the data in the frequencies panel is normalized. See [PR 1158](https://github.com/nextstrain/auspice/pull/1158). * You can now set the starting state of the transmissions-line toggle via the JSON or a URL query. diff --git a/package.json b/package.json index cd9b86742..861c567e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "auspice", - "version": "2.16.0", + "version": "2.17.0", "description": "Web app for visualizing pathogen evolution", "author": "James Hadfield, Trevor Bedford and Richard Neher", "license": "AGPL-3.0-only", diff --git a/src/version.js b/src/version.js index 97c23437a..2d685e5fa 100644 --- a/src/version.js +++ b/src/version.js @@ -1,4 +1,4 @@ -const version = "2.16.0"; +const version = "2.17.0"; module.exports = { version From ff1447c324bb28c599c63ba19d9ad039be075951 Mon Sep 17 00:00:00 2001 From: james hadfield Date: Fri, 19 Jun 2020 15:46:59 +1200 Subject: [PATCH 8/8] rebuild docs --- .../advanced-functionality/view-settings.html | 3 ++- .../view-settings/index.html | 3 ++- docs/contributing/overview.html | 4 +-- docs/contributing/overview/index.html | 4 +-- docs/introduction/how-to-run.html | 12 ++++----- docs/introduction/how-to-run/index.html | 12 ++++----- docs/introduction/install.html | 9 +++---- docs/introduction/install/index.html | 9 +++---- docs/narratives/create-pdf.html | 4 +-- docs/narratives/create-pdf/index.html | 4 +-- docs/releases/changelog.html | 27 ++++++++++++++++--- docs/releases/changelog/index.html | 27 ++++++++++++++++--- 12 files changed, 78 insertions(+), 40 deletions(-) diff --git a/docs/advanced-functionality/view-settings.html b/docs/advanced-functionality/view-settings.html index b2d351608..08e6217a9 100644 --- a/docs/advanced-functionality/view-settings.html +++ b/docs/advanced-functionality/view-settings.html @@ -90,6 +90,7 @@

nextstrain.org/flu/seasonal/h3n2/ha/2y?c=num_date&d=tree,map&m=div&r=region and you'll see how we've changed the coloring to a temporal scale (c=num_date), we're only showing the tree & map panels (d=tree,map), the tree x-axis is divergence (m=div) and the map resolution is region (r=region).

-
Last updated on 15/04/2020
\ No newline at end of file +
Last updated on 03/06/2020
\ No newline at end of file diff --git a/docs/advanced-functionality/view-settings/index.html b/docs/advanced-functionality/view-settings/index.html index b2d351608..08e6217a9 100644 --- a/docs/advanced-functionality/view-settings/index.html +++ b/docs/advanced-functionality/view-settings/index.html @@ -90,6 +90,7 @@

nextstrain.org/flu/seasonal/h3n2/ha/2y?c=num_date&d=tree,map&m=div&r=region and you'll see how we've changed the coloring to a temporal scale (c=num_date), we're only showing the tree & map panels (d=tree,map), the tree x-axis is divergence (m=div) and the map resolution is region (r=region).

-
Last updated on 15/04/2020
\ No newline at end of file +
Last updated on 03/06/2020
\ No newline at end of file diff --git a/docs/contributing/overview.html b/docs/contributing/overview.html index 34dde9f2d..25e8f3017 100644 --- a/docs/contributing/overview.html +++ b/docs/contributing/overview.html @@ -86,7 +86,7 @@

For integration tests to work, you'll need to have git-lfs installed (see below) as it stores the images that the snapshot tests will use.

    -
  1. Fetch the datasets with npm run get-data and npm run get-narratives.
  2. +
  3. Fetch the datasets with npm run get-data.
  4. Ensure you are not currently running the site locally, then run npm run integration-test:ci.

How to update test snapshots

@@ -96,7 +96,7 @@

<

For smoke tests

    -
  1. Fetch the datasets with npm run get-data and npm run get-narratives.
  2. +
  3. Fetch the datasets with npm run get-data.
  4. Ensure you are not currently running the site locally, then run npm run smoke-test:ci.

Test Tips

diff --git a/docs/contributing/overview/index.html b/docs/contributing/overview/index.html index 34dde9f2d..25e8f3017 100644 --- a/docs/contributing/overview/index.html +++ b/docs/contributing/overview/index.html @@ -86,7 +86,7 @@

For integration tests to work, you'll need to have git-lfs installed (see below) as it stores the images that the snapshot tests will use.

    -
  1. Fetch the datasets with npm run get-data and npm run get-narratives.
  2. +
  3. Fetch the datasets with npm run get-data.
  4. Ensure you are not currently running the site locally, then run npm run integration-test:ci.

How to update test snapshots

@@ -96,7 +96,7 @@

<

For smoke tests

    -
  1. Fetch the datasets with npm run get-data and npm run get-narratives.
  2. +
  3. Fetch the datasets with npm run get-data.
  4. Ensure you are not currently running the site locally, then run npm run smoke-test:ci.

Test Tips

diff --git a/docs/introduction/how-to-run.html b/docs/introduction/how-to-run.html index c2b7d4c71..57fe9ff6f 100644 --- a/docs/introduction/how-to-run.html +++ b/docs/introduction/how-to-run.html @@ -160,10 +160,8 @@

Narratives

For narratives, please see Writing a Narrative for a description of the file format.

Obtaining a Set of Input Files

-

If you'd like to download the datasets and narratives on nextstrain.org then there are two scripts which allow you to do this:

-
    -
  • You can download the dataset JSONs by running this script which will create a ./data directory for you.
  • -
  • You can download the narrative Markdown files by running this script which will create a ./narratives directory for you.
  • -
-

You can then run auspice view --datasetDir data --narrativeDir narratives to visualise all of the nextstrain.org datasets locally.

-
Last updated on 23/05/2020
\ No newline at end of file +

If you'd like to download the dataset JSONs which are behind the core-datasets shown on nextstrain.org, then you can run this script which will create a ./data directory for you.

+

The nextstrain-maintained narratives are stored in the nextstrain/narratives github repo. +You can obtain these by cloning that repo.

+

You can then run auspice view --datasetDir data --narrativeDir <path-to-narratives> to visualise all of the nextstrain.org datasets locally.

+
Last updated on 16/06/2020
\ No newline at end of file diff --git a/docs/introduction/how-to-run/index.html b/docs/introduction/how-to-run/index.html index c2b7d4c71..57fe9ff6f 100644 --- a/docs/introduction/how-to-run/index.html +++ b/docs/introduction/how-to-run/index.html @@ -160,10 +160,8 @@

Narratives

For narratives, please see Writing a Narrative for a description of the file format.

Obtaining a Set of Input Files

-

If you'd like to download the datasets and narratives on nextstrain.org then there are two scripts which allow you to do this:

-
    -
  • You can download the dataset JSONs by running this script which will create a ./data directory for you.
  • -
  • You can download the narrative Markdown files by running this script which will create a ./narratives directory for you.
  • -
-

You can then run auspice view --datasetDir data --narrativeDir narratives to visualise all of the nextstrain.org datasets locally.

-
Last updated on 23/05/2020
\ No newline at end of file +

If you'd like to download the dataset JSONs which are behind the core-datasets shown on nextstrain.org, then you can run this script which will create a ./data directory for you.

+

The nextstrain-maintained narratives are stored in the nextstrain/narratives github repo. +You can obtain these by cloning that repo.

+

You can then run auspice view --datasetDir data --narrativeDir <path-to-narratives> to visualise all of the nextstrain.org datasets locally.

+
Last updated on 16/06/2020
\ No newline at end of file diff --git a/docs/introduction/install.html b/docs/introduction/install.html index 00c86573c..55560fee2 100644 --- a/docs/introduction/install.html +++ b/docs/introduction/install.html @@ -56,7 +56,7 @@ });

Install Auspice

Prerequisites

Auspice is a JavaScript program, and requires Node.js to be installed on your system. -For best results, please use Node.js version 10.

+We've had success running a range of different node versions between 10.8 and 13.

We highly recommend using Conda to manage environments, i.e. use Conda to create an environment with Node.js installed where you can use Auspice. It's possible to use other methods, but this documentation presupposes that you have Conda installed.

To run package scripts, the bash shell and the env command need to be in your PATH. @@ -64,7 +64,7 @@ If you are working from Windows, you can run the installation under Git Bash, MSYS2, or Cygwin. You can also use the Windows Subsystem Linux for a fuller Linux environment.

Create a Conda Environment

-
conda create --name auspice nodejs=10
+
conda create --name auspice nodejs=12
 conda activate auspice
 
@@ -99,10 +99,9 @@

help -# Obtain datasets & narratives to view locally (optional) +# Obtain nextstrain.org datasets to view locally (optional) npm run get-data -npm run get-narratives

Updating Auspice should only require pulling the new version from GitHub -- it shouldn't require any npm commands. You will, however, have to re-build Auspice whenever the client-related code has changed, via auspice build.

-
\ No newline at end of file +
Last updated on 16/06/2020
\ No newline at end of file diff --git a/docs/introduction/install/index.html b/docs/introduction/install/index.html index 00c86573c..55560fee2 100644 --- a/docs/introduction/install/index.html +++ b/docs/introduction/install/index.html @@ -56,7 +56,7 @@ });

Install Auspice

Prerequisites

Auspice is a JavaScript program, and requires Node.js to be installed on your system. -For best results, please use Node.js version 10.

+We've had success running a range of different node versions between 10.8 and 13.

We highly recommend using Conda to manage environments, i.e. use Conda to create an environment with Node.js installed where you can use Auspice. It's possible to use other methods, but this documentation presupposes that you have Conda installed.

To run package scripts, the bash shell and the env command need to be in your PATH. @@ -64,7 +64,7 @@ If you are working from Windows, you can run the installation under Git Bash, MSYS2, or Cygwin. You can also use the Windows Subsystem Linux for a fuller Linux environment.

Create a Conda Environment

-
conda create --name auspice nodejs=10
+
conda create --name auspice nodejs=12
 conda activate auspice
 
@@ -99,10 +99,9 @@

help -# Obtain datasets & narratives to view locally (optional) +# Obtain nextstrain.org datasets to view locally (optional) npm run get-data -npm run get-narratives

Updating Auspice should only require pulling the new version from GitHub -- it shouldn't require any npm commands. You will, however, have to re-build Auspice whenever the client-related code has changed, via auspice build.

-
\ No newline at end of file +
Last updated on 16/06/2020
\ No newline at end of file diff --git a/docs/narratives/create-pdf.html b/docs/narratives/create-pdf.html index e530e9088..af95ac271 100644 --- a/docs/narratives/create-pdf.html +++ b/docs/narratives/create-pdf.html @@ -61,7 +61,7 @@

Decktape to be installed, which itself requires Node.js. If you've followed the auspice install instructions and are using a conda environment then this is straightforward. If not, you can create the necessary conda environment via:

-
conda create --name auspice nodejs=10
+
conda create --name auspice nodejs=12
 

Install Decktape via:

conda activate auspice # or whichever conda environment has nodejs
@@ -95,4 +95,4 @@ 

\ No newline at end of file +
Last updated on 11/06/2020
\ No newline at end of file diff --git a/docs/narratives/create-pdf/index.html b/docs/narratives/create-pdf/index.html index e530e9088..af95ac271 100644 --- a/docs/narratives/create-pdf/index.html +++ b/docs/narratives/create-pdf/index.html @@ -61,7 +61,7 @@

Decktape to be installed, which itself requires Node.js. If you've followed the auspice install instructions and are using a conda environment then this is straightforward. If not, you can create the necessary conda environment via:

-
conda create --name auspice nodejs=10
+
conda create --name auspice nodejs=12
 

Install Decktape via:

conda activate auspice # or whichever conda environment has nodejs
@@ -95,4 +95,4 @@ 

\ No newline at end of file +
Last updated on 11/06/2020
\ No newline at end of file diff --git a/docs/releases/changelog.html b/docs/releases/changelog.html index ac32101a2..5c3f59576 100644 --- a/docs/releases/changelog.html +++ b/docs/releases/changelog.html @@ -1,4 +1,4 @@ -Changelog · Auspice \ No newline at end of file +
Last updated on 14/10/2019
\ No newline at end of file diff --git a/docs/releases/changelog/index.html b/docs/releases/changelog/index.html index ac32101a2..5c3f59576 100644 --- a/docs/releases/changelog/index.html +++ b/docs/releases/changelog/index.html @@ -1,4 +1,4 @@ -Changelog · Auspice \ No newline at end of file +
Last updated on 14/10/2019
\ No newline at end of file