1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 00:46:05 +00:00

feat(operations): job panel on the VM page

This commit is contained in:
catborise 2026-10-13 19:59:19 +03:00
parent 9c125aedd2
commit 9c7943a0c8
10 changed files with 469 additions and 13 deletions

View file

@ -130,6 +130,21 @@ class PageControlsTestCase(PageControls, TestCase):
| {"clone", "snapshots", "console settings", "destroy", "host links"},
)
def test_the_job_panel_gets_the_jobs_just_submitted_once(self):
superuser = get_user_model().objects.create_superuser("ctl_jobs", "ctl_jobs@example.com", "x")
self.client.force_login(superuser)
session = self.client.session
other = {"resource": "instance:aaaaaaaa-bbbb-cccc-0000-111111111111", "id": "4343"}
session["operations_shown"] = [{"resource": f"instance:{self.instance.uuid}", "id": "4242"}, other]
session.save()
self.controls(superuser)
self.assertIn('["4242"]', self.last_page)
self.assertNotIn('"4343"', self.last_page)
# a job remembered for another VM waits for that VM's page
self.assertEqual(self.client.session["operations_shown"], [other])
self.controls(superuser)
self.assertNotIn('"4242"', self.last_page)
def test_global_viewers_see_nothing_to_act_on(self):
perms = ("view_instances", "clone_instances", "snapshot_instances")
for user in (self.user("ctl_viewer", perms=perms), self.user("ctl_staff", staff=True, perms=perms)):

View file

@ -191,9 +191,13 @@ class SnapshotTabTestCase(TestCase):
self.assertFalse(self.page(status=1).xpath("//input[@name='memory']")[0].get("disabled"))
self.assertIsNotNone(self.page(status=5).xpath("//input[@name='memory']")[0].get("disabled"))
def test_a_running_job_shows_progress_and_disables_actions(self):
def test_a_running_job_disables_actions(self):
# its progress shows in the job panel, not in the tab; the tab says why the actions are off
line = "A disk job is running on this VM; snapshot actions are unavailable until it ends."
doc = self.page(external=[self.snap("e")], jobs=[{"dev": "vda", "cur": 1, "end": 4}])
self.assertIn("vda 25%", doc.text_content())
self.assertIn(line, doc.text_content())
self.assertNotIn("vda 25%", doc.text_content())
self.assertNotIn(line, self.page(external=[self.snap("e")]).text_content())
self.assertTrue(all(b.get("disabled") is not None
for b in doc.xpath("//div[@id='snapshots']//button[@type='submit']")))