MushroomObserver / mushroom-observer

A website for sharing observations of mushrooms.
https://mushroomobserver.org
MIT License
77 stars 25 forks source link

Revise `object_link_helper` class selectors #2142

Closed nimmolo closed 4 months ago

nimmolo commented 4 months ago

TL;DR Use classes, not ids, for links

These link selectors are for system tests, so you never have to use xpath selectors, which can be brittle if HTML is moved around. They're so you can easily get an HTML class name that selects the link.

I've been meaning to make the link helpers in object_link_helper produce the same identifying HTML attributes as elsewhere in the app. (These in object_link_helper were my first draft, and I used id's as selectors, but then discovered the links are not always unique, so I switched to classes with a unique object ID.) This also removes the word "show" from the class name of plain links to the object show page, as elsewhere.

Note that the selector is still "uniquely identifying" for the object link, but does not have to be literally unique, as in cases where there may be some alternative link elsewhere on the page.