Skip to content

Conversation

@kfamilonidis
Copy link
Contributor

@kfamilonidis kfamilonidis commented Oct 17, 2025

Background

Editor and <EditorNavBar /> upgrade to next version of react requires substitution of Enzyme tests with RTL (React Testing Library) framework.

Acceptance Criteria

  • Upgrade of components to use PF/5 variants.
    • Hosts -> Templates -> Job Templates -> New Job Template (path: /job_templates/new)
    • Hosts -> Templates -> Job Templates -> (any or clone) -> Edit (path: /job_templates/xyz/edit)
  • Removal of Enzyme in all related tests.

Tests

npm run test -- assets/javascripts/react_app/components/Editor assets/javascripts/react_app/components/DiffView

followed by: #10777

@github-actions github-actions bot added the UI label Oct 17, 2025
@kfamilonidis kfamilonidis force-pushed the pf5-editor-nav-bar branch 6 times, most recently from 3e7a6c1 to 880cb47 Compare October 21, 2025 12:03
@kfamilonidis kfamilonidis force-pushed the pf5-editor-nav-bar branch 5 times, most recently from f7cbd8f to 86ff36b Compare October 29, 2025 15:52
@kfamilonidis kfamilonidis marked this pull request as ready for review October 29, 2025 16:25
Copy link
Contributor Author

@kfamilonidis kfamilonidis left a comment

Choose a reason for hiding this comment

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

Still needs progress to remove the snaps from the test that are testing components properties, but have noticed that some snaps are different from others; some are keeping store props, and some keeping components props. I would like to ask for some opinion on should we remove both snap types, or should we keep the store props - as the later might be serve as fixtures in the future (maybe transition to other store).

@kfamilonidis kfamilonidis force-pushed the pf5-editor-nav-bar branch 2 times, most recently from 4474901 to 2fefd25 Compare November 10, 2025 11:51
@kfamilonidis
Copy link
Contributor Author

kfamilonidis commented Nov 10, 2025

I would like to ask for some opinion on should we remove both snap types, or should we keep the store props - as the later might be serve as fixtures in the future (maybe transition to other store).

The *Actions, *Selectors and *Reducer snapshots are not replaceable with the RTL (React Testing Library) approach. They test logic that falls outside of RTL's context. Similarly, the integration tests snapshots. Importantly, these snapshots are not blocking the major React version upgrade

@kfamilonidis kfamilonidis force-pushed the pf5-editor-nav-bar branch 6 times, most recently from a7def11 to ebd3141 Compare November 11, 2025 13:53
pnovotny added a commit to pnovotny/airgun that referenced this pull request Dec 15, 2025
Locator for the template nagigation bar (Editor/Changes/Preview) has slightly changed.

Related to change theforeman/foreman#10728
import PropTypes from 'prop-types';

import { Button, FormControl } from 'patternfly-react';
import { FormControl } from 'patternfly-react';
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this though?

It's used for upload file functionality, but I guess we can use FileUploadField from PF instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel that we still need this. The tabs UI is handled differently in EditorOptions. upload file renders grouped icons with help menus with some offering form with dropdown; see settings.

FileUploadField will render as Tab. That would be different from the current flow of the user experience. Tabs now are split left-to-right with split in the middle and the ones floating right are grouped together. Changing FileUploadField will be possible breaking the flow of these items that are currently grouped together (show/hide, revert, import, settings).

<Tooltip content={__('Import File')} position={TooltipPosition.top}>
<Button
ouiaId="import-file-button"
disabled={selectedView !== 'input'}
Copy link
Member

Choose a reason for hiding this comment

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

Comment from Copilot is still valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, this comment is valid. I fixed it, ty. In EditorRadioButton, NavItem isDisabled is breaking the app.

title,
}) => (
<NavItem
role="presentation"
Copy link
Member

Choose a reason for hiding this comment

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

What's that for? I don't see it listed as one of the props for NavItem: https://v5-archive.patternfly.org/components/navigation#navitem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is used for linking the test with getByRole instead of using custom css. It's evolution in UI semantics that is included some parts in codebase and I adjusted it the same (because I thought would make more sence). Is used in PF6 as default attribute for NavItem, and here is passed as prop to children.

Copy link
Member

Choose a reason for hiding this comment

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

I'd personally avoid changing internal stuff that we don't control or maybe shouldn't just for the sake of testing. That's what ouia's for. Or we could write a new custom selector getBySomething if current ones are not sufficient enough.

Copy link
Member

Choose a reason for hiding this comment

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

since its an Icon it should have a title and aria-title for accesebility and clarity , we can use that for testing. Also this icon is never really visible, I opened https://issues.redhat.com/browse/SAT-40711 for it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the implementation of NavItem to Tabs. Using the role attribute to link them helped me focus only on the elements that needed changes for the new abstraction. Now, Tabs handle the role attribute internally, and the tests required minimum updates. This ensures the tests are verifying exactly what’s needed.

I don’t think settings belongs as part of the Tabs UI, and it shouldn’t be. However, I agree that the showHide attribute logic is mixed in and a bit obscure throughout the component. That part will need closer attention.

@kfamilonidis
Copy link
Contributor Author

Also seeing how much css overrides we do to make the Nav component behave like Tab component, and with the new pf5 css I noticed also the active tab title are too bright so they will also need an override for the colour, why not just use the tab component?

I have tried to use the NavItem from PF5 with no luck as it seems it doesn't support disable. I agree that Tab could be more appropriate component for this case and I am looking at it. The css overrides could be minimized after this change.

@kfamilonidis
Copy link
Contributor Author

kfamilonidis commented Dec 18, 2025

Updated EditorNavBar from NavItems to Tabs. Results look different and more close to PF5 variant without much css overrides. Next is to remove old css completely. SelectHost menu needs a complete new approach. Please see the new look:

Full window width:

Screenshot From 2025-12-18 16-53-07

Adjusted to smaller size:

Screenshot From 2025-12-18 16-53-24

With preview select:

Screenshot From 2025-12-18 16-53-37

@kfamilonidis kfamilonidis force-pushed the pf5-editor-nav-bar branch 4 times, most recently from 256ef67 to 7af06d2 Compare December 22, 2025 11:03
Copy link
Member

@MariaAga MariaAga left a comment

Choose a reason for hiding this comment

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

Quick notes:

  • Why is there space between the navbar and the editor?
Image
  • when clicking on the safemode checkbox nothing happens
Image
  • Clicking on the right side arrow does not move the navbar to show all the other tools
Image
  • host select should not increase the size of the navbar
Image
  • separator line should be in the centre
Image

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 32 out of 32 changed files in this pull request and generated 20 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +184 to +195
/* NOTE: raises Each child in a list should have a unique "key" prop.%s%s
tabs.push(
<div key="preview-spinner" id="preview-spinner">
{showPreview && isLoading ? <Spinner size="sm" /> : null}
</div>
);
*/
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The comment about raising "Each child in a list should have a unique key prop" warning is concerning and suggests there may be an unresolved issue. Since all other items in the tabs array have unique keys, and this code is commented out, it appears the spinner functionality was removed. If the spinner is needed, the issue should be resolved rather than commented out. If it's not needed, the comment block should be removed entirely.

Suggested change
/* NOTE: raises Each child in a list should have a unique "key" prop.%s%s
tabs.push(
<div key="preview-spinner" id="preview-spinner">
{showPreview && isLoading ? <Spinner size="sm" /> : null}
</div>
);
*/

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +6
import { FormControl } from 'patternfly-react';
import { Button, Icon, Tooltip, TooltipPosition } from '@patternfly/react-core';
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

FormControl is still imported from the old 'patternfly-react' library (PF3/PF4) instead of '@patternfly/react-core' (PF5). Since this PR is migrating to PF5, this import should be updated to use the PF5 equivalent or a native HTML input element with appropriate styling.

Suggested change
import { FormControl } from 'patternfly-react';
import { Button, Icon, Tooltip, TooltipPosition } from '@patternfly/react-core';
import { Button, Icon, Tooltip, TooltipPosition, FormSelect as FormControl } from '@patternfly/react-core';

Copilot uses AI. Check for mistakes.
))}
</FormSelect>
</FormGroup>
<FormGroup
Copy link
Member

Choose a reason for hiding this comment

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

Image

checkboxs and text are still not aligned

Comment on lines 196 to 187
<Button
ouiaId="maximize-editor-button"
className="editor-button"
Copy link
Member

Choose a reason for hiding this comment

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

fullscreen button is not aligned to the other buttons

Image

Copy link
Contributor Author

@kfamilonidis kfamilonidis Dec 23, 2025

Choose a reason for hiding this comment

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

thanks. An element ID was missing when styles where applied, now fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

about labels and check-boxes centering: did a css override to handle cases that appear inside pf5 forms.

Upgrade NavBar (Alert, Button), Options (RadioButton, View), Settings.
Remove enzyme in tests including DiffView, HostSelect, EditorView. Keep
actions, and selectors tests.
@kfamilonidis
Copy link
Contributor Author

Quick notes:

  • Why is there space between the navbar and the editor?

Fixed. Have removed some old css, but still some are present such navbar navbar-form navbar-editor. I try to focus on adding only to one namespace, if needed to override an existing glitch. pls. see .navbar.navbar-editor in editor.scss

  • when clicking on the safemode checkbox nothing happens

Not sure is tested. Is assumed to be always disabled.

  • Clicking on the right side arrow does not move the navbar to show all the other tools

Noticed this. It's not a consistent behavior as there are time when it moves, and others not. Need to look at it closer.

  • host select should not increase the size of the navbar

This is a problem now. The Tab elements are now wrapping the whole Select element, are not floating, and the select element needs to find a way to break out of the normal flow of surounding Tabs.

  • separator line should be in the centrer

Tried to. Hope it's fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants