- 
                Notifications
    You must be signed in to change notification settings 
- Fork 115
test(express): Add kitchensink apps & tests #1886
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 24 commits
      Commits
    
    
            Show all changes
          
          
            25 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      19a888d
              
                Add tests along with core & express apps
              
              
                karangattu 59eb594
              
                Add more tests
              
              
                karangattu 48568d1
              
                linting issues
              
              
                karangattu e007836
              
                Merge branch 'main' into add-kitchensink-ai-tests
              
              
                karangattu 1388794
              
                fixing imports
              
              
                karangattu 1fc21fc
              
                address flake8 issues
              
              
                karangattu 7c59aab
              
                fix missing imports
              
              
                karangattu ced84a2
              
                fix imports
              
              
                karangattu f0bc5b6
              
                fix times
              
              
                karangattu 9cb403c
              
                fix tests
              
              
                karangattu b61850f
              
                make apps use UTC timezone for consistent tests
              
              
                karangattu 5a1bc5c
              
                use datetime instead of date
              
              
                karangattu 4a48d5c
              
                use +0000 instead of UTC for timezone
              
              
                karangattu b5d1032
              
                use +0800 instead of +0000
              
              
                karangattu 3e97957
              
                use consistent timezones
              
              
                karangattu 6ffc625
              
                fix failing tests
              
              
                karangattu 8c9c910
              
                use consistent timezone
              
              
                karangattu 8a0efdf
              
                add padding 2px
              
              
                karangattu 23a3514
              
                move ai generated apps to separate job and directory
              
              
                karangattu 71b91e9
              
                update pyright ignore path for ai generated files dir
              
              
                karangattu 653d09b
              
                correct name
              
              
                karangattu d2ce926
              
                add 2 more apps
              
              
                karangattu 0c0f141
              
                Merge branch 'main' into add-kitchensink-ai-tests
              
              
                karangattu 9078ddf
              
                Update CHANGELOG.md
              
              
                karangattu 07707c4
              
                Update .github/workflows/pytest.yaml
              
              
                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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
            File renamed without changes.
          
    
            File renamed without changes.
          
    
            File renamed without changes.
          
    
        
          
          
            65 changes: 65 additions & 0 deletions
          
          65 
        
  tests/playwright/ai_generated_apps/accordion_panel/app-core.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,65 @@ | ||
| from shiny import App, render, ui | ||
|  | ||
| # Define the UI | ||
| app_ui = ui.page_fillable( | ||
| # Add Font Awesome CSS in the head section | ||
| ui.tags.head( | ||
| ui.tags.link( | ||
| rel="stylesheet", | ||
| href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css", | ||
| ) | ||
| ), | ||
| # Card containing accordion | ||
| ui.card( | ||
| ui.accordion( | ||
| # Basic Panel | ||
| ui.accordion_panel( | ||
| "Basic Panel", | ||
| ui.markdown("This is a basic panel with just a title parameter"), | ||
| ), | ||
| # Panel with title and value | ||
| ui.accordion_panel( | ||
| "Panel with Value", | ||
| ui.markdown("This panel has both a title and a value parameter"), | ||
| value="panel2", | ||
| ), | ||
| # Panel with title, value, and icon | ||
| ui.accordion_panel( | ||
| "Panel with Icon", | ||
| ui.markdown("This panel includes an icon parameter using Font Awesome"), | ||
| value="panel3", | ||
| icon=ui.tags.i( | ||
| class_="fa-solid fa-shield-halved", style="font-size: 1rem;" | ||
| ), | ||
| ), | ||
| # Panel with title, value, icon, and custom attributes | ||
| ui.accordion_panel( | ||
| "Panel with Custom Attributes", | ||
| ui.markdown( | ||
| "This panel demonstrates custom attributes (class and style)" | ||
| ), | ||
| value="panel4", | ||
| icon=ui.tags.i(class_="fa-solid fa-star", style="font-size: 1rem;"), | ||
| class_="custom-panel", | ||
| style="background-color: #f8f9fa;", | ||
| ), | ||
| id="acc", | ||
| open=True, | ||
| multiple=True, | ||
| ), | ||
| ), | ||
| # Output for selected panel | ||
| ui.output_text("selected_panel"), | ||
| ) | ||
|  | ||
|  | ||
| # Define the server | ||
| def server(input, output, session): | ||
| @output | ||
| @render.text | ||
| def selected_panel(): | ||
| return f"Currently selected panel: {input.acc()}" | ||
|  | ||
|  | ||
| # Create the app | ||
| app = App(app_ui, server) | 
        
          
          
            46 changes: 46 additions & 0 deletions
          
          46 
        
  tests/playwright/ai_generated_apps/accordion_panel/app-express.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,46 @@ | ||
| from shiny.express import input, render, ui | ||
|  | ||
| # Add Font Awesome CSS in the head section first | ||
| ui.head_content( | ||
| ui.HTML( | ||
| '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">' | ||
| ) | ||
| ) | ||
|  | ||
| ui.page_opts(fillable=True) | ||
|  | ||
| with ui.card(): | ||
| with ui.accordion(id="acc", open=True, multiple=True): | ||
| # Panel with just title | ||
| with ui.accordion_panel("Basic Panel"): | ||
| ui.markdown("This is a basic panel with just a title parameter") | ||
|  | ||
| # Panel with title and value | ||
| with ui.accordion_panel("Panel with Value", value="panel2"): | ||
| ui.markdown("This panel has both a title and a value parameter") | ||
|  | ||
| # Panel with title, value, and icon | ||
| with ui.accordion_panel( | ||
| "Panel with Icon", | ||
| value="panel3", | ||
| icon=ui.tags.i( | ||
| class_="fa-solid fa-shield-halved", style="font-size: 1rem;" | ||
| ), | ||
| ): | ||
| ui.markdown("This panel includes an icon parameter using Font Awesome") | ||
|  | ||
| # Panel with title, value, icon, and custom attributes | ||
| with ui.accordion_panel( | ||
| "Panel with Custom Attributes", | ||
| value="panel4", | ||
| icon=ui.tags.i(class_="fa-solid fa-star", style="font-size: 1rem;"), | ||
| class_="custom-panel", | ||
| style="background-color: #f8f9fa;", | ||
| ): | ||
| ui.markdown("This panel demonstrates custom attributes (class and style)") | ||
|  | ||
|  | ||
| # Show which panel is currently selected | ||
| @render.text | ||
| def selected_panel(): | ||
| return f"Currently selected panel: {input.acc()}" | 
        
          
          
            59 changes: 59 additions & 0 deletions
          
          59 
        
  tests/playwright/ai_generated_apps/accordion_panel/test_accordion_panel_core_express.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,59 @@ | ||
| from playwright.sync_api import Page | ||
|  | ||
| from shiny.playwright import controller | ||
| from shiny.pytest import create_app_fixture | ||
| from shiny.run import ShinyAppProc | ||
|  | ||
| app = create_app_fixture(["app-core.py", "app-express.py"]) | ||
|  | ||
|  | ||
| def test_accordion_demo(page: Page, app: ShinyAppProc) -> None: | ||
| page.goto(app.url) | ||
|  | ||
| # Test accordion with ID "acc" | ||
| accordion = controller.Accordion(page, "acc") | ||
|  | ||
| # Test that multiple panels can be open | ||
| accordion.expect_multiple(True) | ||
|  | ||
| # Test that accordion is initially open | ||
| panel1 = accordion.accordion_panel("Basic Panel") | ||
| panel2 = accordion.accordion_panel("panel2") | ||
| panel3 = accordion.accordion_panel("panel3") | ||
| panel4 = accordion.accordion_panel("panel4") | ||
|  | ||
| # Test initial state | ||
| panel1.expect_open(True) | ||
| panel2.expect_open(True) | ||
| panel3.expect_open(True) | ||
| panel4.expect_open(True) | ||
|  | ||
| # Test panel labels | ||
| panel1.expect_label("Basic Panel") | ||
| panel2.expect_label("Panel with Value") | ||
| panel3.expect_label("Panel with Icon") | ||
| panel4.expect_label("Panel with Custom Attributes") | ||
|  | ||
| # Test panel content | ||
| panel1.expect_body("This is a basic panel with just a title parameter") | ||
| panel2.expect_body("This panel has both a title and a value parameter") | ||
| panel3.expect_body("This panel includes an icon parameter using Font Awesome") | ||
| panel4.expect_body("This panel demonstrates custom attributes (class and style)") | ||
|  | ||
| # Test icons (presence/absence) | ||
| panel1.expect_icon(False) # First panel has no icon | ||
| panel2.expect_icon(False) # Second panel has no icon | ||
| panel3.expect_icon(True) # Third panel has an icon | ||
| panel4.expect_icon(True) # Fourth panel has an icon | ||
|  | ||
| # Test closing and opening panels | ||
| panel1.set(False) | ||
| panel1.expect_open(False) | ||
| panel1.set(True) | ||
| panel1.expect_open(True) | ||
|  | ||
| # Test output text that shows selected panel | ||
| selected_text = controller.OutputText(page, "selected_panel") | ||
| selected_text.expect_value( | ||
| "Currently selected panel: ('Basic Panel', 'panel2', 'panel3', 'panel4')" | ||
| ) | 
  
    
      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,46 @@ | ||
| from shiny import App, render, ui | ||
|  | ||
| # Define the UI | ||
| app_ui = ui.page_fillable( | ||
| # Card with all possible parameters | ||
| ui.card( | ||
| ui.card_header("Card Demo", "This demonstrates all card parameters"), | ||
| ui.markdown( | ||
| """ | ||
| This is the main content of the card. | ||
| The card has various parameters set including: | ||
|  | ||
| * full_screen=True - allows expanding to full screen | ||
| * height='300px' - sets fixed height | ||
| * fill=True - allows card to grow/shrink | ||
| * class_='my-4' - adds custom CSS classes | ||
| """ | ||
| ), | ||
| ui.card_footer("Card Footer", class_="text-muted"), | ||
| id="demo_card", | ||
| full_screen=True, # Allow card to be expanded to full screen | ||
| height="300px", # Set card height | ||
| fill=True, # Allow card to grow/shrink to fit container | ||
| class_="my-4", # Add custom CSS classes | ||
| ), | ||
| # Another card showing dynamic content | ||
| ui.card( | ||
| ui.card_header("Dynamic Content Demo"), | ||
| ui.output_text("dynamic_content"), | ||
| id="dynamic_card", | ||
| full_screen=True, | ||
| height="200px", | ||
| class_="mt-4", | ||
| ), | ||
| ) | ||
|  | ||
|  | ||
| # Define the server | ||
| def server(input, output, session): | ||
| @render.text | ||
| def dynamic_content(): | ||
| return "This card shows how to include dynamic content using render functions" | ||
|  | ||
|  | ||
| # Create the app | ||
| app = App(app_ui, server) | 
  
    
      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,39 @@ | ||
| from shiny.express import render, ui | ||
|  | ||
| # Set page options | ||
| ui.page_opts(fillable=True) | ||
|  | ||
| # Card with all possible parameters | ||
| with ui.card( | ||
| id="demo_card", | ||
| full_screen=True, # Allow card to be expanded to full screen | ||
| height="300px", # Set card height | ||
| fill=True, # Allow card to grow/shrink to fit container | ||
| class_="my-4", # Add custom CSS classes | ||
| ): | ||
| # Card header | ||
| ui.card_header("Card Demo", "This demonstrates all card parameters") | ||
|  | ||
| # Card body content | ||
| ui.markdown( | ||
| """ | ||
| This is the main content of the card. | ||
| The card has various parameters set including: | ||
|  | ||
| * full_screen=True - allows expanding to full screen | ||
| * height='300px' - sets fixed height | ||
| * fill=True - allows card to grow/shrink | ||
| * class_='my-4' - adds custom CSS classes | ||
| """ | ||
| ) | ||
|  | ||
| # Card footer | ||
| ui.card_footer("Card Footer", class_="text-muted") | ||
|  | ||
| # Another card showing dynamic content | ||
| with ui.card(id="dynamic_card", full_screen=True, height="200px", class_="mt-4"): | ||
| ui.card_header("Dynamic Content Demo") | ||
|  | ||
| @render.text | ||
| def dynamic_content(): | ||
| return "This card shows how to include dynamic content using render functions" | 
      
      Oops, something went wrong.
        
    
  
      
      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.