Skip to content

Commit

Permalink
[gui] Fix non-deterministic GUI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
csordasmarton committed Jan 20, 2022
1 parent 07939c4 commit 5f16f7b
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 71 deletions.
13 changes: 10 additions & 3 deletions web/server/codechecker_server/api/product_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,9 @@ def editProduct(self, product_id, new_config):
codechecker_api_shared.ttypes.ErrorCode.GENERAL, msg)

if self.__server.get_product(new_config.endpoint):
LOG.error("A product endpoint '/%s' is already"
"configured!", product.endpoint)
msg = f"A product endpoint '/{product.endpoint}' is " \
f"already configured!"
LOG.error(msg)
raise codechecker_api_shared.ttypes.RequestFailed(
codechecker_api_shared.ttypes.ErrorCode.GENERAL, msg)

Expand Down Expand Up @@ -597,7 +598,13 @@ def editProduct(self, product_id, new_config):
LOG.info("Product change requires database reconnection...")

LOG.debug("Disconnecting...")
self.__server.remove_product(old_endpoint)
try:
# Because of the process pool it is possible that in the
# local cache of the current process the product with the
# old endpoint is not found and it will raise an exception.
self.__server.remove_product(old_endpoint)
except ValueError:
pass

LOG.debug("Connecting new settings...")
self.__server.add_product(product)
Expand Down
33 changes: 19 additions & 14 deletions web/server/vue-cli/e2e/pages/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const commands = {
this
.click("@editAnnouncementBtn");

this.expect.element("@overlay").to.be.visible.before(5000);

this.expect.section("@editAnnouncementDialog")
.to.be.visible.before(5000);

Expand All @@ -13,13 +15,17 @@ const commands = {
this.expect.section("@editAnnouncementDialog")
.to.not.be.present.before(5000);

this.expect.element("@overlay").to.not.be.present.before(5000);

return this;
},

showGlobalPermissionsDialog() {
this
.click("@editGlobalPermissionBtn");

this.expect.element("@overlay").to.be.visible.before(5000);

this.expect.section("@editGlobalPermissionsDialog")
.to.be.visible.before(5000);

Expand All @@ -32,6 +38,8 @@ const commands = {
this.expect.section("@editGlobalPermissionsDialog")
.to.not.be.present.before(5000);

this.expect.element("@overlay").to.not.be.present.before(5000);

return this;
},

Expand Down Expand Up @@ -80,21 +88,12 @@ const commands = {
this
.click("@newProductBtn");

this.expect.element("@overlay").to.be.visible.before(5000);
this.expect.section("@productDialog").to.be.visible;

return this;
},

closeNewProductDialog() {
this.section.productDialog
.waitForElementVisible("@closeBtn")
.click("@closeBtn", () => {
this.expect.section("@productDialog").to.not.be.present.before(4000);
});

return this;
},

fillNewProductData(props={}) {
const section = this.section.productDialog;

Expand Down Expand Up @@ -165,8 +164,9 @@ const commands = {
},

saveProduct() {
this.section.productDialog
.click("@confirmBtn");
this.section.productDialog.click("@confirmBtn");

this.waitForElementNotPresent("@progressBar", 5000);

return this;
},
Expand All @@ -175,11 +175,15 @@ const commands = {
this.click("@removeBtn");

this.expect.section("@removeProductDialog").to.be.visible.before(5000);
this.expect.element("@overlay").to.be.visible.before(5000);

this.section.removeProductDialog
.waitForElementVisible("@confirmBtn")
.click("@confirmBtn");

this.waitForElementNotPresent("@progressBar", 5000);
this.expect.element("@overlay").to.not.be.present.before(5000);

return this;
},

Expand Down Expand Up @@ -229,7 +233,8 @@ module.exports = {
searchInput: ".v-toolbar__content input[type='text']",
progressBar: ".v-data-table__progress",
editBtn: "tr .edit-btn",
removeBtn: "tr .remove-btn"
removeBtn: "tr .remove-btn",
overlay: ".v-overlay.v-overlay--active"
},
sections: {
editAnnouncementDialog: {
Expand All @@ -252,7 +257,7 @@ module.exports = {
checkBox: ".v-input--checkbox",
cancelBtn: ".cancel-btn",
confirmBtn: ".confirm-btn",
closeBtn: ".title button"
closeBtn: ".close-btn"
}
},
productDialog: {
Expand Down
3 changes: 2 additions & 1 deletion web/server/vue-cli/e2e/pages/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ module.exports = {
setCleanupPlanBtn: ".set-cleanup-plan-btn",
expandBtn: "button.v-data-table__expand-icon",
selectReportCheckbox: "tbody .v-simple-checkbox",
selectAllReportCheckbox: "thead .v-simple-checkbox"
selectAllReportCheckbox: "thead .v-simple-checkbox",
overlay: ".v-overlay.v-overlay--active"
},
sections: {
baselineRunFilter: createRunFilterSection("#run"),
Expand Down
3 changes: 2 additions & 1 deletion web/server/vue-cli/e2e/pages/reportDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ module.exports = {
selectSameReport: ".select-same-report",
reportStepMsg: ".report-step-msg",
toggleBlameViewBtn: ".toggle-blame-view-btn",
blameCommitInfo: ".blame-commit-info"
blameCommitInfo: ".blame-commit-info",
overlay: ".v-overlay.v-overlay--active"
},
commands: [ commands ],
sections: {
Expand Down
1 change: 1 addition & 0 deletions web/server/vue-cli/e2e/pages/runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = {
deleteSelectedRunsBtn: ".delete-run-btn",
diffSelectedRunsBtn: ".diff-runs-btn",
expandBtn: "button.v-data-table__expand-icon",
overlay: ".v-overlay.v-overlay--active",
},
sections: {
table: {
Expand Down
8 changes: 6 additions & 2 deletions web/server/vue-cli/e2e/specs/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ module.exports = {
})
.saveProduct();

product.expect.element("@overlay").to.not.be.present.before(5000);

product
.filterProducts("Test")
.editProduct()
Expand All @@ -115,8 +117,10 @@ module.exports = {
})
.saveProduct();

product
.removeProduct();
product.expect.section("@productDialog").to.not.be.present.before(4000);
product.expect.element("@overlay").to.not.be.present.before(5000);

product.removeProduct();
},

"sort products" (browser) {
Expand Down
10 changes: 10 additions & 0 deletions web/server/vue-cli/e2e/specs/reportDetail.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = {
before(browser) {
browser.resizeWindow(1600, 1000);

const login = browser.page.login();

const reportDetailPage = browser.page.reportDetail();
Expand Down Expand Up @@ -68,6 +70,8 @@ module.exports = {
reportDetailPage.expect.section(changeReviewStatusMessageDialog)
.to.be.visible.before(5000);

reportDetailPage.expect.element("@overlay").to.be.visible.before(5000);

// Set the message and save.
const message = "Test";
changeReviewStatusMessageDialog
Expand All @@ -85,6 +89,7 @@ module.exports = {
reportDetailPage.click("@page");
reportDetailPage.expect.section(reviewStatusMessageMenu)
.to.be.not.present.before(5000);
reportDetailPage.expect.element("@overlay").to.not.be.present.before(5000);
},

"change review status without message" (browser) {
Expand All @@ -106,6 +111,8 @@ module.exports = {
reportDetailPage.expect.section(changeReviewStatusMessageDialog)
.to.be.visible.before(5000);

reportDetailPage.expect.element("@overlay").to.be.visible.before(5000);

// Clear the message.
changeReviewStatusMessageDialog
.clearAndSetValue("@message", "", changeReviewStatusMessageDialog)
Expand Down Expand Up @@ -146,6 +153,8 @@ module.exports = {
reportDetailPage.expect.section(editCommentDialog)
.to.be.visible.before(5000);

reportDetailPage.expect.element("@overlay").to.be.visible.before(5000);

editCommentDialog
.clearAndSetValue("@message", newMessage, editCommentDialog);

Expand All @@ -161,6 +170,7 @@ module.exports = {
userCommentSection.click("@removeBtn");
reportDetailPage.expect.section(removeCommentDialog)
.to.be.visible.before(5000);
reportDetailPage.expect.element("@overlay").to.be.visible.before(5000);

removeCommentDialog.click("@removeBtn");

Expand Down
34 changes: 34 additions & 0 deletions web/server/vue-cli/e2e/specs/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,14 @@ module.exports = {

section.click("@input");
reportPage.expect.section(dateDialog).to.be.visible.before(5000);
reportPage.expect.element("@overlay").to.be.visible.before(5000);

dateDialog
.click("@date")
.click("@ok");

reportPage.expect.element("@overlay").to.not.be.present.before(5000);

section.click("@clearBtn");

reportPage
Expand Down Expand Up @@ -272,11 +275,14 @@ module.exports = {

section.click("@input");
reportPage.expect.section(dateDialog).to.be.visible.before(5000);
reportPage.expect.element("@overlay").to.be.visible.before(5000);

dateDialog
.click("@date")
.click("@ok");

reportPage.expect.element("@overlay").to.not.be.present.before(5000);

section.click("@clearBtn");

await reportPage.pause(500);
Expand Down Expand Up @@ -440,27 +446,34 @@ module.exports = {
dialogSection.click("@newComponentBtn");
reportPage.expect.section(newComponentDialog).to.be.visible.before(5000);

reportPage.expect.element("@overlay").to.be.visible.before(5000);

let [ name, value, description ] = [ "e2e", "+*", "Test" ];
newComponentDialog
.clearAndSetValue("@name", name, newComponentDialog)
.clearAndSetValue("@value", value, newComponentDialog)
.clearAndSetValue("@description", description, newComponentDialog)
.click("@saveBtn");

reportPage.expect.element("@overlay").to.not.be.present.before(5000);

dialogSection.api.elements("@tableRows", (elements) => {
browser.assert.ok(elements.result.value.length === 1);
});

// Edit component.
dialogSection.click({ selector: "@editBtn", index: 0 });
reportPage.expect.section(newComponentDialog).to.be.visible.before(5000);
reportPage.expect.element("@overlay").to.be.visible.before(5000);

[ value, description ] = [ "+*\n-dummy", "Renamed" ];
newComponentDialog
.clearAndSetValue("@value", value, newComponentDialog)
.clearAndSetValue("@description", description, newComponentDialog)
.click("@saveBtn");

reportPage.expect.element("@overlay").to.not.be.present.before(5000);

dialogSection.api.elements("@tableRows", (elements) => {
browser.assert.ok(elements.result.value.length === 1);
});
Expand Down Expand Up @@ -498,6 +511,8 @@ module.exports = {
reportPage.expect.section(removeComponentDialog)
.to.be.visible.before(5000);

reportPage.expect.element("@overlay").to.be.visible.before(5000);

removeComponentDialog.click("@confirmBtn");

dialogSection
Expand Down Expand Up @@ -529,26 +544,32 @@ module.exports = {
dialogSection.waitForElementVisible("@newCleanupPlanBtn")
dialogSection.click("@newCleanupPlanBtn");
reportPage.expect.section(newCleanupPlanDialog).to.be.visible.before(5000);
reportPage.expect.element("@overlay").to.be.visible.before(5000);

let [ name, description ] = [ "e2e", "Test" ];
newCleanupPlanDialog
.clearAndSetValue("@name", name, newCleanupPlanDialog)
.clearAndSetValue("@description", description, newCleanupPlanDialog)
.click("@saveBtn");

reportPage.expect.element("@overlay").to.not.be.present.before(5000);

dialogSection.api.elements("@tableRows", (elements) => {
browser.assert.ok(elements.result.value.length === 1);
});

// Edit cleanup plan.
dialogSection.click({ selector: "@editCleanupPlanBtn", index: 0 });
reportPage.expect.section(newCleanupPlanDialog).to.be.visible.before(5000);
reportPage.expect.element("@overlay").to.be.visible.before(5000);

[ description ] = [ "Renamed" ];
newCleanupPlanDialog
.clearAndSetValue("@description", description, newCleanupPlanDialog)
.click("@saveBtn");

reportPage.expect.element("@overlay").to.not.be.present.before(5000);

dialogSection.api.elements("@tableRows", (elements) => {
browser.assert.ok(elements.result.value.length === 1);
});
Expand Down Expand Up @@ -641,6 +662,8 @@ module.exports = {
reportPage.expect.section(removeCleanupPlanDialog)
.to.be.visible.before(5000);

reportPage.expect.element("@overlay").to.be.visible.before(5000);

removeCleanupPlanDialog.click("@confirmBtn");

dialogSection
Expand Down Expand Up @@ -692,18 +715,23 @@ module.exports = {

section.click("@from");
reportPage.expect.section(fromDateDialog).to.be.visible.before(5000);
reportPage.expect.element("@overlay").to.be.visible.before(5000);

fromDateDialog
.click("@date")
.click("@ok");

reportPage.expect.element("@overlay").to.not.be.present.before(5000);

section.click("@to");
reportPage.expect.section(toDateDialog).to.be.visible.before(5000);
reportPage.expect.element("@overlay").to.be.visible.before(5000);

toDateDialog
.click("@date")
.click("@ok");

reportPage.expect.element("@overlay").to.not.be.present.before(5000);
section.click("@clearBtn");

reportPage
Expand All @@ -720,18 +748,24 @@ module.exports = {

section.click("@from");
reportPage.expect.section(fromDateDialog).to.be.visible.before(5000);
reportPage.expect.element("@overlay").to.be.visible.before(5000);

fromDateDialog
.click("@date")
.click("@ok");

reportPage.expect.element("@overlay").to.not.be.present.before(5000);

section.click("@to");
reportPage.expect.section(toDateDialog).to.be.visible.before(5000);
reportPage.expect.element("@overlay").to.be.visible.before(5000);

toDateDialog
.click("@date")
.click("@ok");

reportPage.expect.element("@overlay").to.not.be.present.before(5000);

section.click("@clearBtn");

reportPage
Expand Down
Loading

0 comments on commit 5f16f7b

Please sign in to comment.