From 3c7af8e6628e19d769614e6a1afe1135d54e697e Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Mon, 14 Oct 2019 18:32:39 -0400 Subject: [PATCH 01/26] Add initial puppeteer tests --- .github/workflows/test.yml | 14 ++++++++++++++ README.md | 3 +++ jest-puppeteer.config.js | 10 ++++++++++ jest.config.js | 9 +++++++++ jupyter_notebook_config.py | 2 ++ package.json | 10 ++++++++++ src/index.spec.ts | 23 +++++++++++++++++++++++ tsconfig.json | 3 +-- 8 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 jest-puppeteer.config.js create mode 100644 jest.config.js create mode 100644 jupyter_notebook_config.py create mode 100644 src/index.spec.ts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..57c88e3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,14 @@ +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - run: conda create -n jupyterlab-metadata-service -c conda-forge python=3.6 jupyterlab + - run: | + conda activate jupyterlab-metadata-service + jupyter labextension link . + - run: | + conda activate jupyterlab-metadata-service + jlpm run test diff --git a/README.md b/README.md index 8b58ab1..2f3be70 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,9 @@ jupyter labextension link . ../jupyterlab-data-explorer/dataregistry-extension/ // Run Jupyterlab jupyter lab + +# Run tests +jlpm run test ``` ### License diff --git a/jest-puppeteer.config.js b/jest-puppeteer.config.js new file mode 100644 index 0000000..9db25ea --- /dev/null +++ b/jest-puppeteer.config.js @@ -0,0 +1,10 @@ +module.exports = { + launch: { + headless: process.env.HEADLESS !== "false" + }, + // https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-dev-server#options + server: { + command: "jupyter lab --port 8080 --no-browser", + port: 8080 + } +}; diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..448ff17 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,9 @@ +const { defaults: tsjPreset } = require("ts-jest/presets"); + +module.exports = { + rootDir: "src", + preset: "jest-puppeteer", + transform: { + ...tsjPreset.transform + } +}; diff --git a/jupyter_notebook_config.py b/jupyter_notebook_config.py new file mode 100644 index 0000000..d955109 --- /dev/null +++ b/jupyter_notebook_config.py @@ -0,0 +1,2 @@ +c.NotebookApp.token = '' +c.NotebookApp.password = '' diff --git a/package.json b/package.json index e92179a..a5e75b4 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,8 @@ "build": "tsc", "watch": "tsc -w", "lint": "stylelint style.css", + "test": "jlpm jest --runInBand", + "test:debug": "env HEADLESS=false jlpm test", "clean": "rimraf lib tsconfig.tsbuildinfo", "prepare": "npm run clean && jlpm run lint && npm run build" }, @@ -54,11 +56,19 @@ }, "devDependencies": { "@jupyterlab/dataregistry-extension": "^3.0.0", + "@types/expect-puppeteer": "3.3.2", + "@types/jest": "24.0.19", + "@types/jest-environment-puppeteer": "4.3.1", "@types/jsonld": "1.5.0", + "@types/puppeteer": "1.20.2", + "jest": "24.9.0", + "jest-puppeteer": "4.3.0", + "puppeteer": "1.20.0", "rimraf": "~2.6.2", "stylelint": "11.0.0", "stylelint-config-prettier": "6.0.0", "stylelint-config-standard": "19.0.0", + "ts-jest": "24.1.0", "typescript": "~3.3.1" }, "publishConfig": { diff --git a/src/index.spec.ts b/src/index.spec.ts new file mode 100644 index 0000000..cc1ce8f --- /dev/null +++ b/src/index.spec.ts @@ -0,0 +1,23 @@ +const { setDefaultOptions } = require("expect-puppeteer"); + +const timeout = 10 * 1000; + +jest.setTimeout(timeout); +setDefaultOptions({ timeout }); + +describe("JupyterLab", () => { + beforeAll(async () => { + await page.goto("http://localhost:8080/lab"); + }); + + it("should show JupyterLab logo", async () => { + expect.assertions(1); + await expect(page).toMatchElement("#jp-MainLogo"); + }); + + it("show be able to click on datasets", async () => { + expect.assertions(2); + await expect(page).toClick('[title="Data Explorer"]'); + await expect(page).toMatch("Datasets"); + }); +}); diff --git a/tsconfig.json b/tsconfig.json index 5af1706..868169a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,6 @@ "strict": true, "strictNullChecks": true, "target": "es2017", - "types": [] }, - "include": ["src/*"] + "include": ["src/*",] } From 709833bb3d41782f5d9305e6b00a14fe63c12b30 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Mon, 14 Oct 2019 18:37:25 -0400 Subject: [PATCH 02/26] Switch to use pip instead of conda in CI --- .github/workflows/test.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 57c88e3..0502720 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,10 +5,13 @@ jobs: steps: - uses: actions/checkout@v1 - - run: conda create -n jupyterlab-metadata-service -c conda-forge python=3.6 jupyterlab - - run: | - conda activate jupyterlab-metadata-service - jupyter labextension link . - - run: | - conda activate jupyterlab-metadata-service - jlpm run test + - uses: actions/setup-python@v1 + with: + python-version: "3.6" + - uses: actions/setup-node@v1 + with: + node-version: "10.x" + - run: python -m pip install --upgrade pip + - run: pip install jupyterlab + - run: jupyter labextension link . + - run: jlpm run test From 1d96d187a621c8bd1d504c4a0017e537ee2f15f3 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Mon, 14 Oct 2019 18:46:17 -0400 Subject: [PATCH 03/26] Try printing debug logs --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0502720..d73e5c8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,5 +13,7 @@ jobs: node-version: "10.x" - run: python -m pip install --upgrade pip - run: pip install jupyterlab - - run: jupyter labextension link . + - run: jupyter labextension link . --debug-log-path log.txt + - if: failure() + run: cat log.txt - run: jlpm run test From 858f86638cea6f864aa3cbb856ea7c92a9cb3142 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Mon, 14 Oct 2019 18:49:26 -0400 Subject: [PATCH 04/26] Install dataregistry as well --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d73e5c8..7e71a35 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: node-version: "10.x" - run: python -m pip install --upgrade pip - run: pip install jupyterlab - - run: jupyter labextension link . --debug-log-path log.txt + - run: jupyter labextension install . @jupyterlab/dataregistry-extension --debug-log-path log.txt - if: failure() run: cat log.txt - run: jlpm run test From eb48925746012c6e1ee09fee0333c23d63a7cde6 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Mon, 14 Oct 2019 18:52:04 -0400 Subject: [PATCH 05/26] auto forrmat --- tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 868169a..195c0d8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,7 @@ "lib": ["dom", "esnext"], "strict": true, "strictNullChecks": true, - "target": "es2017", + "target": "es2017" }, - "include": ["src/*",] + "include": ["src/*"] } From 36645aa48f22853c85c9c273efc5ac35e07299a8 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Mon, 14 Oct 2019 19:32:32 -0400 Subject: [PATCH 06/26] Try adding more tests to datasets --- src/index.spec.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/index.spec.ts b/src/index.spec.ts index cc1ce8f..67437ed 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -15,9 +15,26 @@ describe("JupyterLab", () => { await expect(page).toMatchElement("#jp-MainLogo"); }); - it("show be able to click on datasets", async () => { + it("show be able to show Dataset Explorer tab", async () => { expect.assertions(2); await expect(page).toClick('[title="Data Explorer"]'); await expect(page).toMatch("Datasets"); }); + + it("should see files marker", async () => { + expect.assertions(1); + await expect(page).toMatchElement("h3", { text: "file:///" }); + }); + + it("should be able to expand files", async () => { + expect.assertions(2); + const fileButtons = await page.$x('//button[../h3/text()="file:///"]'); + await expect(fileButtons.length).toBe(1); + await expect(fileButtons[0]).toClick("button"); + }); + + it("should see datasets.yml marker", async () => { + expect.assertions(1); + await expect(page).toMatch("datasets.yml"); + }); }); From c38ed0a9f8016d2d9d04c9fb9225f2be3d979b99 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Tue, 15 Oct 2019 10:27:51 -0400 Subject: [PATCH 07/26] Reset workspace for tests --- src/index.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.spec.ts b/src/index.spec.ts index 67437ed..8caea83 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -7,7 +7,7 @@ setDefaultOptions({ timeout }); describe("JupyterLab", () => { beforeAll(async () => { - await page.goto("http://localhost:8080/lab"); + await page.goto("http://localhost:8080/lab?reset"); }); it("should show JupyterLab logo", async () => { From 37c3b5c80a98f5b04da35020b24fd78fc8df35b6 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Tue, 15 Oct 2019 12:47:24 -0400 Subject: [PATCH 08/26] Fix clicking on file button --- src/index.spec.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/index.spec.ts b/src/index.spec.ts index 8caea83..d39750d 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -27,14 +27,15 @@ describe("JupyterLab", () => { }); it("should be able to expand files", async () => { - expect.assertions(2); - const fileButtons = await page.$x('//button[../h3/text()="file:///"]'); - await expect(fileButtons.length).toBe(1); - await expect(fileButtons[0]).toClick("button"); + expect.assertions(1); + await page.waitForXPath('//button[../h3/text()="file:///"]') + const filebuttons = await page.$x('//button[../h3/text()="file:///"]'); + expect(filebuttons.length).toBe(1) + await filebuttons[0].click(); }); it("should see datasets.yml marker", async () => { expect.assertions(1); - await expect(page).toMatch("datasets.yml"); + await expect(page).toMatchElement("h3", { text: "datasets.yml" }); }); }); From e7536d7891b86dddafb7dd94abf947fb79a0609f Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Tue, 15 Oct 2019 12:57:13 -0400 Subject: [PATCH 09/26] Expand datasets as well --- src/index.spec.ts | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/index.spec.ts b/src/index.spec.ts index d39750d..107cfb2 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -1,3 +1,5 @@ +import { ElementHandle } from "puppeteer"; + const { setDefaultOptions } = require("expect-puppeteer"); const timeout = 10 * 1000; @@ -5,6 +7,15 @@ const timeout = 10 * 1000; jest.setTimeout(timeout); setDefaultOptions({ timeout }); + +async function getXPath(xpath: string): Promise> { + await page.waitForXPath(xpath) + const elements = await page.$x(xpath); + expect(elements.length).toBe(1) + return elements[0] +} + + describe("JupyterLab", () => { beforeAll(async () => { await page.goto("http://localhost:8080/lab?reset"); @@ -15,7 +26,7 @@ describe("JupyterLab", () => { await expect(page).toMatchElement("#jp-MainLogo"); }); - it("show be able to show Dataset Explorer tab", async () => { + it("show be able to show 'Data Explorer' tab", async () => { expect.assertions(2); await expect(page).toClick('[title="Data Explorer"]'); await expect(page).toMatch("Datasets"); @@ -28,14 +39,31 @@ describe("JupyterLab", () => { it("should be able to expand files", async () => { expect.assertions(1); - await page.waitForXPath('//button[../h3/text()="file:///"]') - const filebuttons = await page.$x('//button[../h3/text()="file:///"]'); - expect(filebuttons.length).toBe(1) - await filebuttons[0].click(); + const filebutton = await getXPath('//button[../h3/text()="file:///"]'); + await filebutton.click(); }); it("should see datasets.yml marker", async () => { expect.assertions(1); await expect(page).toMatchElement("h3", { text: "datasets.yml" }); }); + + + it("should be able to expand datasets.yml", async () => { + expect.assertions(1); + const datasetsButton = await getXPath('//button[../h3/text()="datasets.yml"]'); + await datasetsButton.click(); + }); + + it("should show datasets label", async () => { + expect.assertions(1); + await expect(page).toMatchElement("h3", { text: "A Publication" }); + }); + + it("show be able to show 'Data Browser' tab", async () => { + expect.assertions(2); + await expect(page).toClick('[title="Data Browser"]'); + await expect(page).toMatch("Follow active?"); + }); + }); From a40b3521a6c6542c255c2ec678cfab564fc04615 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Tue, 15 Oct 2019 13:38:50 -0400 Subject: [PATCH 10/26] Take screenshots on failure --- .github/workflows/test.yml | 5 +++++ .gitignore | 1 + jest-environment.js | 30 ++++++++++++++++++++++++++++++ jest.config.js | 5 +++++ package.json | 2 ++ 5 files changed, 43 insertions(+) create mode 100644 jest-environment.js diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7e71a35..394a002 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,3 +17,8 @@ jobs: - if: failure() run: cat log.txt - run: jlpm run test + - if: failure() + uses: actions/upload-artifact@v1 + with: + name: screenshots + path: screenshots \ No newline at end of file diff --git a/.gitignore b/.gitignore index 28aa8ea..04db1cc 100644 --- a/.gitignore +++ b/.gitignore @@ -111,3 +111,4 @@ node_modules/ # npm yarn.lock package-lock.json +screenshots diff --git a/jest-environment.js b/jest-environment.js new file mode 100644 index 0000000..0a3c107 --- /dev/null +++ b/jest-environment.js @@ -0,0 +1,30 @@ +// Copied from https://yarnpkg.com/en/package/@rws-air/jestscreenshot +// jest-environment.ts + +const PuppeteerEnvironment = require("jest-environment-puppeteer"); +const JestScreenshot = require("@rws-air/jestscreenshot"); +require("jest-circus"); + +// @ts-ignore +class CustomEnvironment extends PuppeteerEnvironment { + async teardown() { + await this.global.page.waitFor(2000); + await super.teardown(); + } + + async handleTestEvent(event, state) { + if (event.name === "test_fn_failure") { + const testName = state.currentlyRunningTest.name; + + const jestScreenshot = new JestScreenshot({ + page: this.global.page, + dirName: __dirname, + testName + }); + + await jestScreenshot.setup(); + } + } +} + +module.exports = CustomEnvironment; diff --git a/jest.config.js b/jest.config.js index 448ff17..2e6408a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,6 +3,11 @@ const { defaults: tsjPreset } = require("ts-jest/presets"); module.exports = { rootDir: "src", preset: "jest-puppeteer", + + // Needed for jest-screenshots + testRunner: 'jest-circus/runner', + + testEnvironment: '../jest-environment.js', transform: { ...tsjPreset.transform } diff --git a/package.json b/package.json index a5e75b4..fc2512b 100644 --- a/package.json +++ b/package.json @@ -56,12 +56,14 @@ }, "devDependencies": { "@jupyterlab/dataregistry-extension": "^3.0.0", + "@rws-air/jestscreenshot": "3.0.3", "@types/expect-puppeteer": "3.3.2", "@types/jest": "24.0.19", "@types/jest-environment-puppeteer": "4.3.1", "@types/jsonld": "1.5.0", "@types/puppeteer": "1.20.2", "jest": "24.9.0", + "jest-circus": "24.9.0", "jest-puppeteer": "4.3.0", "puppeteer": "1.20.0", "rimraf": "~2.6.2", From 75d76249677e9b532fdb9d69b7a157153eb6cafb Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Tue, 15 Oct 2019 13:42:54 -0400 Subject: [PATCH 11/26] Add name for screenshots step --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 394a002..f2b57cf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,8 @@ jobs: - if: failure() run: cat log.txt - run: jlpm run test - - if: failure() + - name: upload screenshots + if: failure() uses: actions/upload-artifact@v1 with: name: screenshots From 113c6a3d6047c2e2a33e3b9d45b162c68cb55ea7 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Tue, 15 Oct 2019 13:42:58 -0400 Subject: [PATCH 12/26] Clean up screenshots --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fc2512b..746604c 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "lint": "stylelint style.css", "test": "jlpm jest --runInBand", "test:debug": "env HEADLESS=false jlpm test", - "clean": "rimraf lib tsconfig.tsbuildinfo", + "clean": "rimraf lib tsconfig.tsbuildinfo screenshots", "prepare": "npm run clean && jlpm run lint && npm run build" }, "dependencies": { From 15b395bf0871a8a6af3325eb52a0e7860167abee Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Tue, 15 Oct 2019 15:32:27 -0400 Subject: [PATCH 13/26] Increase timeout --- jest-environment.js | 4 +--- src/index.spec.ts | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/jest-environment.js b/jest-environment.js index 0a3c107..c40b396 100644 --- a/jest-environment.js +++ b/jest-environment.js @@ -1,11 +1,9 @@ -// Copied from https://yarnpkg.com/en/package/@rws-air/jestscreenshot -// jest-environment.ts +// Based on from https://yarnpkg.com/en/package/@rws-air/jestscreenshot const PuppeteerEnvironment = require("jest-environment-puppeteer"); const JestScreenshot = require("@rws-air/jestscreenshot"); require("jest-circus"); -// @ts-ignore class CustomEnvironment extends PuppeteerEnvironment { async teardown() { await this.global.page.waitFor(2000); diff --git a/src/index.spec.ts b/src/index.spec.ts index 107cfb2..a67f2e2 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -2,7 +2,7 @@ import { ElementHandle } from "puppeteer"; const { setDefaultOptions } = require("expect-puppeteer"); -const timeout = 10 * 1000; +const timeout = 20 * 1000; jest.setTimeout(timeout); setDefaultOptions({ timeout }); From 624603f5b720701dddb97edf39deb758e98d2cd9 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Tue, 15 Oct 2019 16:46:57 -0400 Subject: [PATCH 14/26] Require elements to be visible in tests --- src/index.spec.ts | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/index.spec.ts b/src/index.spec.ts index a67f2e2..84a3d00 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -2,20 +2,18 @@ import { ElementHandle } from "puppeteer"; const { setDefaultOptions } = require("expect-puppeteer"); -const timeout = 20 * 1000; +const timeout = 5 * 1000; jest.setTimeout(timeout); setDefaultOptions({ timeout }); - async function getXPath(xpath: string): Promise> { - await page.waitForXPath(xpath) + await page.waitForXPath(xpath); const elements = await page.$x(xpath); - expect(elements.length).toBe(1) - return elements[0] + expect(elements.length).toBe(1); + return elements[0]; } - describe("JupyterLab", () => { beforeAll(async () => { await page.goto("http://localhost:8080/lab?reset"); @@ -23,18 +21,24 @@ describe("JupyterLab", () => { it("should show JupyterLab logo", async () => { expect.assertions(1); - await expect(page).toMatchElement("#jp-MainLogo"); + await expect(page).toMatchElement("#jp-MainLogo", { visible: true } as any); }); it("show be able to show 'Data Explorer' tab", async () => { expect.assertions(2); await expect(page).toClick('[title="Data Explorer"]'); - await expect(page).toMatch("Datasets"); + await expect(page).toMatchElement(".jl-explorer-heading", { + text: "Datasets", + visible: true + } as any); }); it("should see files marker", async () => { expect.assertions(1); - await expect(page).toMatchElement("h3", { text: "file:///" }); + await expect(page).toMatchElement("h3", { + text: "file:///", + visible: true + } as any); }); it("should be able to expand files", async () => { @@ -45,25 +49,34 @@ describe("JupyterLab", () => { it("should see datasets.yml marker", async () => { expect.assertions(1); - await expect(page).toMatchElement("h3", { text: "datasets.yml" }); + await expect(page).toMatchElement("h3", { + text: "datasets.yml", + visible: true + } as any); }); - it("should be able to expand datasets.yml", async () => { expect.assertions(1); - const datasetsButton = await getXPath('//button[../h3/text()="datasets.yml"]'); + const datasetsButton = await getXPath( + '//button[../h3/text()="datasets.yml"]' + ); await datasetsButton.click(); }); it("should show datasets label", async () => { expect.assertions(1); - await expect(page).toMatchElement("h3", { text: "A Publication" }); + await expect(page).toMatchElement("h3", { + text: "A Publication", + visible: true + } as any); }); it("show be able to show 'Data Browser' tab", async () => { expect.assertions(2); await expect(page).toClick('[title="Data Browser"]'); - await expect(page).toMatch("Follow active?"); + await expect(page).toMatchElement(".jl-dr-browser", { + text: "Follow active?", + visible: true + } as any); }); - }); From a7387c05ab5c8999f9cacd4a485af84fe26f31f5 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Tue, 15 Oct 2019 16:55:07 -0400 Subject: [PATCH 15/26] Add sleep --- src/index.spec.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.spec.ts b/src/index.spec.ts index 84a3d00..1c8c0de 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -14,9 +14,13 @@ async function getXPath(xpath: string): Promise> { return elements[0]; } +function sleep(ms: number): Promise { + return new Promise(resolve => setTimeout(resolve, ms)); +} describe("JupyterLab", () => { beforeAll(async () => { await page.goto("http://localhost:8080/lab?reset"); + await sleep(1000); }); it("should show JupyterLab logo", async () => { From 581d9989fb9691c76fd3b7373f00389c082085e9 Mon Sep 17 00:00:00 2001 From: kgryte Date: Wed, 23 Oct 2019 16:09:04 -0700 Subject: [PATCH 16/26] Remove unused file --- jupyter_notebook_config.py | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 jupyter_notebook_config.py diff --git a/jupyter_notebook_config.py b/jupyter_notebook_config.py deleted file mode 100644 index d955109..0000000 --- a/jupyter_notebook_config.py +++ /dev/null @@ -1,2 +0,0 @@ -c.NotebookApp.token = '' -c.NotebookApp.password = '' From 33990ab3a336648f66402f2556b09f3d7693b67d Mon Sep 17 00:00:00 2001 From: kgryte Date: Wed, 23 Oct 2019 16:17:40 -0700 Subject: [PATCH 17/26] Move file --- src/index.spec.ts => test/index.test.ts | 42 ++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) rename src/index.spec.ts => test/index.test.ts (59%) diff --git a/src/index.spec.ts b/test/index.test.ts similarity index 59% rename from src/index.spec.ts rename to test/index.test.ts index 1c8c0de..ba7b4d1 100644 --- a/src/index.spec.ts +++ b/test/index.test.ts @@ -1,6 +1,6 @@ -import { ElementHandle } from "puppeteer"; +import { ElementHandle } from 'puppeteer'; -const { setDefaultOptions } = require("expect-puppeteer"); +const { setDefaultOptions } = require('expect-puppeteer'); const timeout = 5 * 1000; @@ -17,49 +17,49 @@ async function getXPath(xpath: string): Promise> { function sleep(ms: number): Promise { return new Promise(resolve => setTimeout(resolve, ms)); } -describe("JupyterLab", () => { +describe('JupyterLab', () => { beforeAll(async () => { - await page.goto("http://localhost:8080/lab?reset"); + await page.goto('http://localhost:8080/lab?reset'); await sleep(1000); }); - it("should show JupyterLab logo", async () => { + it('should show JupyterLab logo', async () => { expect.assertions(1); - await expect(page).toMatchElement("#jp-MainLogo", { visible: true } as any); + await expect(page).toMatchElement('#jp-MainLogo', { visible: true } as any); }); it("show be able to show 'Data Explorer' tab", async () => { expect.assertions(2); await expect(page).toClick('[title="Data Explorer"]'); - await expect(page).toMatchElement(".jl-explorer-heading", { - text: "Datasets", + await expect(page).toMatchElement('.jl-explorer-heading', { + text: 'Datasets', visible: true } as any); }); - it("should see files marker", async () => { + it('should see files marker', async () => { expect.assertions(1); - await expect(page).toMatchElement("h3", { - text: "file:///", + await expect(page).toMatchElement('h3', { + text: 'file:///', visible: true } as any); }); - it("should be able to expand files", async () => { + it('should be able to expand files', async () => { expect.assertions(1); const filebutton = await getXPath('//button[../h3/text()="file:///"]'); await filebutton.click(); }); - it("should see datasets.yml marker", async () => { + it('should see datasets.yml marker', async () => { expect.assertions(1); - await expect(page).toMatchElement("h3", { - text: "datasets.yml", + await expect(page).toMatchElement('h3', { + text: 'datasets.yml', visible: true } as any); }); - it("should be able to expand datasets.yml", async () => { + it('should be able to expand datasets.yml', async () => { expect.assertions(1); const datasetsButton = await getXPath( '//button[../h3/text()="datasets.yml"]' @@ -67,10 +67,10 @@ describe("JupyterLab", () => { await datasetsButton.click(); }); - it("should show datasets label", async () => { + it('should show datasets label', async () => { expect.assertions(1); - await expect(page).toMatchElement("h3", { - text: "A Publication", + await expect(page).toMatchElement('h3', { + text: 'A Publication', visible: true } as any); }); @@ -78,8 +78,8 @@ describe("JupyterLab", () => { it("show be able to show 'Data Browser' tab", async () => { expect.assertions(2); await expect(page).toClick('[title="Data Browser"]'); - await expect(page).toMatchElement(".jl-dr-browser", { - text: "Follow active?", + await expect(page).toMatchElement('.jl-dr-browser', { + text: 'Follow active?', visible: true } as any); }); From 99c4b2b364c75771870f9c90eca55802c2e0e3be Mon Sep 17 00:00:00 2001 From: kgryte Date: Wed, 23 Oct 2019 18:50:36 -0700 Subject: [PATCH 18/26] Move test file and update configuration --- .editorconfig | 3 ++- jest-environment.js | 17 ++++++++++---- jest-puppeteer.config.js | 18 ++++++++++++--- jest.config.js | 36 +++++++++++++++++++++++------- test/{index.test.ts => ui/test.ts} | 7 ++++++ tsconfig.test.json | 8 +++++++ 6 files changed, 73 insertions(+), 16 deletions(-) rename test/{index.test.ts => ui/test.ts} (94%) create mode 100644 tsconfig.test.json diff --git a/.editorconfig b/.editorconfig index 148b389..8ef8dba 100644 --- a/.editorconfig +++ b/.editorconfig @@ -19,7 +19,8 @@ insert_final_newline = true # Set properties for JavaScript files: [*.js] -indent_style = tab +indent_style = space +indent_size = 2 # Set properties for TypeScript files: [*.ts] diff --git a/jest-environment.js b/jest-environment.js index c40b396..c12357f 100644 --- a/jest-environment.js +++ b/jest-environment.js @@ -1,8 +1,14 @@ +/** + * @license BSD-3-Clause + * + * Copyright (c) 2019 Project Jupyter Contributors. + * Distributed under the terms of the 3-Clause BSD License. + */ + // Based on from https://yarnpkg.com/en/package/@rws-air/jestscreenshot -const PuppeteerEnvironment = require("jest-environment-puppeteer"); -const JestScreenshot = require("@rws-air/jestscreenshot"); -require("jest-circus"); +const PuppeteerEnvironment = require('jest-environment-puppeteer'); +const JestScreenshot = require('@rws-air/jestscreenshot'); class CustomEnvironment extends PuppeteerEnvironment { async teardown() { @@ -11,7 +17,7 @@ class CustomEnvironment extends PuppeteerEnvironment { } async handleTestEvent(event, state) { - if (event.name === "test_fn_failure") { + if (event.name === 'test_fn_failure') { const testName = state.currentlyRunningTest.name; const jestScreenshot = new JestScreenshot({ @@ -25,4 +31,7 @@ class CustomEnvironment extends PuppeteerEnvironment { } } +/** + * Exports. + */ module.exports = CustomEnvironment; diff --git a/jest-puppeteer.config.js b/jest-puppeteer.config.js index 9db25ea..c9a661e 100644 --- a/jest-puppeteer.config.js +++ b/jest-puppeteer.config.js @@ -1,10 +1,22 @@ -module.exports = { +/** + * @license BSD-3-Clause + * + * Copyright (c) 2019 Project Jupyter Contributors. + * Distributed under the terms of the 3-Clause BSD License. + */ + +const config = { launch: { - headless: process.env.HEADLESS !== "false" + headless: process.env.HEADLESS !== 'false' }, // https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-dev-server#options server: { - command: "jupyter lab --port 8080 --no-browser", + command: 'jupyter lab --port 8080 --no-browser', port: 8080 } }; + +/** + * Exports. + */ +module.exports = config; diff --git a/jest.config.js b/jest.config.js index 2e6408a..89b7c61 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,14 +1,34 @@ -const { defaults: tsjPreset } = require("ts-jest/presets"); +/** + * @license BSD-3-Clause + * + * Copyright (c) 2019 Project Jupyter Contributors. + * Distributed under the terms of the 3-Clause BSD License. + */ -module.exports = { - rootDir: "src", - preset: "jest-puppeteer", - - // Needed for jest-screenshots +const { defaults: tsjPreset } = require('ts-jest/presets'); + +const config = { + preset: 'jest-puppeteer', + rootDir: '.', + + // Needed for jest-screenshots testRunner: 'jest-circus/runner', - - testEnvironment: '../jest-environment.js', + + testEnvironment: './jest-environment.js', transform: { ...tsjPreset.transform + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], + testMatch: ['**/test/**/test*.ts?(x)'], + testPathIgnorePatterns: ['/build/', '/lib/', '/node_modules/'], + globals: { + 'ts-jest': { + tsConfig: './tsconfig.test.json' + } } }; + +/** + * Exports. + */ +module.exports = config; diff --git a/test/index.test.ts b/test/ui/test.ts similarity index 94% rename from test/index.test.ts rename to test/ui/test.ts index ba7b4d1..6139d0a 100644 --- a/test/index.test.ts +++ b/test/ui/test.ts @@ -1,3 +1,10 @@ +/** + * @license BSD-3-Clause + * + * Copyright (c) 2019 Project Jupyter Contributors. + * Distributed under the terms of the 3-Clause BSD License. + */ + import { ElementHandle } from 'puppeteer'; const { setDefaultOptions } = require('expect-puppeteer'); diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 0000000..856ebbb --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "build/test", + "rootDir": "test" + }, + "include": ["test/*", "test/**/*"] +} From e7aa5119a8768d397198fb3454b6eaa5b6efb8a9 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Thu, 24 Oct 2019 13:55:57 -0400 Subject: [PATCH 19/26] Try removing preset! --- jest.config.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/jest.config.js b/jest.config.js index 2e6408a..3d900bd 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,12 +2,15 @@ const { defaults: tsjPreset } = require("ts-jest/presets"); module.exports = { rootDir: "src", - preset: "jest-puppeteer", - - // Needed for jest-screenshots - testRunner: 'jest-circus/runner', - - testEnvironment: '../jest-environment.js', + + // Needed for jest-screenshots + // https://yarnpkg.com/en/package/@rws-air/jestscreenshot + testRunner: "jest-circus/runner", + + globalSetup: "jest-environment-puppeteer/setup", + globalTeardown: "jest-environment-puppeteer/teardown", + testEnvironment: "../jest-environment.js", + setupFilesAfterEnv: ["expect-puppeteer"], transform: { ...tsjPreset.transform } From eb9642046f9a9c82e9eacd00c0b628081b43d742 Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Thu, 24 Oct 2019 14:44:45 -0400 Subject: [PATCH 20/26] fix environment --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5a61f84..c2412e5 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "dependencies": { "@jupyterlab/application": "^1.0.0", "@phosphor/coreutils": "^1.3.0", + "jest-environment-puppeteer": "4.3.0", "jsonld": "1.6.2", "react": "^16.4.2" }, @@ -80,20 +81,20 @@ "@types/jsonld": "1.5.0", "@types/puppeteer": "1.20.2", "husky": "^3.0.9", - "lint-staged": "^9.4.2", "jest": "24.9.0", "jest-circus": "24.9.0", "jest-puppeteer": "4.3.0", + "lint-staged": "^9.4.2", "prettier": "^1.18.2", "puppeteer": "1.20.0", "rimraf": "~2.6.2", "stylelint": "11.0.0", "stylelint-config-prettier": "6.0.0", "stylelint-config-standard": "19.0.0", + "ts-jest": "24.1.0", "tslint": "^5.20.0", "tslint-config-prettier": "^1.18.0", "tslint-plugin-prettier": "^2.0.1", - "ts-jest": "24.1.0", "typescript": "~3.3.1" }, "publishConfig": { From c8bd7706bf10cd5a910f434158d83cd51357cb3c Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Thu, 24 Oct 2019 14:59:34 -0400 Subject: [PATCH 21/26] update tests --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f2b57cf..674bd1e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,7 @@ jobs: node-version: "10.x" - run: python -m pip install --upgrade pip - run: pip install jupyterlab + - run: jlpm run build - run: jupyter labextension install . @jupyterlab/dataregistry-extension --debug-log-path log.txt - if: failure() run: cat log.txt @@ -22,4 +23,4 @@ jobs: uses: actions/upload-artifact@v1 with: name: screenshots - path: screenshots \ No newline at end of file + path: screenshots From a16bb332d1726b25be23f16061a10d356f127847 Mon Sep 17 00:00:00 2001 From: kgryte Date: Thu, 24 Oct 2019 14:16:46 -0700 Subject: [PATCH 22/26] Debug tests --- jest-environment.js | 3 +++ jest-puppeteer.config.js | 5 +++-- jest.config.js | 5 ++++- package.json | 2 +- test/ui/test.ts | 28 ++++++++++++++++++++++++---- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/jest-environment.js b/jest-environment.js index c12357f..df1d6b4 100644 --- a/jest-environment.js +++ b/jest-environment.js @@ -11,6 +11,9 @@ const PuppeteerEnvironment = require('jest-environment-puppeteer'); const JestScreenshot = require('@rws-air/jestscreenshot'); class CustomEnvironment extends PuppeteerEnvironment { + async setup() { + await super.setup(); + } async teardown() { await this.global.page.waitFor(2000); await super.teardown(); diff --git a/jest-puppeteer.config.js b/jest-puppeteer.config.js index c9a661e..cc843ca 100644 --- a/jest-puppeteer.config.js +++ b/jest-puppeteer.config.js @@ -7,11 +7,12 @@ const config = { launch: { - headless: process.env.HEADLESS !== 'false' + headless: process.env.HEADLESS !== 'false', + slowMo: true }, // https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-dev-server#options server: { - command: 'jupyter lab --port 8080 --no-browser', + command: "jupyter lab --port 8080 --no-browser --LabApp.token=''", port: 8080 } }; diff --git a/jest.config.js b/jest.config.js index 89b7c61..c95771f 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,13 +8,16 @@ const { defaults: tsjPreset } = require('ts-jest/presets'); const config = { - preset: 'jest-puppeteer', rootDir: '.', // Needed for jest-screenshots testRunner: 'jest-circus/runner', testEnvironment: './jest-environment.js', + globalSetup: 'jest-environment-puppeteer/setup', + globalTeardown: 'jest-environment-puppeteer/teardown', + setupFilesAfterEnv: ['expect-puppeteer'], + transform: { ...tsjPreset.transform }, diff --git a/package.json b/package.json index 852b7c4..67902b4 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "prettier": "prettier --write '**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}'", "prettier:check": "prettier --list-different '**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}'", "rebuild:packages": "jlpm run clean:packages && jlpm run build:packages", - "test": "jlpm jest --runInBand", + "test": "jlpm jest --runInBand --verbose", "test:debug": "env HEADLESS=false jlpm test", "uninstall:extensions": "jupyter labextension uninstall --all --no-build", "unlink": "jlpm run unlink:packages", diff --git a/test/ui/test.ts b/test/ui/test.ts index 6139d0a..35f98c0 100644 --- a/test/ui/test.ts +++ b/test/ui/test.ts @@ -9,7 +9,7 @@ import { ElementHandle } from 'puppeteer'; const { setDefaultOptions } = require('expect-puppeteer'); -const timeout = 5 * 1000; +const timeout = 15 * 1000; jest.setTimeout(timeout); setDefaultOptions({ timeout }); @@ -28,6 +28,26 @@ describe('JupyterLab', () => { beforeAll(async () => { await page.goto('http://localhost:8080/lab?reset'); await sleep(1000); + let el = await page.$('[title="Data Explorer"]'); + if (el !== null) { + await el.click(); + const box = await el.boundingBox(); + if (box !== null) { + await page.mouse.move(box.x, box.y); + await page.mouse.down(); + await page.mouse.up(); + el = await page.$('#jp-main-content-panel .p-TabBar'); + if (el !== null) { + await el.click(); + } else { + console.log('Unable to find tab bar.'); + } + } else { + console.log('Unable to resolve bounding box.'); + } + } else { + console.log('Unable to find expected tab.'); + } }); it('should show JupyterLab logo', async () => { @@ -35,9 +55,9 @@ describe('JupyterLab', () => { await expect(page).toMatchElement('#jp-MainLogo', { visible: true } as any); }); - it("show be able to show 'Data Explorer' tab", async () => { - expect.assertions(2); - await expect(page).toClick('[title="Data Explorer"]'); + it.only("show be able to show 'Data Explorer' tab", async () => { + expect.assertions(1); + // await expect(page).toClick('[title="Data Explorer"]'); await expect(page).toMatchElement('.jl-explorer-heading', { text: 'Datasets', visible: true From dc5704e30ac91910d75068d9370f7a065effaeb1 Mon Sep 17 00:00:00 2001 From: kgryte Date: Thu, 24 Oct 2019 15:13:13 -0700 Subject: [PATCH 23/26] Increase sleep duration --- package.json | 30 +++++++++++++++--------------- test/ui/test.ts | 21 +++------------------ 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index 6a0dbd9..de198e6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "prettier": "prettier --write '**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}'", "prettier:check": "prettier --list-different '**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}'", "rebuild:packages": "jlpm run clean:packages && jlpm run build:packages", - "test": "jlpm jest --runInBand --verbose", + "test": "jest --runInBand", "test:debug": "env HEADLESS=false jlpm test", "uninstall:extensions": "jupyter labextension uninstall --all --no-build", "unlink": "jlpm run unlink:packages", @@ -74,25 +74,25 @@ }, "devDependencies": { "@jupyterlab/dataregistry-extension": "^3.0.0", - "@rws-air/jestscreenshot": "3.0.3", - "@types/expect-puppeteer": "3.3.2", - "@types/jest": "24.0.19", - "@types/jest-environment-puppeteer": "4.3.1", - "@types/jsonld": "1.5.0", - "@types/puppeteer": "1.20.2", + "@rws-air/jestscreenshot": "^3.0.3", + "@types/expect-puppeteer": "^3.3.2", + "@types/jest": "^24.0.19", + "@types/jest-environment-puppeteer": "^4.3.1", + "@types/jsonld": "^1.5.0", + "@types/puppeteer": "^1.20.2", "husky": "^3.0.9", - "jest": "24.9.0", - "jest-circus": "24.9.0", - "jest-puppeteer": "4.3.0", + "jest": "^24.9.0", + "jest-circus": "^24.9.0", + "jest-puppeteer": "^4.3.0", "husky": "^3.0.9", "lint-staged": "^9.4.2", "prettier": "^1.18.2", - "puppeteer": "1.20.0", + "puppeteer": "^2.0.0", "rimraf": "~2.6.2", - "stylelint": "11.0.0", - "stylelint-config-prettier": "6.0.0", - "stylelint-config-standard": "19.0.0", - "ts-jest": "24.1.0", + "stylelint": "^11.0.0", + "stylelint-config-prettier": "^6.0.0", + "stylelint-config-standard": "^19.0.0", + "ts-jest": "^24.1.0", "tslint": "^5.20.0", "tslint-config-prettier": "^1.18.0", "tslint-plugin-prettier": "^2.0.1", diff --git a/test/ui/test.ts b/test/ui/test.ts index 35f98c0..c27f010 100644 --- a/test/ui/test.ts +++ b/test/ui/test.ts @@ -27,24 +27,10 @@ function sleep(ms: number): Promise { describe('JupyterLab', () => { beforeAll(async () => { await page.goto('http://localhost:8080/lab?reset'); - await sleep(1000); + await sleep(3000); let el = await page.$('[title="Data Explorer"]'); if (el !== null) { - await el.click(); - const box = await el.boundingBox(); - if (box !== null) { - await page.mouse.move(box.x, box.y); - await page.mouse.down(); - await page.mouse.up(); - el = await page.$('#jp-main-content-panel .p-TabBar'); - if (el !== null) { - await el.click(); - } else { - console.log('Unable to find tab bar.'); - } - } else { - console.log('Unable to resolve bounding box.'); - } + el.click(); } else { console.log('Unable to find expected tab.'); } @@ -55,9 +41,8 @@ describe('JupyterLab', () => { await expect(page).toMatchElement('#jp-MainLogo', { visible: true } as any); }); - it.only("show be able to show 'Data Explorer' tab", async () => { + it("show be able to show 'Data Explorer' tab", async () => { expect.assertions(1); - // await expect(page).toClick('[title="Data Explorer"]'); await expect(page).toMatchElement('.jl-explorer-heading', { text: 'Datasets', visible: true From 7e7b09c3a76f4e5af1a9431dd9668166f82b842a Mon Sep 17 00:00:00 2001 From: kgryte Date: Thu, 24 Oct 2019 15:21:40 -0700 Subject: [PATCH 24/26] Add support for running puppeteer in "slowmo" mode when debugging --- jest-puppeteer.config.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jest-puppeteer.config.js b/jest-puppeteer.config.js index cc843ca..6978dde 100644 --- a/jest-puppeteer.config.js +++ b/jest-puppeteer.config.js @@ -8,7 +8,7 @@ const config = { launch: { headless: process.env.HEADLESS !== 'false', - slowMo: true + slowMo: process.env.SLOWMO === 'true' }, // https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-dev-server#options server: { diff --git a/package.json b/package.json index de198e6..0125160 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "prettier:check": "prettier --list-different '**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}'", "rebuild:packages": "jlpm run clean:packages && jlpm run build:packages", "test": "jest --runInBand", - "test:debug": "env HEADLESS=false jlpm test", + "test:debug": "env HEADLESS=false SLOWMO=true jlpm test", "uninstall:extensions": "jupyter labextension uninstall --all --no-build", "unlink": "jlpm run unlink:packages", "unlink:packages": "jupyter labextension unlink ./ --no-build || echo 'Unlink command failed, but continuing...'" From fdfadd96b414c706c8bf00bc16cba0875afe86a5 Mon Sep 17 00:00:00 2001 From: kgryte Date: Thu, 24 Oct 2019 15:39:10 -0700 Subject: [PATCH 25/26] Update variable declaration --- test/ui/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ui/test.ts b/test/ui/test.ts index c27f010..beaa832 100644 --- a/test/ui/test.ts +++ b/test/ui/test.ts @@ -28,7 +28,7 @@ describe('JupyterLab', () => { beforeAll(async () => { await page.goto('http://localhost:8080/lab?reset'); await sleep(3000); - let el = await page.$('[title="Data Explorer"]'); + const el = await page.$('[title="Data Explorer"]'); if (el !== null) { el.click(); } else { From 3bd50db88ee25645e4c29c71eaa56585d57d709e Mon Sep 17 00:00:00 2001 From: kgryte Date: Thu, 24 Oct 2019 15:43:15 -0700 Subject: [PATCH 26/26] Add comments --- test/ui/test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/ui/test.ts b/test/ui/test.ts index beaa832..21a02db 100644 --- a/test/ui/test.ts +++ b/test/ui/test.ts @@ -26,10 +26,16 @@ function sleep(ms: number): Promise { } describe('JupyterLab', () => { beforeAll(async () => { + // Load JupyterLab: await page.goto('http://localhost:8080/lab?reset'); + + // NOTE: depending on system resource constraints, this may NOT be enough time for JupyterLab to load and get "settled", so to speak. If CI tests begin inexplicably failing due to timeout failures, may want to consider increasing the sleep duration... await sleep(3000); + + // Attempt to find the data explorer tab on the page (all tests essentially presume that we can load the data explorer via the tab bar button): const el = await page.$('[title="Data Explorer"]'); if (el !== null) { + // Clicking on the data explorer tab should open the data explorer, thus allowing us to test data explorer UI interactions: el.click(); } else { console.log('Unable to find expected tab.');