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

fix(tags): three tags and "…" on the host's VM list too

The host's VM list showed every tag of a VM, widening its Name column as
the VM list did before; it now shows three and the others behind "…".
There its tags are not buttons: the tags "…" shows take the focus, so a
keyboard user is not sent back to the top of the page.
This commit is contained in:
catborise 2026-11-19 08:29:40 +03:00
parent 65b8110464
commit 6680e14ce4
5 changed files with 22 additions and 5 deletions

View file

@ -163,6 +163,10 @@ assert.deepStrictEqual(visible(turkish), ["Şişli"]);
const ellipsis = {hidden: false, nextElementSibling: others};
listeners.click({target: {closest: (s) => (s === "[data-show-tags]" ? ellipsis : null)}});
assert.deepStrictEqual([others.hidden, ellipsis.hidden, focused], [false, true, "d4"]);
// tags that are not buttons (no tag list on the page): the tags shown take it
const plain = {hidden: true, querySelector: () => null, focus: () => { focused = "plain"; }};
listeners.click({target: {closest: (s) => (s === "[data-show-tags]" ? {hidden: false, nextElementSibling: plain} : null)}});
assert.strictEqual(focused, "plain");
}
// a kept tag the list no longer has is forgotten: made again later, it is not chosen by itself

View file

@ -92,6 +92,18 @@ class VmTagsTests(TestCase):
self.assertContains(self.client.get(reverse("instances", args=[self.vm.compute_id])), "prod")
self.assertContains(self.client.get(reverse("accounts:account", args=[self.owner.id])), "prod")
def test_the_host_s_vm_list_shows_three_and_the_others_behind_an_ellipsis(self):
self.vm.tags.add(*(Tag.objects.create(name=name) for name in ("a1", "b2", "c3", "d4")))
self.client.force_login(self.admin)
with patch("computes.views.utils.refresh_instance_database"), patch("computes.views.vm_states", return_value={}), \
patch("computes.views.read_list_rows"):
page = lxml_html.fromstring(self.client.get(reverse("instances", args=[self.vm.compute_id])).content)
self.assertEqual(page.xpath("//td//span[contains(@class,'tag-badge')][not(ancestor::*[@hidden])]/text()[last()]"),
[" a1", " b2", " c3"])
self.assertEqual(page.xpath("//button[@data-show-tags]/@title"), ["d4"])
# the tags "…" shows take the focus from it (table_filter.js), not buttons here
self.assertEqual(page.xpath("//button[@data-show-tags]/following-sibling::span[1]/@tabindex"), ["-1"])
def test_the_vm_list_shows_them(self):
self.vm.tags.add(Tag.objects.create(name="prod"))
html = render_to_string("instance_name_cell.html", {"instance": self.vm})