Generate random IDs for internal elements
As part of the PiT for 23.2, we identified an issue related to Selenium tests, where an automated test recording tool used internally generated element IDs as selector. After changing the logic of the ID generation these tests broke.
As these IDs are in general not reliable / consistent for automated testing purposes we might want to communicate this better by using random, or more randomly looking, IDs. Currently we use increasing numbers as IDs which makes them seem stable in between test runs. Instead we could use or adopt code from some package that can generate some random ID. Another idea that might be to generate a hash code from an increasing number that starts from a random offset.
One concern that was raised was how to deal with tests (for example snapshot tests) where we rely on consistent IDs ourselves. This should be solvable by resetting the random ID generator to the same state before a test run, for example by initializing it with the same seed.
how to deal with tests (for example snapshot tests) where we rely on consistent IDs ourselves
We could try to mock the unique-id-utils.js with import maps, using @web/dev-server-import-maps plugin.