Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
467a128
on dashboard api calls - take the id from the beginning of the slug, …
Aug 15, 2019
1e818f6
add dashboard id when showing links to dashboards
Aug 15, 2019
90ef7cc
change path to include new name when renaming dashboards
Aug 15, 2019
8392126
Merge branch 'master' into id-and-slug-for-dashboards
Aug 17, 2019
aba6e3b
move slug generation to backend
Aug 18, 2019
0ae13b0
redirect to new name after changing (this time with a proper promise)
Aug 18, 2019
0783351
oh right, we already have a slug function
Aug 18, 2019
1aedc44
add spec that makes sure that renamed dashboards are redirected to the
Aug 18, 2019
b7a7a55
use id-slug in all Cypress specs
Aug 19, 2019
a851402
move dashboards from /dashboard/:slug to /dashboards/:id-:name_as_slug
Aug 19, 2019
75b71d7
Merge branch 'master' into id-and-slug-for-dashboards
gabrieldutra Jun 26, 2020
6ea5b97
Update dashboard url as its name changes
gabrieldutra Jun 26, 2020
8e5f491
Update separator to be "/"
gabrieldutra Jun 26, 2020
3f47fb8
Update missing dashboard urls
gabrieldutra Jun 26, 2020
2649292
Update api not to depend on int id
gabrieldutra Jun 26, 2020
59a9143
Use '-' instead of '/' as separator and update Dashboard.get calls
gabrieldutra Jun 30, 2020
169200e
slug -> name_as_slug
gabrieldutra Jun 30, 2020
1c9bbbe
Keep slug urls on cypress
gabrieldutra Jun 30, 2020
2cf590b
Update route path
gabrieldutra Jul 1, 2020
49482d9
Use legacy attr for GET
gabrieldutra Jul 2, 2020
52041a3
Use getter for urlForDashboard
gabrieldutra Jul 2, 2020
2ccc4c1
Update dashboard url when loaded by slug
gabrieldutra Jul 2, 2020
08c14de
Update Dashboard routes to use id instead of slug
gabrieldutra Jul 2, 2020
d7728d1
Update Dashboard handler tests
gabrieldutra Jul 2, 2020
d166069
Update Cypress tests
gabrieldutra Jul 3, 2020
210a755
Merge branch 'master' into id-and-slug-for-dashboards
gabrieldutra Jul 3, 2020
7a8cb0e
Fix create new dashboard spec
gabrieldutra Jul 3, 2020
0957129
Merge branch 'master' into id-and-slug-for-dashboards
gabrieldutra Jul 6, 2020
eb82583
Use axios { params }
gabrieldutra Jul 6, 2020
fd26a9f
Drop Ternary operator
gabrieldutra Jul 13, 2020
6e68b91
Send updated slug directly in 'slug' attr
gabrieldutra Jul 13, 2020
2de74b3
Merge branch 'master' into id-and-slug-for-dashboards
gabrieldutra Jul 13, 2020
cd867a7
Update multiple urls Dashboard test name
gabrieldutra Jul 13, 2020
212d4b4
Update route names
gabrieldutra Jul 13, 2020
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
Prev Previous commit
Next Next commit
Update Dashboard handler tests
  • Loading branch information
gabrieldutra committed Jul 2, 2020
commit d7728d1db06a567384d0bb1805de50f3b6afcac3
20 changes: 15 additions & 5 deletions tests/handlers/test_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,17 @@ def test_search_term(self):
class TestDashboardResourceGet(BaseTestCase):
def test_get_dashboard(self):
d1 = self.factory.create_dashboard()
rv = self.make_request("get", "/api/dashboards/{0}".format(d1.slug))
rv = self.make_request("get", "/api/dashboards/{0}".format(d1.id))
self.assertEqual(rv.status_code, 200)

expected = serialize_dashboard(d1, with_widgets=True, with_favorite_state=False)
actual = json_loads(rv.data)

self.assertResponseEqual(expected, actual)

def test_get_dashboard_with_slug(self):
d1 = self.factory.create_dashboard()
rv = self.make_request("get", "/api/dashboards/{0}?legacy".format(d1.slug))
self.assertEqual(rv.status_code, 200)

expected = serialize_dashboard(d1, with_widgets=True, with_favorite_state=False)
Expand All @@ -76,13 +86,13 @@ def test_get_dashboard_filters_unauthorized_widgets(self):
dashboard.layout = "[[{}, {}]]".format(widget.id, restricted_widget.id)
db.session.commit()

rv = self.make_request("get", "/api/dashboards/{0}".format(dashboard.slug))
rv = self.make_request("get", "/api/dashboards/{0}".format(dashboard.id))
self.assertEqual(rv.status_code, 200)
self.assertTrue(rv.json["widgets"][0]["restricted"])
self.assertNotIn("restricted", rv.json["widgets"][1])

def test_get_non_existing_dashboard(self):
rv = self.make_request("get", "/api/dashboards/not_existing")
rv = self.make_request("get", "/api/dashboards/-1")
Copy link
Member

@gabrieldutra gabrieldutra Jul 3, 2020

Choose a reason for hiding this comment

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

This actually doesn't happen only to the dashboard, but anything that's /api/resource/not_a_number causes a sqlalchemy error. This PR didn't feel like a scope to fix it and at least now I don't have an idea on how to solve this as it turned to be a dynamic thing.

self.assertEqual(rv.status_code, 404)


Expand Down Expand Up @@ -156,10 +166,10 @@ class TestDashboardResourceDelete(BaseTestCase):
def test_delete_dashboard(self):
d = self.factory.create_dashboard()

rv = self.make_request("delete", "/api/dashboards/{0}".format(d.slug))
rv = self.make_request("delete", "/api/dashboards/{0}".format(d.id))
self.assertEqual(rv.status_code, 200)

d = Dashboard.get_by_slug_and_org(d.slug, d.org)
d = Dashboard.get_by_id_and_org(d.id, d.org)
self.assertTrue(d.is_archived)


Expand Down