Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [unreleased]
### Fixed
- Fix Vertical Slider regression [#479](https://github.com/plotly/dash/issues/479)

## [0.44.0] - 2019-03-04
### Added
Expand Down
3 changes: 2 additions & 1 deletion src/components/Slider.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ export default class Slider extends Component {
}

render() {
const {id, setProps, updatemode, loading_state} = this.props;
const {id, loading_state, setProps, updatemode, vertical} = this.props;
const {value} = this.state;
return (
<div
id={id}
data-dash-is-loading={
(loading_state && loading_state.is_loading) || undefined
}
style={vertical ? {height: '100%'} : {}}
>
<ReactSlider
onChange={value => {
Expand Down
45 changes: 18 additions & 27 deletions test/IntegrationTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities


class IntegrationTests(unittest.TestCase):
Expand All @@ -20,11 +21,13 @@ def setUpClass(cls):
super(IntegrationTests, cls).setUpClass()

options = Options()
capabilities = DesiredCapabilities.CHROME
capabilities['loggingPrefs'] = {'browser': 'SEVERE'}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried in vain to find docs for this, did you? If this config does what's needed here that's fine for this PR, I'm just curious if we might like other settings in other cases, to get messages that don't quite rise to the level of SEVERE :rage4:

Copy link
Contributor Author

@Marc-Andre-Rivet Marc-Andre-Rivet Mar 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities#loggingpreferences-json-object

Available values for most loggers are "OFF", "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST", "ALL".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm yeah, I saw that one, but it also says

See the documentation of each driver for what browser specific logging components are available.

Which I was hoping existed somewhere and would tell us something about what kind of messages are included in each level... oh well, trial and error I guess.


if 'DASH_TEST_CHROMEPATH' in os.environ:
options.binary_location = os.environ['DASH_TEST_CHROMEPATH']

cls.driver = webdriver.Chrome(chrome_options=options)
cls.driver = webdriver.Chrome(options=options, desired_capabilities=capabilities)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Settings to get browser errors

loader = percy.ResourceLoader(
webdriver=cls.driver,
base_url='/assets',
Expand All @@ -47,7 +50,8 @@ def tearDown(self):
requests.get('http://localhost:8050/stop')
else:
self.server_process.terminate()
self.driver.back()

self.clear_log()
time.sleep(1)

def startServer(self, app):
Expand Down Expand Up @@ -103,28 +107,15 @@ def _stop_server_windows():
# Visit the dash page
self.driver.get('http://localhost:8050')

# Inject an error and warning logger
logger = '''
window.tests = {};
window.tests.console = {error: [], warn: [], log: []};

var _log = console.log;
var _warn = console.warn;
var _error = console.error;

console.log = function() {
window.tests.console.log.push({method: 'log', arguments: arguments});
return _log.apply(console, arguments);
};

console.warn = function() {
window.tests.console.warn.push({method: 'warn', arguments: arguments});
return _warn.apply(console, arguments);
};

console.error = function() {
window.tests.console.error.push({method: 'error', arguments: arguments});
return _error.apply(console, arguments);
};
'''
self.driver.execute_script(logger)
def clear_log(self):
entries = self.driver.get_log("browser")

if entries:
self.last_timestamp = entries[-1]["timestamp"]

def get_log(self):
entries = self.driver.get_log("browser")

return [entry for entry in entries if entry["timestamp"] > self.last_timestamp]

last_timestamp = 0
28 changes: 28 additions & 0 deletions test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,34 @@ def test_upload_gallery(self):

self.snapshot('test_upload_gallery')

def test_vertical_slider(self):
app = dash.Dash(__name__)

app.layout = html.Div([
html.Label('Vertical Slider'),
dcc.Slider(
id='vertical-slider',
min=0,
max=9,
marks={i: 'Label {}'.format(i) if i == 1 else str(i)
for i in range(1, 6)},
value=5,
vertical=True,
),
], style={'height': '500px'})
self.startServer(app)

self.wait_for_element_by_css_selector('#vertical-slider')
self.snapshot('vertical slider')

v_slider = self.driver.find_element_by_css_selector(
'#vertical-slider div[role="slider"]'
)
v_slider.click()

for entry in self.get_log():
raise Exception('browser error logged during test', entry)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's a message here, something went wrong. Not doing this for all tests as lots of tests have issues at the moment..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this test shouldn't be in the test_gallery test, since that's where most of the snapshots of components are taken. Although, I would rather see the test_gallery test eventually be broken up into specific tests per component, so I guess this is a good start! :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the gallery snapshot approach is a bad idea in general. When I see a diff I want that diff to be isolated and linked to as little dependencies as possible. If the vertical slider breaks, it's obvious. And no wondering if there's multiple issues in the single diff.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed - so many times I've had to look at a diff where something was added in the middle of a long page... and percy has no idea that it's all the same content just shifted down, so I have to try and do that diffing in my head. Much better to break these up into single-purpose images, and not worry about making a huge total number of images.


def test_gallery(self):
app = dash.Dash(__name__)

Expand Down