These tests are designed to give 100% coverage to the App._on_remove method,
which is the heart of the widget removal system. This is done in
anticipation to some reworking as part of #1094.
Note that, for the moment, there's a bit of a hack in here. These tests need
the pilot. The pilot would need that we await changes to the DOM. Removing
things from the DOM changes the DOM. Remove can't be awaited (see above
change that's coming). So... until such a time as we can await a remove, we
go with a simple await of asyncio.sleep to get things started.
Once #1094 has been done these tests should all still work fine *and* we
should be able to await the removes rather than use the sleeps.
This finishes off the work to make the loop-free query request to remove
objects work as fast as possible. Removing widgets with that query method
should be more or less as fast as removing a container for the same number
of widgets.
See https://github.com/Textualize/textual/discussions/1110 for some context.
As well as dropping `self` from the list that DOMNode.ancestors provides,
this commit also adds DOMNode.ancestors_with_self, which maintains the
previous behaviour of DOMNode.ancestors.
Because some changes are going to be made to the way that removal of widgets
happens, and because this will affect the linkage between parents and
children, and because we don't want the current way of working to change...
extend to the tests to be sure that when an unmount happens a widget has no
children any more, but still knows about its parent.
This commit sets things up so that a list of widgets can be used, but also
then goes on to ignore the fact that there is a list, only removing the
first one in the list. That's a feature, not a but -- here I'm just testing
that we can make this move and nothing breaks. Next up is to allow removing
all of the widgets while holding off on any layout refresh until all
removals have been performed.