Skip to content

Conversation

@elsamaryv
Copy link
Contributor

  • Revamp of service dialogs (Also includes its conversion from Angular to React)

@miq-bot add-label enhancement
@miq-bot add-label wip

@@ -0,0 +1,37 @@
/* eslint-disable no-undef */

// Look for notification popups and disable them if present
Copy link
Member

Choose a reason for hiding this comment

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

Are these for "real" notifications or for debug-type notifications? If the latter, then this shouldn't be needed because if you run the webpack-dev-server and the rails server with CYPRESS=true then those debug-type notifications won't be there.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I went the same way, creating a command to get rid of these notifications before I knew CYPRESS variable to do CYPRESS=true bin/webpack for compiling assets for development

/* eslint-disable no-undef */

// Drag and drop a component to a section
Cypress.Commands.add('dragAndDropComponent', (componentName, targetSectionIndex = 0) => {
Copy link
Member

Choose a reason for hiding this comment

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

Because there are commands being defined globally, but are specific to service dialogs, I think the names should be prefixed with something like serviceDialog to avoid any name collisions and to clarify their purpose.

});

// Login and navigate to add a new service dialog
Cypress.Commands.add('navigateToAddDialog', () => {
Copy link
Member

Choose a reason for hiding this comment

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

well, maybe not this one because it also includes login and navigation

@Fryguy
Copy link
Member

Fryguy commented Aug 25, 2025

I know this is still WIP, but can @GilbertCherrie , @asirvadAbrahamVarghese please review to get a first pass on it?

@elsamaryv elsamaryv marked this pull request as ready for review August 26, 2025 10:55
@elsamaryv elsamaryv requested a review from a team as a code owner August 26, 2025 10:55
import PropTypes from 'prop-types';
import { InlineNotification } from 'carbon-components-react';

const InlineFlashMessage = ({ message, setMessage }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

  • if it’s just to pass through any actions required for the close button click maybe we could rename the prop to something like onCloseClick (I’m clueless when it comes to naming, so it’s your call)
  • Should we consider changing message to messageInfo, given that its an object? - again thats your call

Copy link
Contributor Author

@elsamaryv elsamaryv Aug 28, 2025

Choose a reason for hiding this comment

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

if it’s just to pass through any actions required for the close button click maybe we could rename the prop to something like onCloseClick

This component pulls InlineNotification component from carbon-components-react and is used to display contextual messages inline with other contents in the UI. onCloseButtonClick is actually a property of the InlineNotification component - It is an event handler that is only called when the user clicks the close button(if it is visible).

Screenshot 2025-08-28 at 3 50 04 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant the setMessage prop from our component that we’re using as the handler for onCloseButtonClick in InlineNotification, I feel like onCloseButtonClick ={onCloseClick} (or anything similar) seems better in this context

title={message.title || ''}
subtitle={message.subtitle || ''}
lowContrast
hideCloseButton={!setMessage}
Copy link
Contributor

@asirvadAbrahamVarghese asirvadAbrahamVarghese Aug 27, 2025

Choose a reason for hiding this comment

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

It might be better to control hideCloseButton through a separate boolean prop and set a default for it 🤔

lowContrast
hideCloseButton={!setMessage}
onCloseButtonClick={
typeof setMessage === 'function' ? () => setMessage(null) : undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking if we should directly do:
onCloseButtonClick={setMessage}
So that react will pass down the event automatically when setMessage handler is called similar to how we’d pass the event manually like:
onCloseButtonClick={(event)=>setMessage(event)}

So if in case we want to access any event methods (preventDefault, stopPropagation) from this component sometime later we can do:
<InlineFlashMessage setMessage={(event)=>{ event.preventDefault(); }} .... />

};

InlineFlashMessage.defaultProps = {
message: null,
Copy link
Contributor

@asirvadAbrahamVarghese asirvadAbrahamVarghese Aug 27, 2025

Choose a reason for hiding this comment

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

since we are doing if (!message) return null; at the top of the component, we can safely skip setting message as null from default props unless its marked required by PropTypes.shape({}).isRequired - the value received will be undefined and would still match our if(!message) condition


InlineFlashMessage.defaultProps = {
message: null,
setMessage: undefined,
Copy link
Contributor

@asirvadAbrahamVarghese asirvadAbrahamVarghese Aug 27, 2025

Choose a reason for hiding this comment

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

We can set a no-op function as default instead of undefined:
setMessage: () => {},
If thats throwing any eslint error(empty blocks), we can do:

  setMessage: () => {
    // default callback
  },

so that it prevents errors like “Cannot call setMessage of undefined”.
this also means we don’t have to explicitly verify typeof setMessage === 'function' before passing existing function reference directly: onCloseButtonClick={setMessage}
or even if we are creating a new arrow function on every render that calls onCloseButtonClick:

      onCloseButtonClick={() => {
        // any other action
        setMessage();
      }}

} from 'carbon-components-react';
import { getCurrentDate, getCurrentTimeAndPeriod } from '../service-dialog-form/helper';

const CustomDateTimePicker = (field) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct me here if I am wrong
We will be using the component like:

        <CustomDateTimePicker
          label="Custom Date Time Picker"
          initialData={{ date: '11/06/2025', time: '23:11', period: 'PM' }}
          onChange={(data) => {
            // any actions with on change data
          }}
        />

So I was thinking - just like we did with InlineFlashMessage, inline destructuring of component props is generally cleaner instead of accessing them via field object:
const CustomDateTimePicker = ({ label, onChange, initialData }) => {...

and then add props validations and default props for them:

CustomDateTimePicker.propTypes = {
  initialData: PropTypes.shape({
    date: PropTypes.string,
    time: PropTypes.string,
    period: PropTypes.string,
  }),
  onChange: PropTypes.func,
  label: PropTypes.string,
};

CustomDateTimePicker.defaultProps = {
  initialData: { date: '', time: '', period: '' },
  onChange: () => {},
  label: '',
};

Note: date, time and period having an empty string as default value ({ date: '', time: '', period: '' }) shouldn't be a problem as they are falsy in JS, fallback methods like getCurrentDate and getCurrentTimeAndPeriod will still be triggered to set states initial values

const CustomDateTimePicker = (field) => {
const { initialData, onChange } = field;

const [date, setDate] = useState(initialData.date || getCurrentDate);
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it would be better to call the function immediately (getCurrentDate) instead of passing the reference for React to call it automatically to get the initial state value when initialData.date is not available:
const [date, setDate] = useState(() => initialData.date || getCurrentDate());

also include the lazy initialization () =>🔝, like we did with time and period states initializations, so that the arrow function is only executed during the initial render, on subsequent re-renders, react knows it already has a state value and doesn't need to call the function again. The performance difference would be negligible here I believe, but it's better to use the arrow function for any initialization that creates objects, makes calculations or anything that could potentially be expensive.

const { initialData, onChange } = field;

const [date, setDate] = useState(initialData.date || getCurrentDate);
const [time, setTime] = useState(() => initialData.time || getCurrentTimeAndPeriod().time);
Copy link
Contributor

Choose a reason for hiding this comment

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

On initial render, time would look like this which is not in our expected "hh:mm" format, it should have been "09:54", But the invalid time error: "Enter a valid 12-hour time" is not displayed, probably thats because isValid state is initially true
image
Right after time field is edited the error is displayed since our state isValid state is now updated:
image

No issues with this implementation, this should work well once we apply zero-padding to the hour value in getCurrentTimeAndPeriod(similar to what we did with minutes).
It should be padded after converting to 12-hour format, otherwise, the modulo will reduce it to a single digit again.
hours = ${hours % 12 || 12}.padStart(2, '0');
Which should work well:
image

};

const handleDateChange = (newDate) => {
if (newDate.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if (newDate.length) should be fine here since 0 is also falsy in JS and any number greater than 0 will be truthy

const newTime = event.target.value;
setTime(newTime);
validateTime(newTime);
if (isValid) onChange({ value: combinedDateTime(), initialData });
Copy link
Contributor

Choose a reason for hiding this comment

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

Tried "11:5" in the time field, which doesn't match our pattern, so it's treated as an invalid time, the regex correctly returns false, which we also assign to the isValid state:
image
Given the condition(if (isValid) onChange({ ... });), we don't expect the onChange prop to be triggered in this case but it still gets called since isValid is still true(initial state value is true):
image
This is because state updates are asynchronous & batched and won't be reflecting immediately, when setIsValid is called react schedules the state update and updated value will be available only in the next render(only after the current event scope) not immediately after the call. So within the same event, we will still be accessing the previous state(which is true).

Returning the regex result from validateTime and using it for both setting state and controlling onChange should work fine:

  const validateTime = (value) => {
    const timeRegex = /^(0[1-9]|1[0-2]):[0-5][0-9]$/; // Matches 12-hour format hh:mm
    return timeRegex.test(value);
  };
  const handleTimeChange = (event) => {
    const newTime = event.target.value;
    setTime(newTime);
    const isValidTime = validateTime(newTime);
    setIsValid(isValidTime);
    if (isValidTime) onChange({ value: combinedDateTime(), initialData });
  };

const newTime = event.target.value;
setTime(newTime);
validateTime(newTime);
if (isValid) onChange({ value: combinedDateTime(), initialData });
Copy link
Contributor

Choose a reason for hiding this comment

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

The combinedDateTime function is also impacted the same way, we are updating the time state from here & then trying to access the state value from the same event scope, we will be having the previous time value due to react's batched updates.
Time field value is updated to "12:53" but time state will still provide its previous value "12:5" inside the same method scope:
image

Instead of relying on stale state we could update combinedDateTime to use the same input we're using for the state (in a way that it uses parameter value if available or the state value, thus other state values(date & period) are set):

  const combinedDateTime = ({ dateValue, timeValue, periodValue } = {}) =>
    `${dateValue || date} ${timeValue || time} ${periodValue || period}`;

🔝 we can also avoid the intermediate variable(const dateTime) by returning the string immediately

Now from handleTimeChange we can pass the value for time like:

    if (isValidTime) {
      onChange({
        value: combinedDateTime({ timeValue: newTime }),
        initialData,
      });
    }

So that correct updated time is returned from combinedDateTime
image

year: 'numeric',
}).format(newDate[0]);
setDate(formattedDate);
onChange({ value: combinedDateTime(), initialData });
Copy link
Contributor

Choose a reason for hiding this comment

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

Like discussed below, due to batched state updates we might want to update combinedDateTime to receive the updated date string:

  const combinedDateTime = ({ dateValue, timeValue, periodValue } = {}) =>
    `${dateValue || date} ${timeValue || time} ${periodValue || period}`;

and then from handleDateChange pass the date string value:

  const handleDateChange = (newDate) => {
    if (newDate.length) {
      const formattedDate = new Intl.DateTimeFormat('en-US', {
      .....
      onChange({
        value: combinedDateTime({ dateValue: formattedDate }),
        initialData,
      });
    }
  };


const handlePeriodChange = (event) => {
setPeriod(event.target.value);
onChange({ value: combinedDateTime(), initialData });
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, due to batched state updates we might want to update combinedDateTime to receive the updated period string:

  const combinedDateTime = ({ dateValue, timeValue, periodValue } = {}) =>
    `${dateValue || date} ${timeValue || time} ${periodValue || period}`;

and then from handlePeriodChange pass the updated period value:

  const handlePeriodChange = (event) => {
    const newPeriod = event.target.value;
    setPeriod(newPeriod);
    onChange({
      value: combinedDateTime({ periodValue: newPeriod }),
      initialData,
    });
  };


return (
<div>
<FormLabel>{field.label}</FormLabel>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the label prop expected to always be provided? The label element still gets rendered in the DOM even when no label is provided:
image
conditionally rendering it can help prevent unused elements in the DOM:
{label && <FormLabel>{label}</FormLabel>}
So that Label won't be rendered:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, {field.label} will always be present. It comes from the dynamic-field-configuration file

defaultDateTimePickerValue: { **label: __('Default value')**, name: 'value', field: 'date-time-picker' },

SelectItem,
FormLabel,
} from 'carbon-components-react';
import { getCurrentDate, getCurrentTimeAndPeriod } from '../service-dialog-form/helper';
Copy link
Contributor

Choose a reason for hiding this comment

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

Dealing with dates can be bug-prone. we should be fine for now with simple date logics but as logic grows, pulling in a utility like date-fns would help.

@elsamaryv elsamaryv changed the title [WIP] Conversion of Service Dialogs Form from Angular to React Conversion of Service Dialogs Form from Angular to React Sep 11, 2025
@elsamaryv elsamaryv force-pushed the service-dialogs-conversion branch from 78be4a5 to ad336c6 Compare October 7, 2025 09:36
schema={createSchema(usedTabNames, tabInfo.name)}
initialValues={{
tab_name: tabInfo.name,
tab_description: tabInfo.description,
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the Edit Tab modal isn’t storing the description field value after saving and reopening:
image
image

};

// Custom form template
const FormTemplate = ({ formFields }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Better if we can move this FormTemplate component outside of EditFieldModal component
It gets recreated on every render of EditFieldModal

@@ -0,0 +1,730 @@
/* eslint-disable radix */
import React, { useState, useRef, useEffect, useCallback } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like useCallback is not used

const dragEnterItem = useRef(null); /** Stores the information of component where the dragged item is being hovered before release. */
const draggedItem = useRef(null); /** Stores the information of component being dragged. */
const hoverItem = useRef(null); /** Stores the tab and section position during the drop event. */
const nextSectionId = useRef(1); /** Counter for generating unique section IDs */
Copy link
Contributor

Choose a reason for hiding this comment

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

To me it looks neat to use useRef for this, since the counter doesn’t need to cause unnecessary re-renders and the value sticks around
I’m just not sure if there are any downsides compared to using the state managing hooks like useState/useReducer

}
}
})
.catch((error) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to display the API error on the UI so it’s clear what failed? If that’s not required, we could just add an underscore prefix _error

}
}, [dialogData, dialogAction]);

const [isSubmitButtonEnabled, setIsSubmitButtonEnabled] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

For complex components, it’s better if we keep all the state up at the top of the component

evaluateSubmitButton();
}, [data]);

const onTabAction = (type, event) => tabAction({
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like onTabAction is not used

const [selTab, setSelTab] = useState(null);

const [showSectionEditModal, setSectionEditModal] = useState(false);
const [selSection, setSelSection] = useState(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Like mentioned above, better if we can move these states to the top



const onModalHide = () => setTabEditModal(false);
const onModalShow = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like onModalHide & onModalShow are not used


/** Function to render the Tab's name. */
const renderTabName = (tab) => (
<div className="dynamic-tab-name">
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking maybe we could prefix these classnames with the component name, like service-dialog-dynamic-tab-name
I’m just being cautious because while doing the C11 migration, I’ve noticed styles keep getting overridden here and there because of duplicate class names

{renderTabs()}
</Tabs>
</div>
);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if these renderTabName, renderSections, renderAddSectionButton , renderTabs, renderTabContents should be moved outside to avoid re-creation on every parent component render

description: data.description,
dialog_tabs: data.formFields
.filter((tab) => tab.tabId !== 'new') // Filter out the "Create new tab" option
.map((tab, index) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could turn these filter and map iterations into a single reduce to avoid looping over the array multiple times?

}
</div>
{/* Form submit/cancel buttons */}
<div className="custom-button-wrapper">
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thought as I mentioned here about class names

return result;
};

const getFieldsInfo = (fields) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

If there is no other logic to add, we can use parseFieldsInfo directly when required instead of a wrapper getFieldsInfo


const getTabsInfo = (tabs) =>
tabs
.map((tab) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Like mentioned above we can use reduce instead of map + filter I believe

});

export const formattedCatalogPayload = (data) => {
const payload = payloadForSave(data);
Copy link
Contributor

Choose a reason for hiding this comment

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

We can do this directly instead of using payloadForSave

export const formattedCatalogPayload = (data) => {
  const payload = { action: 'create', resource: getDialogInfo(data) };
  return payload;
};

const trimmed = value.trim().toLowerCase();

const isDuplicate = usedNames
.filter((name) => name.toLowerCase() !== currentName.toLowerCase())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can do this using some instead of filter, map and includes

const isDuplicate = usedNames.some((name) => 
  name.toLowerCase() !== currentName.toLowerCase() && 
  name.toLowerCase() === trimmed
);

ManageIQ.component.addReact('MiqCustomTab', MiqCustomTab);
ManageIQ.component.addReact('MiqDataTable', MiqDataTable);
ManageIQ.component.addReact('MiqMarkdown', MiqMarkdown);
ManageIQ.component.addReact('ServiceDialogForm', ServiceDialogForm);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to maintain alphabetical order here?

margin-right: 5%;
}
}
// CSS to adjust the UI for field array items in service dialog form
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove these if they won’t be required later on...

};

// Get the current time and period
export const getCurrentTimeAndPeriod = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Turns out we have moment lib, so may be we could use that to format dates & times:

const now = moment();
return {
  time: now.format("hh:mm"),
  period: now.format("A")
};

Moment should handle the 12-hour conversion and zero-padding automatically I guess


// Look for a server error pop up and close if visible
Cypress.Commands.add('closeErrorPopupIfVisible', () => {
cy.get('body').then(($body) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This gets called after navigating to 'Customization', is that error coming from an API during navigation maybe only sometimes or is this similar to the session timing bug with memcached? Something like this ⬇️
image

const renderTabs = () => data.formFields.map((tab, tabPosition) => (
<Tab
key={`tab${tabPosition.toString()}`}
draggable
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the tabs be draggable too?
image

Seems like the drop action isn’t working with them


// Enable Required
cy.get('.edit-field-modal input[name="required"]')
.check({ force: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

I’m guessing the force: true is needed because the input is small and Cypress thinks it’s hidden. Maybe we can target the label with the for attribute instead to interact with the input, like we did for the Default Value checkbox:
cy.get('.edit-field-modal label[for="checked"]').click();


it('should disable save button when label or name is not entered', () => {
const getSubmitButton = () => {
return cy.get('.edit-field-modal button[type="submit"]')
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to make the form element selectors more generic, you can use the selectors from the support commands for buttons, selects, labels, legends, and inputs. But if you’ve got two forms showing at the same time, things could get messy, for example, if you try to target the Cancel button in the modal form while there’s also a Cancel button in the main form, both will match and you’ll end up indexing them, which isn’t reliable I think

Cypress.Commands.add('navigateToAddDialog', () => {
cy.login();
cy.intercept('POST', '/ops/accordion_select?id=dialogs_accord'); // May not be needed; added to check the server error shown sometimes
cy.intercept('POST', '/ops/accordion_select?id=rbac_accord').as('accordion');
Copy link
Contributor

Choose a reason for hiding this comment

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

Accordion-select and Tree-select APIs are taken care of at the support command level (accordion & selectAccordionItem), so tests don’t need to handle them anymore unless we need to register a new intercept handler

.click();

// Step 10: Save the dialog
cy.get('.service-dialog-main-wrapper .custom-button-wrapper button').contains('Submit').click();
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to target buttons using their text, it’s probably better to just use contains:
cy.contains('.service-dialog-main-wrapper .custom-button-wrapper button', 'Submit').click();

@asirvadAbrahamVarghese
Copy link
Contributor

@jrafanie If you get a chance, can you review the Cypress here?

cy.dragAndDropComponent('Check Box');
});

it('should verify default properties of the checkbox', () => {
Copy link
Member

Choose a reason for hiding this comment

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

just searching for "should verify default properties", I can see each type of checkbox, datepicker, dropdown, etc. has a lot of similar assertions. Maybe they can be refactored to have shared helper functions.

Copy link
Member

Choose a reason for hiding this comment

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

The refactoring doesn't need to happen right now, but we're more likely to do it now vs. later.


// Enable dynamic option
cy.get('.edit-field-modal input[name="dynamic"]')
.check({ force: true });
Copy link
Member

Choose a reason for hiding this comment

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

force: true statements should have an explanation why they're needed... if it's being covered by another element, maybe there's a better way to do it by waiting for the object to be fully visible and accessible.

cy.openFieldEditModal(0, 0, 0);

// Initial state - button should be disabled
verifyButtonState(true);
Copy link
Member

Choose a reason for hiding this comment

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

instead of the comment, maybe the function call should look like this:

verifyButtonEnabled(false);

Currently, it looks like verifyButtonState(true); expect disabled... and verifyButtonState(false); means enabled which is negative logic. I think this might be easier to read:

verifyButtonEnabled(false); // disabled
verifyButtonEnabled(true);  // enabled

Or even:

verifyButtonState('enabled');
verifyButtonState('disabled');

(but then you need to check for strings... maybe my first suggestion is clearer. What do you think?

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.

6 participants