From d522cc8f91f057642846bb75de6f72f9da8e2fb8 Mon Sep 17 00:00:00 2001 From: Charlotte Weaver Date: Thu, 9 May 2019 15:31:55 -0700 Subject: [PATCH] Add clipping test to smoke tests (#757) * Add clipping test to smoke tests * devtools on in debug --- client/__tests__/e2e/data.js | 9 +++++++ client/__tests__/e2e/e2e.test.js | 33 +++++++++++++++++++++++++- client/__tests__/e2e/puppeteerUtils.js | 27 +++++++++++++++++++-- client/package-lock.json | 18 +++++++------- client/package.json | 2 +- client/src/components/graph/graph.js | 4 ++++ 6 files changed, 80 insertions(+), 13 deletions(-) diff --git a/client/__tests__/e2e/data.js b/client/__tests__/e2e/data.js index 796f4357..ba2408bb 100644 --- a/client/__tests__/e2e/data.js +++ b/client/__tests__/e2e/data.js @@ -108,6 +108,15 @@ export const datasets = { count: "24" } } + }, + clip: { + min: "30", + max: "70", + metadata: "n_genes", + gene: "S100A8", + "coordinates-as-percent": { x1: 0.25, y1: 0.5, x2: 0.55, y2: 0.5 }, + count: "392", + "gene-cell-count": "421" } } }; diff --git a/client/__tests__/e2e/e2e.test.js b/client/__tests__/e2e/e2e.test.js index b0665c0b..aa218a55 100644 --- a/client/__tests__/e2e/e2e.test.js +++ b/client/__tests__/e2e/e2e.test.js @@ -182,7 +182,6 @@ describe("diffexp", async () => { ); }); }); -// describe("subset/reset", async () => { test("subset - cell count matches", async () => { @@ -271,6 +270,38 @@ describe("scatter plot", async () => { }); }); +describe("clipping", async () => { + test("clip continuous", async () => { + await cxgActions.clip(data.clip.min, data.clip.max) + const histId = `histogram-${data.clip.metadata}-plot-brush`; + const coords = await cxgActions.calcDragCoordinates( + histId, + data.clip["coordinates-as-percent"] + ); + await cxgActions.drag(histId, coords.start, coords.end); + const cellCount = await cxgActions.cellSet(1); + expect(cellCount).toBe(data.clip.count); + + }); + + test("clip gene", async () => { + await utils.typeInto("gene-search", data.clip.gene); + await page.keyboard.press("Enter"); + await page.waitForSelector( + `[data-testid='histogram-${data.clip.gene}']` + ); + await cxgActions.clip(data.clip.min, data.clip.max) + const histId = `histogram-${data.clip.gene}-plot-brush`; + const coords = await cxgActions.calcDragCoordinates( + histId, + data.clip["coordinates-as-percent"] + ); + await cxgActions.drag(histId, coords.start, coords.end); + const cellCount = await cxgActions.cellSet(1); + expect(cellCount).toBe(data.clip["gene-cell-count"]); + }); +}); + // interact with UI elements just that they do not break describe("ui elements don't error", async () => { test("color by", async () => { diff --git a/client/__tests__/e2e/puppeteerUtils.js b/client/__tests__/e2e/puppeteerUtils.js index 17633c2b..bdc9588c 100644 --- a/client/__tests__/e2e/puppeteerUtils.js +++ b/client/__tests__/e2e/puppeteerUtils.js @@ -16,10 +16,25 @@ export const puppeteerUtils = puppeteerPage => ({ async typeInto(testid, text) { // only works for text without special characters await this.waitByID(testid); + const selector = `[data-testid='${testid}']`; // type ahead can be annoying if you don't pause before you type - await puppeteerPage.click(`[data-testid='${testid}']`); + await puppeteerPage.click(selector); await puppeteerPage.waitFor(200); - await puppeteerPage.type(`[data-testid='${testid}']`, text); + await puppeteerPage.type(selector, text); + }, + + async clearInputAndTypeInto(testid, text) { + await this.waitByID(testid); + const selector = `[data-testid='${testid}']`; + // only works for text without special characters + // type ahead can be annoying if you don't pause before you type + await puppeteerPage.click(selector); + await puppeteerPage.waitFor(200); + // select all + + await puppeteerPage.click(selector, {clickCount: 3}) + await puppeteerPage.keyboard.type("Backspace") + await puppeteerPage.type(selector, text); }, async clickOn(testid) { @@ -161,5 +176,13 @@ export const cellxgeneActions = puppeteerPage => ({ await puppeteerUtils(puppeteerPage).clickOn("reset"); // loading state never actually happens, reset is too fast await page.waitFor(200); + }, + + async clip(min = 0, max = 100) { + await puppeteerUtils(puppeteerPage).clickOn("visualization-settings"); + await puppeteerUtils(puppeteerPage).clearInputAndTypeInto("clip-min-input", min); + await puppeteerUtils(puppeteerPage).clearInputAndTypeInto("clip-max-input", max); + await puppeteerUtils(puppeteerPage).clickOn("clip-commit"); } + }); diff --git a/client/package-lock.json b/client/package-lock.json index d22c74c4..8601992d 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -11318,9 +11318,9 @@ "dev": true }, "puppeteer": { - "version": "1.12.2", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.12.2.tgz", - "integrity": "sha512-xWSyCeD6EazGlfnQweMpM+Hs6X6PhUYhNTHKFj/axNZDq4OmrVERf70isBf7HsnFgB3zOC1+23/8+wCAZYg+Pg==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.15.0.tgz", + "integrity": "sha512-D2y5kwA9SsYkNUmcBzu9WZ4V1SGHiQTmgvDZSx6sRYFsgV25IebL4V6FaHjF6MbwLK9C6f3G3pmck9qmwM8H3w==", "dev": true, "requires": { "debug": "^4.1.0", @@ -11343,15 +11343,15 @@ } }, "mime": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz", - "integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.2.tgz", + "integrity": "sha512-zJBfZDkwRu+j3Pdd2aHsR5GfH2jIWhmL1ZzBoc+X+3JEti2hbArWcyJ+1laC1D2/U/W1a/+Cegj0/OnEU2ybjg==", "dev": true }, "ws": { - "version": "6.1.4", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz", - "integrity": "sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", "dev": true, "requires": { "async-limiter": "~1.0.0" diff --git a/client/package.json b/client/package.json index 3e593d6d..fdb27492 100644 --- a/client/package.json +++ b/client/package.json @@ -104,7 +104,7 @@ "jest-puppeteer": "^4.1.0", "json-loader": "^0.5.4", "mini-css-extract-plugin": "^0.4.1", - "puppeteer": "^1.12.1", + "puppeteer": "^1.15.0", "rimraf": "^2.6.3", "serve-favicon": "^2.3.0", "start-server-and-test": "^1.7.11", diff --git a/client/src/components/graph/graph.js b/client/src/components/graph/graph.js index a87493e7..61fe89a9 100644 --- a/client/src/components/graph/graph.js +++ b/client/src/components/graph/graph.js @@ -898,6 +898,7 @@ class Graph extends React.Component { target={