-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #333 from BSd3v/dmc-tests
adds testing to dmc using GHA
- Loading branch information
Showing
5 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,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 | ||
This file contains 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
Empty file.
This file contains 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,5 @@ | ||
dash[ci,dev,testing]>=2.0 | ||
pyyaml>=5.0 | ||
pytest<8.1.0 | ||
wheel | ||
selenium<4.3.0 |
This file contains 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,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']") |