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

Disable creation of accordion navigation for single page #32

Merged
merged 7 commits into from
Sep 13, 2023

Conversation

huong-li-nguyen
Copy link
Contributor

@huong-li-nguyen huong-li-nguyen commented Sep 12, 2023

Description

  • Disable creation of accordion navigation if only single page is provided
  • Add test for disabling accordion navigation
  • Remove redundant tests from test_navigation and test_accordion

Screenshot

One page only:
Screenshot 2023-09-12 at 17 57 39

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

  • I have not referenced individuals, products or companies in any commits, directly or indirectly
  • I have not added data or restricted code in any commits, directly or indirectly
  • I have updated the docstring of any public function/class/model changed
  • I have added the PR number to the change description in the changelog fragment, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1)) (if applicable)

Types of changes

  • Docs/refactoring (non-breaking change which improves codebase)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Comment on lines -76 to -86
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
Copy link
Contributor Author

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])
Copy link
Contributor Author

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.

@huong-li-nguyen huong-li-nguyen marked this pull request as ready for review September 12, 2023 17:12
@huong-li-nguyen huong-li-nguyen self-assigned this Sep 12, 2023
@huong-li-nguyen huong-li-nguyen added Tests 🧪 Issue/PR that address test framework Status: Ready for Review ☑️ Issue/PR is ready for review - all tests have passed Issue: Feature Request 🤓 Issue/PR contains a feature request or is based on a feature request labels Sep 12, 2023
@huong-li-nguyen huong-li-nguyen changed the title Disable creation of accordion navigation for single page and clean tests Disable creation of accordion navigation for single page Sep 13, 2023
nadijagraca
nadijagraca previously approved these changes Sep 13, 2023
Copy link
Contributor

@nadijagraca nadijagraca left a 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. 🚀

Copy link
Contributor

@nadijagraca nadijagraca left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Contributor

@lingyielia lingyielia left a comment

Choose a reason for hiding this comment

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

LGTM!

@huong-li-nguyen huong-li-nguyen merged commit 53aa226 into main Sep 13, 2023
16 checks passed
@huong-li-nguyen huong-li-nguyen deleted the feat/disable_accordion_clean_tests branch September 13, 2023 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Feature Request 🤓 Issue/PR contains a feature request or is based on a feature request Status: Ready for Review ☑️ Issue/PR is ready for review - all tests have passed Tests 🧪 Issue/PR that address test framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants