mirror of
https://github.com/apache/superset.git
synced 2026-04-24 02:25:13 +00:00
[add] Save filters to dashboard (#3183)
* [add] Save filters to dashboard * format code * fix CI error * add semicolon semi * fix none object * add test data optimize the js code fix the compatibility issue * fix urllib to urllib.parse * add space * update test case * remove 'return' * fix error * update test case
This commit is contained in:
@@ -380,6 +380,42 @@ class CoreTests(SupersetTestCase):
|
||||
resp = self.get_resp(url, data=dict(data=json.dumps(data)))
|
||||
self.assertIn("SUCCESS", resp)
|
||||
|
||||
def test_save_dash_with_filter(self, username='admin'):
|
||||
self.login(username=username)
|
||||
dash = db.session.query(models.Dashboard).filter_by(
|
||||
slug="world_health").first()
|
||||
positions = []
|
||||
for i, slc in enumerate(dash.slices):
|
||||
d = {
|
||||
'col': 0,
|
||||
'row': i * 4,
|
||||
'size_x': 4,
|
||||
'size_y': 4,
|
||||
'slice_id': '{}'.format(slc.id)}
|
||||
positions.append(d)
|
||||
|
||||
filters = {str(dash.slices[0].id): {'region': ['North America']}}
|
||||
default_filters = json.dumps(filters)
|
||||
data = {
|
||||
'css': '',
|
||||
'expanded_slices': {},
|
||||
'positions': positions,
|
||||
'dashboard_title': dash.dashboard_title,
|
||||
'default_filters': default_filters
|
||||
}
|
||||
|
||||
url = '/superset/save_dash/{}/'.format(dash.id)
|
||||
resp = self.get_resp(url, data=dict(data=json.dumps(data)))
|
||||
self.assertIn("SUCCESS", resp)
|
||||
|
||||
updatedDash = db.session.query(models.Dashboard).filter_by(
|
||||
slug="world_health").first()
|
||||
new_url = updatedDash.url
|
||||
self.assertIn("region", new_url)
|
||||
|
||||
resp = self.get_resp(new_url)
|
||||
self.assertIn("North America", resp)
|
||||
|
||||
def test_save_dash_with_dashboard_title(self, username='admin'):
|
||||
self.login(username=username)
|
||||
dash = (
|
||||
|
||||
Reference in New Issue
Block a user