Skip to content

Commit

Permalink
Update test to work with test string update and add test for new
Browse files Browse the repository at this point in the history
edit description implementation
  • Loading branch information
henrywang authored and martinpitt committed Aug 13, 2019
1 parent a3a12aa commit 968923b
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 32 deletions.
2 changes: 1 addition & 1 deletion test/end-to-end/components/Details.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class DetailsComponent {
}

get componentDescriptionLabel() {
const selector = '[id="blueprint-tabs-pane-customizations"] .cmpsr-title';
const selector = '[id="blueprint-tabs-pane-details"] .cmpsr-title';
browser.waitUntil(
() => $(selector).isExisting(),
timeout,
Expand Down
30 changes: 0 additions & 30 deletions test/end-to-end/pages/ViewBlueprint.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,36 +105,6 @@ class ViewBlueprintPage {
return $(selector);
}

get descriptionInputBox() {
const selector = '[data-form="description"] .form-control';
browser.waitUntil(
() => browser.isExisting(selector),
timeout,
`blueprint description input box under "Customizations" tab in View Blueprint page cannot be found by selector ${selector}`
);
return $(selector);
}

get okButton() {
const selector = '[data-form="description"] .form-control-pf-save';
browser.waitUntil(
() => browser.isExisting(selector),
timeout,
`ok button under "Customizations" tab in View Blueprint page cannot be found by selector ${selector}`
);
return $(selector);
}

get cancelButton() {
const selector = '[data-form="description"] .form-control-pf-cancel';
browser.waitUntil(
() => browser.isExisting(selector),
timeout,
`cancel button under "Customizations" tab in View Blueprint page cannot be found by selector ${selector}`
);
return $(selector);
}

customizationsTabHostnameLabel(hostname) {
const selector = `span=${hostname}`;
browser.waitUntil(
Expand Down
56 changes: 56 additions & 0 deletions test/end-to-end/pages/editDescription.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Edit Description page

class EditDescriptionPage {
constructor() {
this.containerSelector = '[id="cmpsr-modal-edit-description"]';
}

loading() {
browser.waitUntil(
() => browser.isExisting(this.containerSelector),
timeout,
`Loading Edit Description page failed because selector ${this.containerSelector} cannot be found`
);
}

get xButton() {
const selector = `${this.containerSelector} .pficon-close`;
browser.waitUntil(
() => browser.isExisting(selector),
timeout,
`X button under Edit Description page cannot be found by selector ${selector}`
);
return $(selector);
}

get descriptionInputBox() {
const selector = `${this.containerSelector} [id="textInput-modal-markup"]`;
browser.waitUntil(
() => browser.isExisting(selector),
timeout,
`blueprint description input box under Edit Description page cannot be found by selector ${selector}`
);
return $(selector);
}

get saveButton() {
const selector = `${this.containerSelector} [id="edit-description-modal-submit-button"]`;
browser.waitUntil(
() => browser.isExisting(selector),
timeout,
`Save button under Edit Description page cannot be found by selector ${selector}`
);
return $(selector);
}

get cancelButton() {
const selector = `${this.containerSelector} .btn-default`;
browser.waitUntil(
() => browser.isExisting(selector),
timeout,
`Cancel button under Edit Description page cannot be found by selector ${selector}`
);
return $(selector);
}
}
module.exports = new EditDescriptionPage();
51 changes: 50 additions & 1 deletion test/end-to-end/specs/viewBlueprint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,54 @@ describe("View Blueprint Page", function() {
});
});

describe("Edit description", function() {
const editDescriptionPage = require("../pages/editDescription.page");
it("should show correct description", function() {
viewBlueprintPage.moreButton.click();
browser.keys("ArrowDown");
browser.keys("Enter");
editDescriptionPage.loading();
expect(editDescriptionPage.descriptionInputBox.getValue()).to.equal(description);
editDescriptionPage.cancelButton.click();
browser.waitUntil(
() => !browser.isExisting(editDescriptionPage.containerSelector),
timeout,
"Cannot close Edit Description dialog"
);
});

it("should not update blueprint description after clicking X button", function() {
viewBlueprintPage.moreButton.click();
browser.keys("ArrowDown");
browser.keys("Enter");
editDescriptionPage.loading();
editDescriptionPage.xButton.click();
browser.waitUntil(
() => !browser.isExisting(editDescriptionPage.containerSelector),
timeout,
"Cannot close Edit Description dialog"
);
expect(viewBlueprintPage.headerBlueprintDescriptionLabel.getText()).to.equal(description);
});

it("should update blueprint description after apply", function() {
viewBlueprintPage.moreButton.click();
browser.keys("ArrowDown");
browser.keys("Enter");
editDescriptionPage.loading();

const newDescription = faker.lorem.sentence();
editDescriptionPage.descriptionInputBox.setValue(newDescription);
editDescriptionPage.saveButton.click();
browser.waitUntil(
() => !browser.isExisting(editDescriptionPage.containerSelector),
timeout,
"Cannot close Edit Description dialog"
);
expect(viewBlueprintPage.headerBlueprintDescriptionLabel.getText()).to.equal(newDescription);
});
});

describe("Edit Blueprint", function() {
const EditPackagesPage = require("../pages/EditPackages.page");
const editPackagesPage = new EditPackagesPage(name);
Expand All @@ -148,6 +196,7 @@ describe("View Blueprint Page", function() {
it("should copy correct blueprint manifest", function() {
viewBlueprintPage.moreButton.click();
browser.keys("ArrowDown");
browser.keys("ArrowDown");
browser.keys("Enter");
exportPage.loading();
// getText() does not work here on Edge, but works on Firefox and Chrome
Expand All @@ -159,7 +208,7 @@ describe("View Blueprint Page", function() {
browser.waitForExist(exportPage.containerSelector, timeout, true);
if (wdioConfig.config.capabilities[0].browserName !== "MicrosoftEdge") {
// back to view blueprint page for pasting
viewBlueprintPage.selectedComponentsTab.click();
viewBlueprintPage.packagesTab.click();
// paste blueprint manifest here to test copy function
viewBlueprintPage.selectedComponentFilter.click();
viewBlueprintPage.selectedComponentFilter.setValue(["Control", "v"]);
Expand Down

0 comments on commit 968923b

Please sign in to comment.