mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
test: add all the e2e tests with nightwatch
This commit is contained in:
parent
c4733f72bc
commit
229330f2af
8 changed files with 994 additions and 68 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -34,6 +34,8 @@ npm-debug.log
|
|||
yarn-error.log
|
||||
testem.log
|
||||
/typings
|
||||
chromedriver.log
|
||||
e2e-test-results
|
||||
|
||||
# System Files
|
||||
.DS_Store
|
||||
|
|
@ -53,3 +55,4 @@ electron/**/*.js.map
|
|||
all-certs.p12
|
||||
mac-cert.tar
|
||||
build/electron-builder.appx.yaml
|
||||
|
||||
|
|
|
|||
28
n2e/daily-summary.e2e.ts
Normal file
28
n2e/daily-summary.e2e.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import {NightwatchBrowser} from 'nightwatch';
|
||||
import {Key} from 'protractor';
|
||||
|
||||
const URL = 'http://localhost:4200/#/tag/TODAY/daily-summary';
|
||||
const ADD_TASK_BTN_SEL = '.action-nav > button:first-child';
|
||||
const ADD_TASK_GLOBAL_SEL = 'add-task-bar.global input';
|
||||
|
||||
module.exports = {
|
||||
after: (browser: NightwatchBrowser) => {
|
||||
browser
|
||||
.end();
|
||||
},
|
||||
'Daily summary message': (browser: NightwatchBrowser) => browser
|
||||
.url(URL)
|
||||
.waitForElementVisible('.done-headline')
|
||||
.assert.containsText('.done-headline', 'Take a moment to celebrate')
|
||||
.end(),
|
||||
|
||||
'show any added task in table': (browser: NightwatchBrowser) => browser
|
||||
.url(URL)
|
||||
.waitForElementVisible(ADD_TASK_BTN_SEL)
|
||||
.click(ADD_TASK_BTN_SEL)
|
||||
.waitForElementVisible(ADD_TASK_GLOBAL_SEL)
|
||||
|
||||
.setValue(ADD_TASK_GLOBAL_SEL, 'test task hohoho')
|
||||
.setValue(ADD_TASK_GLOBAL_SEL, Key.ENTER)
|
||||
|
||||
};
|
||||
14
n2e/tsconfig.n2e.json
Normal file
14
n2e/tsconfig.n2e.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/n2e",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"target": "es5",
|
||||
"types": [
|
||||
"jasmine",
|
||||
"jasminewd2",
|
||||
"node"
|
||||
]
|
||||
}
|
||||
}
|
||||
57
n2e/work-view.e2e.ts
Normal file
57
n2e/work-view.e2e.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import {NightwatchBrowser} from 'nightwatch';
|
||||
import {Key} from 'protractor';
|
||||
|
||||
|
||||
const ADD_TASK_INITIAL_SEL = 'add-task-bar:not(.global) input';
|
||||
const ADD_TASK_GLOBAL_SEL = 'add-task-bar.global input';
|
||||
const TASK_SEL = 'task';
|
||||
const ADD_TASK_BTN_SEL = '.action-nav > button:first-child';
|
||||
const WORK_VIEW_URL = 'http://localhost:4200/';
|
||||
|
||||
module.exports = {
|
||||
'should add a task': (browser: NightwatchBrowser) => browser
|
||||
.url(WORK_VIEW_URL)
|
||||
.waitForElementVisible(ADD_TASK_INITIAL_SEL)
|
||||
|
||||
.setValue(ADD_TASK_INITIAL_SEL, '1 test task hihi')
|
||||
.setValue(ADD_TASK_INITIAL_SEL, Key.ENTER)
|
||||
|
||||
.waitForElementVisible(TASK_SEL)
|
||||
.assert.visible(TASK_SEL)
|
||||
.assert.containsText(TASK_SEL, '1 test task hihi')
|
||||
.end(),
|
||||
|
||||
'should add 2 tasks': (browser: NightwatchBrowser) => browser
|
||||
.url(WORK_VIEW_URL)
|
||||
.waitForElementVisible(ADD_TASK_INITIAL_SEL)
|
||||
|
||||
.setValue(ADD_TASK_INITIAL_SEL, '2 test task hihi')
|
||||
.setValue(ADD_TASK_INITIAL_SEL, Key.ENTER)
|
||||
.setValue(ADD_TASK_INITIAL_SEL, '3 some other task')
|
||||
.setValue(ADD_TASK_INITIAL_SEL, Key.ENTER)
|
||||
|
||||
.waitForElementVisible(TASK_SEL)
|
||||
.assert.visible(TASK_SEL)
|
||||
.assert.containsText(TASK_SEL + ':nth-child(1)', '2 test task hihi')
|
||||
.assert.containsText(TASK_SEL + ':nth-child(2)', '3 some other task')
|
||||
.end(),
|
||||
|
||||
|
||||
'should add multiple tasks from header button': (browser: NightwatchBrowser) => browser
|
||||
.url(WORK_VIEW_URL)
|
||||
.waitForElementVisible(ADD_TASK_BTN_SEL)
|
||||
.click(ADD_TASK_BTN_SEL)
|
||||
.waitForElementVisible(ADD_TASK_GLOBAL_SEL)
|
||||
|
||||
.setValue(ADD_TASK_GLOBAL_SEL, '4 test task hohoho')
|
||||
.setValue(ADD_TASK_GLOBAL_SEL, Key.ENTER)
|
||||
.setValue(ADD_TASK_GLOBAL_SEL, '5 some other task xoxo')
|
||||
.setValue(ADD_TASK_GLOBAL_SEL, Key.ENTER)
|
||||
|
||||
.waitForElementVisible(TASK_SEL)
|
||||
.assert.visible(TASK_SEL)
|
||||
// NOTE: global adds to top rather than bottom
|
||||
.assert.containsText(TASK_SEL + ':nth-child(1)', '5 some other task xoxo')
|
||||
.assert.containsText(TASK_SEL + ':nth-child(2)', '4 test task hohoho')
|
||||
.end(),
|
||||
};
|
||||
61
n2e/work-view.po.ts
Normal file
61
n2e/work-view.po.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
// import {EnhancedPageObject} from 'nightwatch';
|
||||
//
|
||||
// const workViewPage: EnhancedPageObject = {
|
||||
// // can be string or function
|
||||
// url() {
|
||||
// return 'http://localhost:4200/';
|
||||
// },
|
||||
// elements: {
|
||||
// // shorthand, specifies selector
|
||||
// mySubmitButton: 'input[type=submit]',
|
||||
//
|
||||
// // full
|
||||
// myTextInput: {
|
||||
// selector: 'input[type=text]',
|
||||
// locateStrategy: 'css selector'
|
||||
// }
|
||||
// },
|
||||
// commands: [
|
||||
// {
|
||||
// myCustomPause: function() {
|
||||
// this.api.pause(this.props.myPauseTime);
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
// // object version (best considered immutable)
|
||||
// props: {
|
||||
// myPauseTime: 1000
|
||||
// },
|
||||
//
|
||||
// sections: {
|
||||
// myFooterSection: {
|
||||
// selector: '#my-footer',
|
||||
// locateStrategy: 'css selector',
|
||||
// elements: {
|
||||
// myLogo: {
|
||||
// selector: '.my-logo',
|
||||
// locateStrategy: 'css selector'
|
||||
// }
|
||||
// },
|
||||
// commands: [
|
||||
// {
|
||||
// myMoveToLogo: function() {
|
||||
// this.moveToElement('@myLogo', this.props.myLogoX, this.props.myLogoY);
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
// // function version (recommended)
|
||||
// props: function() {
|
||||
// return {
|
||||
// myLogoX: 10,
|
||||
// myLogoY: 10
|
||||
// };
|
||||
// },
|
||||
// sections: {
|
||||
// // additional, nested sections
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// module.exports = workViewPage;
|
||||
43
nightwatch.conf.js
Normal file
43
nightwatch.conf.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
module.exports = {
|
||||
// An array of folders (excluding subfolders) where your tests are located;
|
||||
// if this is not specified, the test source must be passed as the second argument to the test runner.
|
||||
src_folders: [
|
||||
'out-tsc/n2e'
|
||||
],
|
||||
output_folder: "n2e/e2e-test-results",
|
||||
live_output: true,
|
||||
webdriver: {
|
||||
start_process: true,
|
||||
port: 9515,
|
||||
server_path: require('chromedriver').path,
|
||||
cli_args: []
|
||||
},
|
||||
|
||||
test_settings: {
|
||||
default: {
|
||||
launch_url: 'https://localhost:4200',
|
||||
desiredCapabilities: {
|
||||
browserName: 'chrome',
|
||||
chromeOptions: {
|
||||
args: [
|
||||
'--headless',
|
||||
'--disable-gpu',
|
||||
'--window-size=800,600',
|
||||
'--no-sandbox',
|
||||
'--disable-dev-shm-usage',
|
||||
'--disable-browser-side-navigation',
|
||||
// `--binary=${process.env.CHROME_BIN}`
|
||||
],
|
||||
w3c: false,
|
||||
prefs: {
|
||||
"profile.default_content_setting_values.geolocation": 1,
|
||||
"profile.default_content_setting_values.notifications": 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
globals: {
|
||||
waitForConditionTimeout: 30000
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -32,6 +32,7 @@
|
|||
"lint": "ng lint",
|
||||
"preCheck": "yarn lint && yarn test && yarn e2e",
|
||||
"e2e": "ng e2e --webdriver-update true",
|
||||
"e2e:nightwatch": "tsc --project ./n2e/tsconfig.n2e.json && nightwatch",
|
||||
"electron": "NODE_ENV=PROD electron .",
|
||||
"electron:build": "tsc -p tsconfig-electron.json",
|
||||
"electron:watch": "tsc -p tsconfig-electron.json --watch",
|
||||
|
|
@ -117,12 +118,14 @@
|
|||
"@types/jasmine": "^3.3.12",
|
||||
"@types/jasminewd2": "~2.0.3",
|
||||
"@types/moment-duration-format": "^2.2.2",
|
||||
"@types/nightwatch": "^1.1.4",
|
||||
"@types/node": "^12.11.1",
|
||||
"all-contributors-cli": "^6.8.0",
|
||||
"angular-material-css-vars": "^0.3.7",
|
||||
"angular2-promise-buttons": "latest",
|
||||
"axios": "^0.19.2",
|
||||
"chart.js": "^2.8.0",
|
||||
"chromedriver": "^83.0.0",
|
||||
"clipboard": "^2.0.1",
|
||||
"codelyzer": "^5.1.2",
|
||||
"conventional-changelog-cli": "^2.0.21",
|
||||
|
|
@ -155,6 +158,7 @@
|
|||
"ng2-charts-schematics": "^0.1.7",
|
||||
"ng2-dragula": "^2.1.1",
|
||||
"ngx-markdown": "^8.0.2",
|
||||
"nightwatch": "^1.3.6",
|
||||
"node-sass": "^4.12.0",
|
||||
"p-throttle": "^3.1.0",
|
||||
"protractor": "^5.4.2",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue