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

Fixes #37619 - Add ouia-ids for remediation wizard #574

Merged
merged 4 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"plugins": ["@theforeman/foreman"],
"extends": ["plugin:@theforeman/foreman/core", "plugin:@theforeman/foreman/plugins"]
}
"plugins": [
"@theforeman/foreman",
"@theforeman/rules"
],
"extends": [
"plugin:@theforeman/foreman/core",
"plugin:@theforeman/foreman/plugins"
],
"rules":{
"@theforeman/rules/require-ouiaid": ["error"]
}
}
21 changes: 21 additions & 0 deletions .github/workflows/js_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ concurrency:
cancel-in-progress: true

jobs:
lint_custom:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [14]
steps:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Npm install
run: |
npm install
- name: Run plugin linter
run: |
npm run lint
Copy link
Member

Choose a reason for hiding this comment

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

This already runs as part of foreman_plugin_js

Copy link
Member

Choose a reason for hiding this comment

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

maybe we should add it there, but thats a different pr 🙃

- name: Run custom plugin linter
run: |
npm run lint:custom
test:
name: JavaScript
uses: theforeman/actions/.github/workflows/foreman_plugin_js.yml@v0
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"scripts": {
"lint": "tfm-lint --plugin -d /webpack",
"lint:custom": "eslint ./webpack",
"test": "tfm-test --plugin --config jest.config.js",
"test:watch": "tfm-test --plugin --watchAll --config jest.config.js",
"test:current": "tfm-test --plugin --watch --config jest.config.js",
Expand All @@ -28,6 +29,7 @@
"@testing-library/user-event": "^13.2.1",
"@theforeman/builder": ">= 10.1.0",
"@theforeman/eslint-plugin-foreman": ">= 10.1.0",
"@theforeman/eslint-plugin-rules": ">= 10.1.0",
"@theforeman/find-foreman": ">= 10.1.0",
"@theforeman/test": ">= 10.1.0",
"@theforeman/vendor-dev": ">= 10.1.0",
Expand Down
3 changes: 3 additions & 0 deletions webpack/components/ConfirmModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const ConfirmModal = props => {

const actions = [
<Button
ouiaId={`oscap-conf-modal-${props.record.id}-confirm`}
Copy link
Member

Choose a reason for hiding this comment

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

props.record default is null. so this should be props.record?.id or something else

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Although, anything that is fixed here and is not related to the wizard should be removed, since those are leftovers from OVAL additions.

key="confirm"
variant="primary"
onClick={() => props.onConfirm(callMutation, props.record.id)}
Expand All @@ -19,6 +20,7 @@ const ConfirmModal = props => {
{__('Confirm')}
</Button>,
<Button
ouiaId={`oscap-conf-modal-${props.record.id}-cancel`}
key="cancel"
variant="link"
onClick={event => props.onClose()}
Expand All @@ -34,6 +36,7 @@ const ConfirmModal = props => {

return (
<Modal
ouiaId={`oscap-conf-modal-${props.record.id}`}
variant={ModalVariant.medium}
title={props.title}
isOpen={props.isOpen}
Expand Down
3 changes: 3 additions & 0 deletions webpack/components/EditableInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const EditableInput = props => {
const editBtn = (
<SplitItem>
<Button
ouiaId={`oscap-edit-${props.attrName}-edit-button`}
className="inline-edit-icon"
aria-label={`edit ${props.attrName}`}
variant="plain"
Expand Down Expand Up @@ -115,6 +116,7 @@ const EditableInput = props => {
</SplitItem>
<SplitItem>
<Button
ouiaId={`oscap-edit-${props.attrName}-submit-button`}
aria-label={`submit ${props.attrName}`}
variant="plain"
onClick={onSubmit}
Expand All @@ -125,6 +127,7 @@ const EditableInput = props => {
</SplitItem>
<SplitItem>
<Button
ouiaId={`oscap-edit-${props.attrName}-cancel-button`}
aria-label={`cancel editing ${props.attrName}`}
variant="plain"
onClick={onCancel}
Expand Down
14 changes: 12 additions & 2 deletions webpack/components/EmptyState.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@ const EmptyStateIcon = ({ error, search, lock }) => {
return <PfEmptyStateIcon icon={CubeIcon} />;
};

const EmptyState = ({ title, body, error, search, lock, primaryButton }) => (
const EmptyState = ({
title,
body,
error,
search,
lock,
primaryButton,
ouiaEmptyStateTitleId,
}) => (
<Bullseye>
<PfEmptyState variant={EmptyStateVariant.small}>
<EmptyStateIcon error={!!error} search={search} lock={lock} />
<Title headingLevel="h2" size="lg">
<Title ouiaId={ouiaEmptyStateTitleId} headingLevel="h2" size="lg">
{title}
</Title>
<EmptyStateBody>{body}</EmptyStateBody>
Expand Down Expand Up @@ -65,6 +73,7 @@ EmptyState.propTypes = {
search: PropTypes.bool,
lock: PropTypes.bool,
primaryButton: PropTypes.node,
ouiaEmptyStateTitleId: PropTypes.string,
};

EmptyState.defaultProps = {
Expand All @@ -75,6 +84,7 @@ EmptyState.defaultProps = {
search: false,
lock: false,
primaryButton: null,
ouiaEmptyStateTitleId: 'oscap-empty-state-title',
};

export default EmptyState;
4 changes: 3 additions & 1 deletion webpack/components/IndexLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const IndexLayout = ({ pageTitle, children, contentWidthSpan }) => (
<Grid className="scap-page-grid">
<GridItem span={12} className="pf-u-pb-xl">
<TextContent>
<Text component={TextVariants.h1}>{pageTitle}</Text>
<Text ouiaId="oscap-index-title" component={TextVariants.h1}>
{pageTitle}
</Text>
</TextContent>
</GridItem>
<GridItem span={contentWidthSpan}>{children}</GridItem>
Expand Down
3 changes: 3 additions & 0 deletions webpack/components/IndexTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const IndexTable = ({
totalCount,
toolbarBtns,
ariaTableLabel,
ouiaTableId,
columns,
...rest
}) => {
Expand Down Expand Up @@ -38,6 +39,7 @@ const IndexTable = ({
</FlexItem>
</Flex>
<Table
ouiaId={ouiaTableId}
aria-label={ariaTableLabel}
cells={columns}
{...rest}
Expand All @@ -56,6 +58,7 @@ IndexTable.propTypes = {
toolbarBtns: PropTypes.node,
totalCount: PropTypes.number.isRequired,
ariaTableLabel: PropTypes.string.isRequired,
ouiaTableId: PropTypes.string.isRequired,
columns: PropTypes.array.isRequired,
};

Expand Down
4 changes: 4 additions & 0 deletions webpack/components/LinkButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ const LinkButton = ({
btnText,
isDisabled,
btnAriaLabel,
ouiaId,
}) => (
<Link to={path}>
<Button
ouiaId={ouiaId}
variant={btnVariant}
isDisabled={isDisabled}
aria-label={btnAriaLabel}
Expand All @@ -27,12 +29,14 @@ LinkButton.propTypes = {
btnVariant: PropTypes.string,
isDisabled: PropTypes.bool,
btnAriaLabel: PropTypes.string,
ouiaId: PropTypes.string,
};

LinkButton.defaultProps = {
btnVariant: 'primary',
isDisabled: false,
btnAriaLabel: null,
ouiaId: 'oscap-link-button',
};

export default LinkButton;
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const ViewSelectedHostsLink = ({
const url = foremanUrl(`${useForemanHostsPageUrl()}?search=${search}`);
return (
<Button
ouiaId="oscap-rem-wiz-ext-link-to-hosts"
component="a"
variant="link"
icon={<ExternalLinkSquareAltIcon />}
Expand Down
1 change: 1 addition & 0 deletions webpack/components/OpenscapRemediationWizard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const OpenscapRemediationWizard = ({
</OpenscapRemediationWizardContext.Provider>
)}
<Button
ouiaId="oscap-rem-wiz-open-wiz-button"
id="openscapRemediationWizardButton"
variant="link"
isInline
Expand Down
9 changes: 8 additions & 1 deletion webpack/components/OpenscapRemediationWizard/steps/Finish.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const Finish = ({ onClose }) => {

const linkToJob = (
<Button
ouiaId="oscap-rem-wiz-job-details-link"
variant="link"
icon={<ExternalLinkSquareAltIcon />}
iconPosition="right"
Expand All @@ -84,7 +85,11 @@ const Finish = ({ onClose }) => {
{__('Job details')}
</Button>
);
const closeBtn = <Button onClick={onClose}>{__('Close')}</Button>;
const closeBtn = (
<Button ouiaId="oscap-rem-wiz-close-button-fin-step" onClick={onClose}>
{__('Close')}
</Button>
);
const errorComponent =
statusCode === 403 ? (
<PermissionDenied
Expand All @@ -93,6 +98,7 @@ const Finish = ({ onClose }) => {
/>
) : (
<EmptyState
ouiaEmptyStateTitleId="oscap-rem-wiz-empty-state-title"
error
title={__('Error!')}
body={errorMsg(data)}
Expand All @@ -102,6 +108,7 @@ const Finish = ({ onClose }) => {
const body =
status === STATUS.RESOLVED ? (
<EmptyState
ouiaEmptyStateTitleId="oscap-rem-wiz-empty-state-title"
title={__(
'The job has started on selected host(s), you can check the status on the job details page.'
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
selectAllMode,
};
}
}, [selectedCount, fetchBulkParams, setHostIdsParam]);

Check warning on line 112 in webpack/components/OpenscapRemediationWizard/steps/ReviewHosts.js

View workflow job for this annotation

GitHub Actions / lint_custom (14)

React Hook useEffect has missing dependencies: 'exclusionSet', 'inclusionSet', 'savedHostSelectionsRef', and 'selectAllMode'. Either include them or remove the dependency array

const selectionToolbar = (
<ToolbarItem key="selectAll">
Expand Down Expand Up @@ -166,6 +166,7 @@
title: __('Name'),
wrapper: ({ name, display_name: displayName }) => (
<Button
ouiaId={`oscap-rem-wiz-ext-link-to-host-${name}-revhst-step`}
component="a"
variant="link"
target="_blank"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const ReviewRemediation = () => {
</GridItem>
<GridItem md={12} span={4} rowSpan={1}>
<Button
ouiaId={`oscap-wiz-host-details-button-${hostName}-revrem-step`}
variant="link"
icon={<ExternalLinkSquareAltIcon />}
iconPosition="right"
Expand All @@ -130,6 +131,7 @@ const ReviewRemediation = () => {
</GridItem>
<GridItem md={12} span={8} rowSpan={1}>
<Button
ouiaId={`oscap-wiz-ext-link-to-hosts-${source}-revrem-step`}
variant="link"
icon={<ExternalLinkSquareAltIcon />}
iconPosition="right"
Expand All @@ -154,6 +156,7 @@ const ReviewRemediation = () => {
{method === 'manual' ? null : (
<GridItem span={4} rowSpan={1}>
<Checkbox
ouiaId="oscap-wiz-reboot-checkbox-revrem-step"
id="reboot-checkbox"
label={__('Reboot the system(s)')}
name="reboot-checkbox"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ const SnippetSelect = () => {
)}
</Form>
) : (
<EmptyState error title={__('Error!')} body={errorMsg(logError)} />
<EmptyState
ouiaEmptyStateTitleId="oscap-rem-wiz-empty-state-title"
error
title={__('Error!')}
body={errorMsg(logError)}
/>
);

return (
Expand Down
1 change: 1 addition & 0 deletions webpack/helpers/formFieldsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const SelectField = props => {
validated={valid}
>
<FormSelect
ouiaId={`oscap-form-sel-${field.name}`}
{...fieldProps}
className="without_select2"
aria-label={fieldProps.name}
Expand Down
Loading