Skip to content

Commit

Permalink
mgr/dashboard: Add protractor-screenshoter-plugin
Browse files Browse the repository at this point in the history
A plugin to save screenshots on E2E tests failures as well as
console logs, raw HTML, ...
All info visualized in an HTML report (screenshots are clickable to see full image).
Useful for debugging/fixing E2E tests.

Signed-off-by: Alfonso Martínez <almartin@redhat.com>
  • Loading branch information
alfonsomthd committed Mar 27, 2019
1 parent 1fdd8ed commit e456508
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ GTAGS
.idea

# dashboard
/src/pybind/mgr/dashboard/frontend/.protractor-report
/src/pybind/mgr/dashboard/frontend/src/environments/environment.ts
/src/pybind/mgr/dashboard/frontend/src/environments/environment.prod.ts
6 changes: 6 additions & 0 deletions src/pybind/mgr/dashboard/HACKING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ Start all frontend e2e tests by running::

$ ./run-frontend-e2e-tests.sh

Report:
After running the tests you can find the corresponding report as well as screenshots
of failed test cases by opening the following file in your browser:

src/pybind/mgr/dashboard/frontend/.protractor-report/index.html

Device:
You can force the script to use a specific device with the ``-d`` flag::

Expand Down
93 changes: 65 additions & 28 deletions src/pybind/mgr/dashboard/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/pybind/mgr/dashboard/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"jest-silent-reporter": "0.1.2",
"prettier": "1.16.4",
"protractor": "5.4.2",
"protractor-screenshoter-plugin": "0.10.3",
"replace-in-file": "3.4.3",
"ts-node": "8.0.2",
"tslint": "5.12.1",
Expand Down
26 changes: 20 additions & 6 deletions src/pybind/mgr/dashboard/frontend/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ exports.config = {
password: 'admin'
}
},

plugins: [{
package: 'protractor-screenshoter-plugin',
screenshotPath: '.protractor-report',
screenshotOnExpect: 'failure',
screenshotOnSpec: 'none',
withLogs: true,
writeReportFreq: 'asap',
imageToAscii: 'none',
clearFoldersBeforeTest: true
}],

onPrepare() {
browser.manage().timeouts().implicitlyWait(360000);

Expand All @@ -45,12 +57,14 @@ exports.config = {

browser.driver.findElement(by.css('input[type="submit"]')).click();

// Login takes some time, so wait until it's done.
// For the test app's login, we know it's done when it redirects to
// dashboard.
return browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return /dashboard/.test(url);
return global.browser.getProcessedConfig().then(function(config) {
// Login takes some time, so wait until it's done.
// For the test app's login, we know it's done when it redirects to
// dashboard.
return browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return /dashboard/.test(url);
});
});
});
}
Expand Down

0 comments on commit e456508

Please sign in to comment.