diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml new file mode 100644 index 00000000..53560337 --- /dev/null +++ b/.github/workflows/python-test.yml @@ -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 + diff --git a/CHANGELOG.md b/CHANGELOG.md index c60adbfd..6535d99b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/deploy_test.py b/deploy_test.py new file mode 100644 index 00000000..e69de29b diff --git a/requires-dev.txt b/requires-dev.txt new file mode 100644 index 00000000..a208953f --- /dev/null +++ b/requires-dev.txt @@ -0,0 +1,5 @@ +dash[ci,dev,testing]>=2.0 +pyyaml>=5.0 +pytest<8.1.0 +wheel +selenium<4.3.0 \ No newline at end of file diff --git a/tests/test_multi_select.py b/tests/test_multi_select.py new file mode 100644 index 00000000..f0e0015f --- /dev/null +++ b/tests/test_multi_select.py @@ -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']")