@sap_oss/wdio-qmate-service
Version:
[](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[](http
90 lines (76 loc) • 2.79 kB
JavaScript
;
const { BASE_URL } = require("../../../../src/reuse/constants.ts");
const {
handleCookiesConsent
} = require("../../../helper/utils");
const selectorForPopupOkButton = {
"elementProperties": {
"metadata": "sap.m.Button",
"text": "OK"
}
};
describe("confirmationDialog - clickButton - text 'OK'", function () {
it("Preparation", async function () {
await browser.navigateTo(`${BASE_URL}/#/entity/sap.m.Input/sample/sap.m.sample.InputChecked`);
await handleCookiesConsent();
await util.browser.switchToIframe("[id='sampleFrame']");
const submitButtonSelector = {
"elementProperties": {
"viewName": "sap.m.sample.InputChecked.V",
"metadata": "sap.m.Button"
}
};
await ui5.userInteraction.click(submitButtonSelector);
});
it("Execution", async function () {
await ui5.confirmationDialog.clickButton("OK");
});
it("Verification", async function () {
// After we close Dialog window, we have a validation error
const inputFieldWithCheckSelector = {
"elementProperties": {
"viewName": "sap.m.sample.InputChecked.V",
"metadata": "sap.m.Input",
"value": [{
"path": "/email"
}]
}
};
await ui5.assertion.expectValidationError(inputFieldWithCheckSelector);
await expect(ui5.element.getDisplayed(selectorForPopupOkButton))
.rejects.toThrow(/No visible elements found/);
});
});
describe("confirmationDialog - clickButton - text 'OK' without confirmation dialog (unhappy case)", function () {
it("Preparation", async function () {
await browser.url("#/categories");
});
it("Execution and Verification", async function () {
await expect(ui5.element.getDisplayed(selectorForPopupOkButton))
.rejects.toThrow(/No visible elements found/);
await expect(ui5.confirmationDialog.clickButton("OK"))
.rejects.toThrow(/waitUntil condition failed/);
});
});
describe("confirmationDialog - clickButton - text 'Cancel'", function () {
it("Preparation", async function () {
await browser.navigateTo(`${BASE_URL}/#/entity/sap.m.MessageBox/sample/sap.m.sample.MessageBox`);
await handleCookiesConsent();
await util.browser.switchToIframe("[id='sampleFrame']");
const confirmButtonSelector = {
"elementProperties": {
"viewName": "sap.m.sample.MessageBox.V",
"metadata": "sap.m.Button",
"text": "Confirm"
}
};
await ui5.userInteraction.click(confirmButtonSelector);
});
it("Execution", async function () {
await ui5.confirmationDialog.clickButton("Cancel");
});
it("Verification", async function () {
await expect(ui5.element.getDisplayed(selectorForPopupOkButton))
.rejects.toThrow(/No visible elements found/);
});
});