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
Closed
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions pytest_splunk_addon_ui_smartx/components/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

"""
Returns the text from the more info field within a tables row
:param name: Str row name
:param cancel: Bool Whether or not to click cancel after getting the info
:param expand_row: Bool which specifies whether to expand `more_info` or not.
:return: Dict The information found when opening the info table on a row in the table
"""
_row = self._get_row(name)
_row.find_element(*list(self.elements["more_info"]._asdict().values())).click()
if expand_row:
_row.find_element(
*list(self.elements["more_info"]._asdict().values())
).click()
keys = self.more_info_row.find_elements(
*list(self.elements["more_info_key"]._asdict().values())
)
Expand Down
Loading