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

add tests for the node resize feature and properties panel #27

Conversation

jomarko
Copy link
Collaborator

@jomarko jomarko commented Mar 28, 2024

As part of this PR we add:

  • Tests of the resize feature. We select node, using its resize-handle element we increase its size and then we check the size property in the properties panel
  • We change node properties and check the properties panel effect
  • We change the diagram properties and check the effect in the properties panel
  • We change font properties when multiple nodes are selected

@jomarko jomarko force-pushed the kie-issues-946-part-3-resize branch from ac293fe to 118c202 Compare April 2, 2024 14:48
@jomarko jomarko changed the title add tests for the node resize feature and properties of Group and text Annotation [WIP] add tests for the node resize feature and properties panel Apr 2, 2024
Comment on lines 376 to 394
<div data-testid="node-font-style-selector">
<Select
toggleRef={toggleRef}
variant={SelectVariant.single}
aria-label={"Select font style"}
isOpen={isFontFamilySelectOpen}
onSelect={onSelectFont}
onToggle={() => setFontFamilySelectOpen((prev) => !prev)}
selections={fontFamily ?? ""}
isDisabled={false}
maxHeight={inViewTimezoneSelect.maxHeight}
direction={inViewTimezoneSelect.direction}
>
{WEBSAFE_FONTS_LIST.map((fontName, index) => (
<SelectOption key={index} value={fontName} style={{ fontFamily: fontName }} />
))}
</Select>
</div>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can not simply add data-testid int Select, patternfly for some reason ignores that attribute.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could use a React.Fragment instead of the div? Not sure if the div changes something on the UI.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we can not, <React.Fragment data-testid={"xyz"}> has no effect for the produced html. The data-testid is not in the generated html at all.

@jomarko jomarko marked this pull request as ready for review April 4, 2024 11:02
@jomarko jomarko changed the title [WIP] add tests for the node resize feature and properties panel add tests for the node resize feature and properties panel Apr 4, 2024
Copy link
Owner

@ljmotta ljmotta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, the tests are looking good, but it's still missing a few ones. Some of them I've added inline on the test files. We also need to test the documentation links with more cases. Add one more and change orders, for example. We also need to test the reset style button, for now, we can only test with the node font. The documentation links can be added to a different file, as it's not node specific.

Great job on the resize tests. But they are missing a few cases too:

  • Resize with the snapping on?
  • Change the snapping values?
  • Resize on top of another node?

Now, regarding the fixtures, I don't think they're looking good. The class inheritance doesn't fit in some cases, making it necessary to add throw new Error methods. The way to solve this is with class composition. Instead of inheritance, we pass the instance or create the instance on the constructor and attribute it to one property. This way the class will have only the necessary methods. Also, I don't think this would be good either. We can't be sure the nodes will always share those properties, and maybe the best way is to replicate the logic on each class, removing the coupling altogether. Duplicating the code isn't a bad thing in this case, as it'll remove the complexity of creating the abstraction.

Comment on lines 376 to 394
<div data-testid="node-font-style-selector">
<Select
toggleRef={toggleRef}
variant={SelectVariant.single}
aria-label={"Select font style"}
isOpen={isFontFamilySelectOpen}
onSelect={onSelectFont}
onToggle={() => setFontFamilySelectOpen((prev) => !prev)}
selections={fontFamily ?? ""}
isDisabled={false}
maxHeight={inViewTimezoneSelect.maxHeight}
direction={inViewTimezoneSelect.direction}
>
{WEBSAFE_FONTS_LIST.map((fontName, index) => (
<SelectOption key={index} value={fontName} style={{ fontFamily: fontName }} />
))}
</Select>
</div>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could use a React.Fragment instead of the div? Not sure if the div changes something on the UI.

packages/dmn-editor/src/propertiesPanel/FontOptions.tsx Outdated Show resolved Hide resolved
packages/dmn-editor/src/propertiesPanel/ShapeOptions.tsx Outdated Show resolved Hide resolved
packages/dmn-editor/src/propertiesPanel/ShapeOptions.tsx Outdated Show resolved Hide resolved
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the skipped change color test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I do not get it, as I tried to explain, I am not able to write a test for a color change using playwright. Could you please help me and advise how to write such a test? I am not able to handle the color picker we use in KIE tooling.

@jomarko jomarko force-pushed the kie-issues-946-part-3-resize branch from 6ba7c02 to af9a679 Compare April 12, 2024 11:05
@jomarko
Copy link
Collaborator Author

jomarko commented Apr 15, 2024

replaced by apache#2239

@jomarko jomarko closed this Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants