Skip to content

Commit

Permalink
Merge pull request #333 from BSd3v/dmc-tests
Browse files Browse the repository at this point in the history
adds testing to dmc using GHA
  • Loading branch information
AnnMarieW authored Oct 9, 2024
2 parents f0a32f4 + ce47221 commit 597cbef
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Run tests

on:
push:
branches: [master]
tags:
- v*
pull_request:
branches: [master]

jobs:
test-react:
runs-on: ubuntu-latest
strategy:
matrix:
react-version: ["18.2.0"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: 3.12
- name: 'Setup Chrome and chromedriver'
uses: nanasess/setup-chromedriver@v2

- name: 'Setup chromedriver environment'
run: |
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
- name: Start XVFB
run: Xvfb :99 &

- name: Setup uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
- name: Install package
run: |
source .venv/bin/activate
uv pip install --upgrade pip
uv pip install wheel
uv pip install ".[dev]"
echo "Using React version ${{ matrix.react-version }}"
npm ci
npm install react@${{ matrix.react-version }} react-dom@${{ matrix.react-version }}
npm i
npm run build
timeout-minutes: 20
- run: npm run lint
- name: Run tests
run: |
source .venv/bin/activate
pytest --headless
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

### Added

- Added `autoplay` prop to the `Carousel` component #316 by @mmarfat
- Added `autoplay` prop to the `Carousel` component #316 by @mmarfat
- Added GitHub actions workflow for automated tests on PRs by @BSd3v

### Fixed

Expand Down
Empty file added deploy_test.py
Empty file.
5 changes: 5 additions & 0 deletions requires-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dash[ci,dev,testing]>=2.0
pyyaml>=5.0
pytest<8.1.0
wheel
selenium<4.3.0
56 changes: 56 additions & 0 deletions tests/test_multi_select.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from dash import Dash, html, Output, Input, _dash_renderer
import dash_mantine_components as dmc

_dash_renderer._set_react_version("18.2.0")

def test_001ms_multi_select(dash_duo):
app = Dash(__name__)

app.layout = dmc.MantineProvider(
html.Div([
dmc.MultiSelect(
id='multi-select',
data=[
{'value': 'option1', 'label': 'Option 1'},
{'value': 'option2', 'label': 'Option 2'},
{'value': 'option3', 'label': 'Option 3'}
],
placeholder='Select options'
),
html.Div(id='output')
])
)

@app.callback(
Output('output', 'children'),
Input('multi-select', 'value')
)
def update_output(selected_values):
return f'Selected: {selected_values}'

dash_duo.start_server(app)

# Wait for the app to load
dash_duo.wait_for_element("#multi-select")

# Select options
multi_select = dash_duo.find_element("#multi-select")
multi_select.click()

# Select 'Option 1' and 'Option 2'
option1 = dash_duo.find_element("div[value='option1']")
option2 = dash_duo.find_element("div[value='option2']")
option1.click()
option2.click()

# Verify the output
dash_duo.wait_for_text_to_equal("#output", "Selected: ['option1', 'option2']")

# Take a snapshot
dash_duo.percy_snapshot("multi-select-test")

# Deselect 'Option 1'
option1.click()

# Verify the output again
dash_duo.wait_for_text_to_equal("#output", "Selected: ['option2']")

0 comments on commit 597cbef

Please sign in to comment.