-
Couldn't load subscription status.
- Fork 114
tests(brand-yml): Add tests for brand.yml #1764
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6fd07ad
Add tests for brand.yml
karangattu 8479e15
add brand file to pyright ignore list
karangattu ab3c87a
Merge branch 'main' into add-brand-yml-tests
karangattu 9fa99a5
Use the app from examples dir
karangattu 8e03657
Address code review comments
karangattu a385eb4
remove the trailing comma
karangattu 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 hidden or 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 hidden or 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
118 changes: 118 additions & 0 deletions
118
tests/playwright/shiny/brand_kitchensink/test_brand_yml.py
This file contains hidden or 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,118 @@ | ||
| import re | ||
| from typing import Any, Callable, Dict | ||
|
|
||
| from conftest import create_example_fixture | ||
| from playwright.sync_api import Locator, Page, expect | ||
|
|
||
| from shiny.playwright import controller | ||
| from shiny.run import ShinyAppProc | ||
|
|
||
| app = create_example_fixture("brand") | ||
|
|
||
|
|
||
| def test_brand_yml_kitchensink(page: Page, app: ShinyAppProc) -> None: | ||
| page.goto(app.url) | ||
|
|
||
| expected_styles = { | ||
| "primary_value_box": { | ||
| "background-color": "rgb(111, 66, 193)", | ||
| "color": "rgb(248, 248, 248)", | ||
| "font-family": re.compile(r"Monda.*"), | ||
| }, | ||
| "secondary_value_box": { | ||
| "background-color": "rgb(64, 64, 64)", | ||
| "color": "rgb(248, 248, 248)", | ||
| "font-family": re.compile(r"Monda.*"), | ||
| }, | ||
| "info_value_box": { | ||
| "background-color": "rgb(23, 162, 184)", | ||
| "color": "rgb(26, 26, 26)", | ||
| "font-family": re.compile(r"Monda.*"), | ||
| }, | ||
| "switch1": { | ||
| "background-color": "rgba(0, 0, 0, 0)", | ||
| "color": "rgb(26, 26, 26)", | ||
| "font-family": re.compile(r"Monda.*"), | ||
| }, | ||
| "out_text1": { | ||
| "background-color": "rgb(26, 26, 26)", | ||
| "color": "rgb(40, 167, 69)", | ||
| "font-family": re.compile(r"Share Tech Mono.*"), | ||
| }, | ||
| "default_btn": { | ||
| "background-color": "rgba(0, 0, 0, 0)", | ||
| "color": "rgb(64, 64, 64)", | ||
| "font-family": re.compile(r"Monda.*"), | ||
| }, | ||
| "primary_btn": { | ||
| "background-color": "rgb(111, 66, 193)", | ||
| "color": "rgb(248, 248, 248)", | ||
| "font-family": re.compile(r"Monda.*"), | ||
| }, | ||
| "secondary_btn": { | ||
| "background-color": "rgb(64, 64, 64)", | ||
| "color": "rgb(248, 248, 248)", | ||
| "font-family": re.compile(r"Monda.*"), | ||
| }, | ||
| "success_btn": { | ||
| "background-color": "rgb(40, 167, 69)", | ||
| "color": "rgb(26, 26, 26)", | ||
| "font-family": re.compile(r"Monda.*"), | ||
| }, | ||
| "danger_btn": { | ||
| "background-color": "rgb(255, 127, 80)", | ||
| "color": "rgb(26, 26, 26)", | ||
| "font-family": re.compile(r"Monda.*"), | ||
| }, | ||
| "warning_btn": { | ||
| "background-color": "rgb(255, 215, 0)", | ||
| "color": "rgb(26, 26, 26)", | ||
| "font-family": re.compile(r"Monda.*"), | ||
| }, | ||
| "info_btn": { | ||
| "background-color": "rgb(23, 162, 184)", | ||
| "color": "rgb(26, 26, 26)", | ||
| "font-family": re.compile(r"Monda.*"), | ||
| }, | ||
| } | ||
|
|
||
| component_mapping = { | ||
| "primary_value_box": controller.ValueBox, | ||
| "secondary_value_box": controller.ValueBox, | ||
| "info_value_box": controller.ValueBox, | ||
| "switch1": controller.InputSwitch, | ||
| "out_text1": controller.OutputText, | ||
| "default_btn": controller.InputActionButton, | ||
| "primary_btn": controller.InputActionButton, | ||
| "secondary_btn": controller.InputActionButton, | ||
| "success_btn": controller.InputActionButton, | ||
| "danger_btn": controller.InputActionButton, | ||
| "warning_btn": controller.InputActionButton, | ||
| "info_btn": controller.InputActionButton, | ||
| } | ||
|
|
||
| locator_mapping: Dict[type[Any], Callable[[Any], Locator]] = { | ||
| controller.ValueBox: lambda component: component.loc_container, | ||
| controller.InputSwitch: lambda component: component.loc_label, | ||
| controller.OutputText: lambda component: component.loc, | ||
| controller.InputActionButton: lambda component: component.loc, | ||
| } | ||
|
|
||
| # Iterate over expected styles and perform assertions | ||
| for component_name, styles in expected_styles.items(): | ||
| component_class = component_mapping[component_name] | ||
| component = component_class(page, component_name) | ||
| locator = locator_mapping[component_class](component) | ||
| for property_name, expected_value in styles.items(): | ||
| expect(locator).to_have_css(property_name, expected_value) | ||
|
|
||
| # inline-code block | ||
| expect(page.get_by_text("@reactive.effect")).to_have_css( | ||
| "background-color", "rgba(26, 26, 26, 0.867)" | ||
| ) | ||
| expect(page.get_by_text("@reactive.effect")).to_have_css( | ||
| "color", "rgb(255, 215, 0)" | ||
| ) | ||
| expect(page.get_by_text("@reactive.effect")).to_have_css( | ||
| "font-family", re.compile(r"Share Tech Mono.*") | ||
| ) |
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.
Uh oh!
There was an error while loading. Please reload this page.