Skip to content

Commit

Permalink
[fix] Fixed graph visualizer for unpublished topology in admin #169
Browse files Browse the repository at this point in the history
Fixes #169
  • Loading branch information
pandafy committed Jul 7, 2023
1 parent 81c5b05 commit ea2f3c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% load i18n %}

<script>
loadNetJsonGraph = (el='body', url='{{ graph_url }}') => {
const history_url = '{{ history_url }}';
loadNetJsonGraph = (el='body', url='{{ graph_url }}?include_unpublished=true') => {
const history_url = '{{ history_url }}?include_unpublished=true';
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsUrl = `${wsProtocol}//${window.location.host}/ws/network-topology/topology/${getTopologyIdFromUrl()}/`;
const socket = new WebSocket(wsUrl);
Expand Down
8 changes: 8 additions & 0 deletions openwisp_network_topology/tests/test_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ def test_topology_admin_view_graph_visualizer(self):
self.web_driver.find_element(By.CSS_SELECTOR, 'input.visualizelink').click()
self._assert_topology_graph()

def test_unpublished_topology_admin_view_graph_visualizer(self):
self.topology_model.objects.update(published=False)
path = reverse(f'{self.prefix}_topology_change', args=[self.topology.pk])
self.login(username=self.admin_username, password=self.admin_password)
self.open(path)
self.web_driver.find_element(By.CSS_SELECTOR, 'input.visualizelink').click()
self._assert_topology_graph()

def test_topology_non_admin_view_graph_visualizer(self):
path = reverse('topology_list')
self.login(username=self.admin_username, password=self.admin_password)
Expand Down

0 comments on commit ea2f3c2

Please sign in to comment.