-
Notifications
You must be signed in to change notification settings - Fork 107
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
Disable creation of accordion navigation for single page #32
Conversation
def test_accordion_same_result_with_different_config(self, accordion_pages, accordion_from_page_as_list): | ||
result_navigation = Accordion(pages=accordion_pages, id="accordion_list") | ||
expected_navigation = accordion_from_page_as_list | ||
|
||
# setting accordion id to fix the random id generation | ||
expected_navigation.children.id = "accordion_list" | ||
|
||
result = json.loads(json.dumps(result_navigation.build(), cls=plotly.utils.PlotlyJSONEncoder)) | ||
expected = json.loads(json.dumps(expected_navigation, cls=plotly.utils.PlotlyJSONEncoder)) | ||
|
||
assert result == expected |
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.
This is removed as this is covered by test_accordion_build_default
. Essentially the important thing is that the default is always the list of pages. The user will get the same result whether they provide pages as a list of page IDs or they provide None.
result = json.loads(json.dumps(result_navigation.build(), cls=plotly.utils.PlotlyJSONEncoder)) | ||
expected = json.loads(json.dumps(accordion_from_pages_as_dict, cls=plotly.utils.PlotlyJSONEncoder)) | ||
|
||
@pytest.mark.parametrize("pages", [["Page 1", "Page 2"], {"Page 1": ["Page 1"], "Page 2": ["Page 2"]}, None]) |
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.
@nadijagraca - just FYI: I've reviewed the tests again and removed all of these here, as we already tested all of these in the test_accordion.py
. So, these are essentially duplicates.
The only test we need is that the accordion.build()
returns the same as the navigation.build()
, similar to how we have it for our tests in test_filter.py
. The only test that would be worth adding here is if, at some point, we make the Accordion public. In this case, we should test for the use case of precedence, so if pages are provided to Navigation and Accordion, the configuration for Accordion will have precedence.
However, given that this is private for now, this is not required yet.
vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py
Outdated
Show resolved
Hide resolved
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.
Really great addition (or removal :D). I just have two small questions, otherwise looks really good. 🚀
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.
🚀
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.
LGTM!
Description
Screenshot
One page only:
Note: Talked w/ J, and for now we've decided that in case the user does not provide a dashboard title, controls and one page only, the navigation bar will still be created. In the future, we could consider removing that automatically as well.
Checklist
Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
(if applicable)Types of changes