-
Notifications
You must be signed in to change notification settings - Fork 46
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
#2296 Use React Testing Library for common-properties tests - Part 2-… #2331
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,101 +15,105 @@ | |
*/ | ||
|
||
|
||
import propertyUtils from "../../_utils_/property-utils"; | ||
import propertyUtilsRTL from "../../_utils_/property-utilsRTL"; | ||
import { expect } from "chai"; | ||
import conditionOpParamDef from "../../test_resources/paramDefs/dmConditionOp_paramDef.json"; | ||
import { cleanup, fireEvent } from "@testing-library/react"; | ||
|
||
describe("dm condition operators work correctly", () => { | ||
var wrapper; | ||
var controller; | ||
describe.only("dm condition operators work correctly", () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
let wrapper; | ||
let controller; | ||
beforeEach(() => { | ||
const renderedObject = propertyUtils.flyoutEditorForm(conditionOpParamDef); | ||
const renderedObject = propertyUtilsRTL.flyoutEditorForm(conditionOpParamDef); | ||
wrapper = renderedObject.wrapper; | ||
controller = renderedObject.controller; | ||
}); | ||
|
||
afterEach(() => { | ||
wrapper.unmount(); | ||
cleanup(); | ||
}); | ||
|
||
it("checkbox control become enabled if selected item has a dmType equal to string", () => { | ||
const { container } = wrapper; | ||
expect(controller.getControlState({ name: "checkbox" })).to.equal("disabled"); | ||
const dropDown = wrapper.find("div[data-id='properties-ctrl-dmTypeEqualList']"); | ||
const dropdownButton = dropDown.find("button").at(0); | ||
dropdownButton.simulate("click"); | ||
const dropdownList = wrapper.find("li.cds--list-box__menu-item"); | ||
dropdownList.at(3).simulate("click"); | ||
wrapper.update(); | ||
const dropDown = container.querySelector("div[data-id='properties-ctrl-dmTypeEqualList']"); | ||
const dropdownButton = dropDown.querySelectorAll("button")[0]; | ||
fireEvent.click(dropdownButton); | ||
const dropdownList = container.querySelectorAll("li.cds--list-box__menu-item"); | ||
fireEvent.click(dropdownList[3]); | ||
expect(dropdownList).to.be.length(14); | ||
expect(controller.getControlState({ name: "checkbox" })).to.equal("enabled"); | ||
|
||
}); | ||
|
||
it("checkbox control become visible if selected item does not have a dmType equal to string", () => { | ||
const { container } = wrapper; | ||
expect(controller.getControlState({ name: "checkbox1" })).to.equal("hidden"); | ||
const dropDown = wrapper.find("div[data-id='properties-ctrl-dmTypeNotEqualList']"); | ||
const dropdownButton = dropDown.find("button").at(0); | ||
dropdownButton.simulate("click"); | ||
const dropdownList = wrapper.find("li.cds--list-box__menu-item"); | ||
const dropDown = container.querySelector("div[data-id='properties-ctrl-dmTypeNotEqualList']"); | ||
const dropdownButton = dropDown.querySelectorAll("button")[0]; | ||
fireEvent.click(dropdownButton); | ||
const dropdownList = container.querySelectorAll("li.cds--list-box__menu-item"); | ||
expect(dropdownList).to.be.length(14); | ||
dropdownList.at(1).simulate("click"); | ||
wrapper.update(); | ||
fireEvent.click(dropdownList[1]); | ||
expect(controller.getControlState({ name: "checkbox1" })).to.equal("visible"); | ||
}); | ||
|
||
it("checkbox control becomes enabled if selected item has a dmRole equal to input", () => { | ||
const { container } = wrapper; | ||
expect(controller.getControlState({ name: "checkbox2" })).to.equal("disabled"); | ||
const dropDown = wrapper.find("div[data-id='properties-ctrl-dmRoleEqualList']"); | ||
const dropdownButton = dropDown.find("button").at(0); | ||
dropdownButton.simulate("click"); | ||
const dropdownList = wrapper.find("li.cds--list-box__menu-item"); | ||
const dropDown = container.querySelector("div[data-id='properties-ctrl-dmRoleEqualList']"); | ||
const dropdownButton = dropDown.querySelectorAll("button")[0]; | ||
fireEvent.click(dropdownButton); | ||
const dropdownList = container.querySelectorAll("li.cds--list-box__menu-item"); | ||
expect(dropdownList).to.be.length(14); | ||
dropdownList.at(1).simulate("click"); | ||
wrapper.update(); | ||
fireEvent.click(dropdownList[1]); | ||
expect(controller.getControlState({ name: "checkbox2" })).to.equal("enabled"); | ||
}); | ||
|
||
it("checkbox control become visible if selected item does not have a dmRole equal to input", () => { | ||
const { container } = wrapper; | ||
expect(controller.getControlState({ name: "checkbox3" })).to.equal("hidden"); | ||
const dropDown = wrapper.find("div[data-id='properties-ctrl-dmRoleNotEqualList']"); | ||
const dropdownButton = dropDown.find("button").at(0); | ||
dropdownButton.simulate("click"); | ||
const dropdownList = wrapper.find("li.cds--list-box__menu-item"); | ||
const dropDown = container.querySelector("div[data-id='properties-ctrl-dmRoleNotEqualList']"); | ||
const dropdownButton = dropDown.querySelectorAll("button")[0]; | ||
fireEvent.click(dropdownButton); | ||
const dropdownList = container.querySelectorAll("li.cds--list-box__menu-item"); | ||
expect(dropdownList).to.be.length(14); | ||
dropdownList.at(2).simulate("click"); | ||
wrapper.update(); | ||
fireEvent.click(dropdownList[2]); | ||
expect(controller.getControlState({ name: "checkbox3" })).to.equal("visible"); | ||
}); | ||
|
||
// This works in the UI but errorMessages is not updated in test | ||
it.skip("selectColumn control becomes validated if selected item has a dmRole equal to discrete", () => { | ||
const dropDown = wrapper.find("div[data-id='properties-dmMeasurementEqualList']"); | ||
const dropdownButton = dropDown.find("button").at(0); | ||
dropdownButton.simulate("click"); | ||
const dropdownList = wrapper.find("li.cds--list-box__menu-item"); | ||
it("selectColumn control becomes validated if selected item has a dmRole equal to discrete", () => { | ||
let errorMessages; | ||
const { container } = wrapper; | ||
const dropDown = container.querySelector("div[data-id='properties-dmMeasurementEqualList']"); | ||
const dropdownButton = dropDown.querySelectorAll("button")[0]; | ||
fireEvent.click(dropdownButton); | ||
let dropdownList = container.querySelectorAll("li.cds--list-box__menu-item"); | ||
expect(dropdownList).to.be.length(14); | ||
dropdownList.at(0).simulate("click"); // Trigger Error Message | ||
let errorMessages = controller.getErrorMessages(); | ||
expect(errorMessages).to.not.equal({}); | ||
fireEvent.click(dropdownList[0]); // Trigger Error Message | ||
errorMessages = controller.getErrorMessages(); | ||
expect(errorMessages).to.not.deep.equal({}); | ||
expect(errorMessages.dmMeasurementEqualList.type).to.equal("error"); | ||
dropdownButton.simulate("click"); | ||
dropdownList.at(3).simulate("click"); // Fulfill Condition by selecting item with dmRole discrete | ||
fireEvent.click(dropdownButton); | ||
dropdownList = container.querySelectorAll("li.cds--list-box__menu-item"); | ||
fireEvent.click(dropdownList[3]); // Fulfill condition | ||
errorMessages = controller.getErrorMessages(); | ||
expect(controller.getErrorMessages()).to.deep.equal({}); | ||
expect(errorMessages).to.deep.equal({}); | ||
|
||
}); | ||
|
||
// This works in the UI but errorMessages is not updated in test | ||
it.skip("selectColumn control become validated if selected item does not have a dmRole equal to discrete", () => { | ||
const dropDown = wrapper.find("div[data-id='properties-dmMeasurementNotEqualList']"); | ||
const dropdownButton = dropDown.find("button").at(0); | ||
dropdownButton.simulate("click"); | ||
const dropdownList = wrapper.find("li.cds--list-box__menu-item"); | ||
it("selectColumn control become validated if selected item does not have a dmRole equal to discrete", () => { | ||
const { container } = wrapper; | ||
const dropDown = container.querySelector("div[data-id='properties-dmMeasurementNotEqualList']"); | ||
const dropdownButton = dropDown.querySelectorAll("button")[0]; | ||
fireEvent.click(dropdownButton); | ||
let dropdownList = container.querySelectorAll("li.cds--list-box__menu-item"); | ||
expect(dropdownList).to.be.length(14); | ||
dropdownList.at(3).simulate("click"); // Trigger Error Message by selecting item with dmRole discrete | ||
fireEvent.click(dropdownList[3]); // Trigger Error Message by selecting item with dmRole discrete | ||
let errorMessages = controller.getErrorMessages(); | ||
expect(errorMessages).to.not.equal({}); | ||
expect(errorMessages.dmMeasurementNotEqualList.type).to.equal("error"); | ||
dropdownButton.simulate("click"); | ||
dropdownList.at(1).simulate("click"); // Fulfill Condition by selecting item with dmRole input | ||
fireEvent.click(dropdownButton); | ||
dropdownList = container.querySelectorAll("li.cds--list-box__menu-item"); | ||
fireEvent.click(dropdownList[1]); // Fulfill condition | ||
errorMessages = controller.getErrorMessages(); | ||
expect(errorMessages).to.deep.equal({}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the extra lines at beginning and end of file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed extra spaces.