-
-
Notifications
You must be signed in to change notification settings - Fork 16
Update tests #53
Update tests #53
Changes from all commits
6e1000d
581d998
33990ab
99c4b2b
a16bb33
6a6203f
dc5704e
7e7b09c
fdfadd9
3bd50db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
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', | ||
slowMo: process.env.SLOWMO === 'true' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was definitely useful in seeing what button was being pressed in real-time. |
||
}, | ||
// 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=''", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah good call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One less configuration file. |
||
port: 8080 | ||
} | ||
}; | ||
|
||
/** | ||
* Exports. | ||
*/ | ||
module.exports = config; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,36 @@ | ||
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", | ||
const { defaults: tsjPreset } = require('ts-jest/presets'); | ||
|
||
const config = { | ||
rootDir: '.', | ||
|
||
// Needed for jest-screenshots | ||
// https://yarnpkg.com/en/package/@rws-air/jestscreenshot | ||
testRunner: "jest-circus/runner", | ||
testRunner: 'jest-circus/runner', | ||
|
||
globalSetup: "jest-environment-puppeteer/setup", | ||
globalTeardown: "jest-environment-puppeteer/teardown", | ||
testEnvironment: "../jest-environment.js", | ||
setupFilesAfterEnv: ["expect-puppeteer"], | ||
testEnvironment: './jest-environment.js', | ||
globalSetup: 'jest-environment-puppeteer/setup', | ||
globalTeardown: 'jest-environment-puppeteer/teardown', | ||
setupFilesAfterEnv: ['expect-puppeteer'], | ||
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; |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* @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'); | ||
|
||
const timeout = 15 * 1000; | ||
|
||
jest.setTimeout(timeout); | ||
setDefaultOptions({ timeout }); | ||
|
||
async function getXPath(xpath: string): Promise<ElementHandle<Element>> { | ||
await page.waitForXPath(xpath); | ||
const elements = await page.$x(xpath); | ||
expect(elements.length).toBe(1); | ||
return elements[0]; | ||
} | ||
|
||
function sleep(ms: number): Promise<void> { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} | ||
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... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :D |
||
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.'); | ||
} | ||
}); | ||
|
||
it('should show JupyterLab logo', async () => { | ||
expect.assertions(1); | ||
await expect(page).toMatchElement('#jp-MainLogo', { visible: true } as any); | ||
}); | ||
|
||
it("show be able to show 'Data Explorer' tab", async () => { | ||
expect.assertions(1); | ||
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:///', | ||
visible: true | ||
} as any); | ||
}); | ||
|
||
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 () => { | ||
expect.assertions(1); | ||
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"]' | ||
); | ||
await datasetsButton.click(); | ||
}); | ||
|
||
it('should show datasets label', async () => { | ||
expect.assertions(1); | ||
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).toMatchElement('.jl-dr-browser', { | ||
text: 'Follow active?', | ||
visible: true | ||
} as any); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "build/test", | ||
"rootDir": "test" | ||
}, | ||
"include": ["test/*", "test/**/*"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah probably good call to separate these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recognize that, in other worlds (e.g., Go, Ruby), placing tests next to source files is common; in Node.js land, it isn't for reasons of separation of concerns. Plus, UI tests cross file divides and don't fit nicely into the |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's interesting you didn't need this! Not sure why we did, they just had it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was present in one of the dep documentation examples. I am not sure why it was there. If it was needed, I would disappointed, as it means importing the package has (gasp) side-effects :|.