-
Notifications
You must be signed in to change notification settings - Fork 3
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
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import pytest | ||
from unittest.mock import MagicMock, patch | ||
from selenium.webdriver.common.by import By | ||
from pytest_splunk_addon_ui_smartx.components.table import Table | ||
|
||
|
||
@pytest.fixture | ||
def mock_table(): | ||
mock_browser = MagicMock() | ||
|
||
# Mocking container with a `select` attribute | ||
mock_container = MagicMock() | ||
mock_container.select = "#test-container" | ||
table = Table(mock_browser, mock_container) | ||
return table | ||
|
||
|
||
@patch("pytest_splunk_addon_ui_smartx.components.table.Table._get_row") | ||
def test_get_more_info_expand_row_false(mock_get_row, mock_table): | ||
mock_row = MagicMock() | ||
mock_get_row.return_value = mock_row | ||
|
||
mock_more_info_element = MagicMock() | ||
mock_row.find_element.return_value = mock_more_info_element | ||
|
||
# Calling the function with expand_row=False and cancel=False as we are testing for expand_row parameter | ||
mock_table.get_more_info(name="Test Row", cancel=False, expand_row=False) | ||
|
||
mock_get_row.assert_called_with("Test Row") | ||
mock_row.find_element.assert_not_called() | ||
mock_more_info_element.click.assert_not_called() | ||
|
||
|
||
@patch("pytest_splunk_addon_ui_smartx.components.table.Table._get_row") | ||
def test_get_more_info_expand_row_true(mock_get_row, mock_table): | ||
mock_row = MagicMock() | ||
mock_get_row.return_value = mock_row | ||
|
||
mock_more_info_element = MagicMock() | ||
mock_row.find_element.return_value = mock_more_info_element | ||
|
||
mock_key1 = MagicMock() | ||
mock_key1.get_attribute.return_value = " Key1 " | ||
mock_key2 = MagicMock() | ||
mock_key2.get_attribute.return_value = " Key2 " | ||
|
||
mock_value1 = MagicMock() | ||
mock_value1.get_attribute.return_value = " Value1 " | ||
mock_value2 = MagicMock() | ||
mock_value2.get_attribute.return_value = " Value2 " | ||
|
||
mock_table.more_info_row.find_elements.side_effect = [ | ||
[mock_key1, mock_key2], | ||
[mock_value1, mock_value2], | ||
] | ||
|
||
# Call the function with expand_row=True and cancel=False as we are testing for expand_row parameter | ||
result = mock_table.get_more_info(name="Test Row", cancel=False, expand_row=True) | ||
|
||
mock_get_row.assert_called_with("Test Row") | ||
mock_more_info_element.click.assert_called_once() | ||
assert result == {"Key1": "Value1", "Key2": "Value2"} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
aria-expanded
.'false'
, click on the arrowLoading
inside, wait it disappear (in case the custom row is used), it loads in runtimeHere is how I would write in UI unit tests
There was a problem hiding this comment.
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 themoreInfo
section.There was a problem hiding this comment.
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.