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

feat: add an argument to expand moreInfo of an input #441

Closed
wants to merge 3 commits into from

Conversation

hetangmodi-crest
Copy link
Contributor

Added an argument in get_more_info function which specifies whether to click on the arrow that display more info about an input.
This is required in a scenario as described in splunk/addonfactory-ucc-generator#1410.

@hetangmodi-crest hetangmodi-crest added the enhancement New feature or request label Nov 15, 2024
@hetangmodi-crest hetangmodi-crest self-assigned this Nov 15, 2024
@hetangmodi-crest hetangmodi-crest requested a review from a team as a code owner November 15, 2024 07:25
Copy link

@sgoral-splunk sgoral-splunk left a comment

Choose a reason for hiding this comment

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

I know it's simple change but maybe its worth to add some simple test just to test if it really skips the click? smth with pytest.raises etc.? What do you think?

@@ -487,15 +487,19 @@ def get_count_number(self):
row_count = self.get_count_title()
return int(re.search(r"\d+", row_count).group())

def get_more_info(self, name, cancel=True):
def get_more_info(self, name, cancel=True, expand_row=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 don't get the point of this flag. It seems like leaking abstraction for the method that should return the content of _More Info`. Why should caller of this method know about if it is open or close?

Here is my suggestion

  1. check if the row is expanded with attribute aria-expanded.
  2. if the value is 'false', click on the arrow
  3. if there is a Loading inside, wait it disappear (in case the custom row is used), it loads in runtime

Here is how I would write in UI unit tests

    const arrow = within(inputRow).getByRole('cell', { name: /expandable/i });
    const isExpanded = arrow.getAttribute('aria-expanded');
    if (isExpanded === 'false') {
        await userEvent.click(arrow);
    }
    await waitFor(() => expect(arrow.getAttribute('aria-expanded')).not.toBe('false'));
    const loading = screen.queryByText('Loading...');
    if (loading) {
        await waitForElementToBeRemoved(loading);
    }

Copy link
Contributor

Choose a reason for hiding this comment

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

We added the flag to ensure that the moreInfo section remains expanded based on the use case. This allows any changes made to the input's row to be immediately reflected in the custom row section without collapsing and re-expanding the moreInfo section.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have written the unit test case in my PR itself, so we don't need this change in smartx. Hence, we can close this PR.

@hetangmodi-crest
Copy link
Contributor Author

Added unit test cases for get_more_info function for expand_row parameter.

@rohanm-crest
Copy link
Contributor

Test case is covered in the PR PR-1445 so don't need this smartx changes. Hence, closing this PR.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants