Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KOGITO-5428: Introduce DMN Runner cypress test #621

Merged
merged 5 commits into from Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/build-env/graph.dot
Expand Up @@ -113,6 +113,7 @@ digraph G {
"@kogito-tooling/online-editor" -> "@kogito-tooling/form" [ style = "solid", color = "black" ];
"@kogito-tooling/online-editor" -> "@kogito-tooling/kie-bc-editors" [ style = "solid", color = "black" ];
"@kogito-tooling/online-editor" -> "@kogito-tooling/pmml-editor" [ style = "solid", color = "black" ];
"@kogito-tooling/online-editor" -> "@kogito-tooling/extended-services" [ style = "dashed", color = "black" ];
"@kogito-tooling/online-editor" -> "@kogito-tooling/external-assets-base" [ style = "dashed", color = "black" ];
"@kie-tooling-core/operating-system" -> "@kogito-tooling/build-env" [ style = "dashed", color = "purple" ];
"@kie-tooling-core/patternfly-base" -> "@kogito-tooling/build-env" [ style = "dashed", color = "purple" ];
Expand Down
72 changes: 72 additions & 0 deletions packages/online-editor/it-tests/integration/DMNRunnerTest.ts
@@ -0,0 +1,72 @@
/*
* Copyright 2021 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as buildEnv from "@kogito-tooling/build-env";

describe("DMN Runner Test", () => {
beforeEach(() => {
cy.visit(`http://localhost:${buildEnv.onlineEditor.dev.port}/`);
});

it("Test DMN Runner on DMN sample", () => {
// click Create new decision model button (new DMN)
cy.get("[data-ouia-component-id='try-dmn-sample-button']").click();

// wait until loading dialog disappears
cy.loadEditor();

// check editor logo
cy.get("[class='pf-c-brand']").within(($logo) => {
expect($logo.attr("src")).contain("dmn");
expect($logo.attr("alt")).contain("dmn");
});

// start the DMN Runner
cy.get("[data-ouia-component-id='dmn-guided-tour-skip-runner-start-button']").click();

// fill in DMN Runner inputs panel
cy.get("[data-testid='dmn-form']").within(($form) => {
cy.get("input[name='Credit Score.FICO']").type("650");
cy.get("input[name='Applicant Data.Age']").type("30");

cy.get("[x-dmn-type*='Marital_Status'] button").click();
cy.get("ul[name='Applicant Data.Marital Status'] button").contains("M").click();

cy.get("input[name='Applicant Data.Existing Customer']").check();

cy.get("input[name='Applicant Data.Monthly.Income']").type("3000");
cy.get("input[name='Applicant Data.Monthly.Repayments']").type("120");
cy.get("input[name='Applicant Data.Monthly.Expenses']").type("0");
cy.get("input[name='Applicant Data.Monthly.Tax']").type("0");
cy.get("input[name='Applicant Data.Monthly.Insurance']").type("0");

cy.get("[x-dmn-type*='Product_Type'] button").click();
cy.get("ul[name='Requested Product.Type'] button").contains("Standard Loan").click();

cy.get("input[name='Requested Product.Rate']").type("1.5");
cy.get("input[name='Requested Product.Term']").type("4");
cy.get("input[name='Requested Product.Amount']").type("10000");
});

// check DMN Runner outputs panel
cy.get("[data-testid='dmn-form-result']").within(($form) => {
cy.get("article div:contains('Front End Ratio')").next().contains("Sufficient").should("be.visible");
cy.get("article div:contains('Back End Ratio')").next().contains("Sufficient").should("be.visible");
cy.get("article div:contains('Credit Score Rating')").next().contains("Fair").should("be.visible");
cy.get("article div:contains('Loan Pre-Qualification')").next().should("contain.text", "Qualified");
});
});
});
4 changes: 3 additions & 1 deletion packages/online-editor/package.json
Expand Up @@ -26,6 +26,7 @@
},
"devDependencies": {
"@kogito-tooling/build-env": "0.0.0",
"@kogito-tooling/extended-services": "0.0.0",
"@kogito-tooling/external-assets-base": "0.0.0"
},
"scripts": {
Expand All @@ -37,7 +38,8 @@
"start": "webpack serve --host 0.0.0.0 --env dev",
"cy:open": "yarn run cypress open --project it-tests",
"cy:run": "yarn run cypress run -b chrome --project it-tests",
"test:it": "yarn run run-script-if --bool \"$(build-env global.build.testIT)\" --then \"yarn rimraf ./dist-it-tests\" \"yarn run start-server-and-test start http-get://0.0.0.0:$(build-env onlineEditor.dev.port) cy:run\""
"test:it:start:extended-services": "npm --prefix ../extended-services run start",
"test:it": "yarn run run-script-if --bool \"$(build-env global.build.testIT)\" --then \"yarn rimraf ./dist-it-tests\" \"yarn run start-server-and-test test:it:start:extended-services http-get://0.0.0.0:21345/ping start http-get://0.0.0.0:$(build-env onlineEditor.dev.port) cy:run\""
},
"babel": {
"presets": [
Expand Down
Expand Up @@ -651,6 +651,7 @@ export function KieToolingExtendedServicesModal() {

return (
<Modal
ouiaId="kie-tooling-extended-services-modal"
isOpen={kieToolingExtendedServices.isModalOpen}
onClose={onClose}
variant={modalVariant}
Expand Down
6 changes: 5 additions & 1 deletion packages/online-editor/src/tour/GuidedTourInitializer.tsx
Expand Up @@ -74,7 +74,11 @@ function getOnlineEditorTutorial(i18n: OnlineI18n) {
<Text>{i18n.guidedTour.init.dmnRunnerIntro}</Text>

<Text>{" "}</Text>
<Button onClick={() => dismissAndStartDmnRunner(props)} variant="link">
<Button
ouiaId="dmn-guided-tour-skip-runner-start-button"
onClick={() => dismissAndStartDmnRunner(props)}
variant="link"
>
{i18n.guidedTour.init.skipTourAndUseDmnRunner}
</Button>
<br />
Expand Down