Skip to content

Commit 4087dbe

Browse files
committed
Fix test of fileupload
* Add FileDetector and use npm3 * Avoid error: Element is not currently visible and so may not be interacted with in Firefox
1 parent 5128fbb commit 4087dbe

File tree

7 files changed

+38
-19
lines changed

7 files changed

+38
-19
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cache:
2828
# Use Node.js as primary language because Gulp is the build system used in the project.
2929
language: node_js
3030
node_js:
31-
- 4.2.2
31+
- 5.1.1
3232

3333
addons:
3434
# Run tests that require a browser on SauceLabs CI provider. Learn more at: https://saucelabs.com

docs/devel/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ logic and fetches raw data from the various Kubernetes APIs.
1414
Make sure the following software is installed and added to the `$PATH` variable:
1515
* Docker (1.3+)
1616
* go (1.5+)
17-
* nodejs (4.2.2+)
18-
* npm (1.3+)
17+
* nodejs (5.1.1+)
18+
* npm (3+)
1919
* java (7+)
2020
* gulp (3.9+)
2121

src/app/frontend/replicationcontrollerdetail/deletereplicationcontroller.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ <h4 class="md-title">Delete Replication Controller</h4>
3030
</md-icon>
3131
</md-checkbox>
3232
<md-dialog-actions>
33-
<md-button class="md-primary" ng-click="ctrl.cancel()">Cancel</md-button>
34-
<md-button class="md-primary" ng-click="ctrl.remove()">Delete</md-button>
33+
<md-button class="md-primary kd-cancel-btn" ng-click="ctrl.cancel()">Cancel</md-button>
34+
<md-button class="md-primary kd-delete-btn" ng-click="ctrl.remove()">Delete</md-button>
3535
</md-dialog-actions>
3636
</md-dialog-content>
3737
</md-dialog>

src/test/integration/deploy/deployfromfile_po.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,29 @@ export default class DeployFromFilePageObject {
2727
this.inputContainer = element(this.inputContainerQuery);
2828

2929
this.filePickerQuery = by.css('.kd-upload-file-picker');
30-
this.filePicker = element(this.filePickerQuery);
30+
this.filePicker_ = element(this.filePickerQuery);
3131

3232
this.mdDialogQuery = by.tagName('md-dialog');
3333
this.mdDialog = element(this.mdDialogQuery);
3434
}
35+
36+
/**
37+
* Make filePicker input field visible
38+
* Firefox does not allow sendKeys to invisible input[type=file] element
39+
*/
40+
makeInputVisible() {
41+
browser.driver.executeScript(function() {
42+
/* global document */
43+
let filePickerDomElement = document.getElementsByClassName('kd-upload-file-picker')[0];
44+
filePickerDomElement.style.visibility = 'visible';
45+
filePickerDomElement.style.height = '1px';
46+
filePickerDomElement.style.width = '1px';
47+
});
48+
}
49+
50+
/**
51+
* Sets filepath on the filePicker input field
52+
* @param {string} filePath
53+
*/
54+
setFile(filePath) { this.filePicker_.sendKeys(filePath); }
3555
}

src/test/integration/replicationcontrollerdetail/deletereplicationcontroller_po.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@
1414

1515
export default class DeleteReplicationControllerDialogObject {
1616
constructor() {
17-
let deleteDialogXPath = '//md-dialog[@aria-label=\'Delete Replication Controller\']';
18-
this.deleteDialogQuery = by.xpath(deleteDialogXPath);
19-
this.deleteDialog = element(this.deleteDialogQuery);
20-
21-
this.deleteAppButtonQuery =
22-
by.xpath(`${deleteDialogXPath}//md-dialog-actions//span[text() = 'Delete']/..`);
17+
this.deleteAppButtonQuery = by.css('.kd-delete-btn');
2318
this.deleteAppButton = element(this.deleteAppButtonQuery);
2419

25-
this.deleteServicesCheckboxQuery = by.xpath(`${deleteDialogXPath}//md-checkbox`);
20+
this.deleteServicesCheckboxQuery = by.css('.kd-deletedialog-services-checkbox');
2621
this.deleteServicesCheckbox = element(this.deleteServicesCheckboxQuery);
2722
}
2823
}

src/test/integration/stories/deploy_from_invalid_file_test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@
1313
// limitations under the License.
1414

1515
import path from 'path';
16+
import remote from 'selenium-webdriver/remote';
1617

1718
import DeployFromFilePageObject from '../deploy/deployfromfile_po';
1819

1920
// Test assumes, that there are no replication controllers in the cluster at the beginning.
20-
// TODO(#494): Reenable this test when fixed.
21-
xdescribe('Deploy from invalid file user story test', () => {
21+
describe('Deploy from invalid file user story test', () => {
2222

2323
/** @type {!DeployFromFilePageObject} */
2424
let deployFromFilePage;
2525

2626
beforeAll(() => {
27+
browser.driver.setFileDetector(new remote.FileDetector());
2728
deployFromFilePage = new DeployFromFilePageObject();
2829
browser.get('#/deploy');
2930
// switches to deploy from file
@@ -36,7 +37,8 @@ xdescribe('Deploy from invalid file user story test', () => {
3637
let absolutePath = path.resolve(__dirname, fileToUpload);
3738

3839
// when
39-
deployFromFilePage.filePicker.sendKeys(absolutePath);
40+
deployFromFilePage.makeInputVisible();
41+
deployFromFilePage.setFile(absolutePath);
4042
deployFromFilePage.deployButton.click();
4143

4244
// then

src/test/integration/stories/deploy_from_valid_file_test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
// limitations under the License.
1414

1515
import path from 'path';
16+
import remote from 'selenium-webdriver/remote';
1617

1718
import DeployFromFilePageObject from '../deploy/deployfromfile_po';
1819
import ReplicationControllersPageObject from '../replicationcontrollerslist/replicationcontrollers_po';
1920
import DeleteReplicationControllerDialogObject from '../replicationcontrollerdetail/deletereplicationcontroller_po';
2021
import ZeroStatePageObject from '../zerostate/zerostate_po';
2122

2223
// Test assumes, that there are no replication controllers in the cluster at the beginning.
23-
// TODO(#494): Reenable this test when fixed.
24-
xdescribe('Deploy from valid file user story test', () => {
24+
describe('Deploy from valid file user story test', () => {
2525

2626
/** @type {!DeployFromFilePageObject} */
2727
let deployFromFilePage;
@@ -39,6 +39,7 @@ xdescribe('Deploy from valid file user story test', () => {
3939
let appName = 'integration-test-valid-rc';
4040

4141
beforeAll(() => {
42+
browser.driver.setFileDetector(new remote.FileDetector());
4243
deployFromFilePage = new DeployFromFilePageObject();
4344
replicationControllersPage = new ReplicationControllersPageObject();
4445
deleteDialog = new DeleteReplicationControllerDialogObject();
@@ -54,7 +55,8 @@ xdescribe('Deploy from valid file user story test', () => {
5455
let absolutePath = path.resolve(__dirname, fileToUpload);
5556

5657
// when
57-
deployFromFilePage.filePicker.sendKeys(absolutePath);
58+
deployFromFilePage.makeInputVisible();
59+
deployFromFilePage.setFile(absolutePath);
5860
deployFromFilePage.deployButton.click();
5961

6062
// then

0 commit comments

Comments
 (0)