Fix dynamic formset prefix on staff questionnaire form#2745
Conversation
There was a problem hiding this comment.
Again, is there something we can meaningfully test here? For this one I am learning more towards "this just has to work", but we manged to not catch this once in review, so I don't know
There was a problem hiding this comment.
On the bright side, at least the AI also didn't catch this, so we can all sleep tight :^)
There was a problem hiding this comment.
If we want a test to ensure this doesn't stop working, I think live/frontend test, re-order, assert "order" field in database is what we should do. Should be doable in ~10ish lines, assuming it's somewhat possible to simulate a drag+drop for reordering in Selenium.
|
So I wrote a frontend test which moves them using the nice So turns out that this whole dragging thing is still absolutely broken, and not just in selenium but in the official webdriver interface. See https://redirect.github.com/w3c/webdriver/issues/1488 and https://redirect.github.com/SeleniumHQ/selenium/issues/12525 I will just revert to the easy test case :( |
| add_another.click() | ||
| add_another.click() | ||
| add_another.click() |
There was a problem hiding this comment.
Is there any reason why you click three times on the button? I would think once should be enough or do you try to trigger something else?
There was a problem hiding this comment.
Just simulating my personal interaction with the site :D
The real reason is that I wanted to check what happens if there are empty rows at the end and inbetween (notice that I use rows 5 and 7 instead of 5 and 6 below)
Closes #2742
Ough, this was annoying to debug (see the issue). So the problem is that the underlying ids changed so our call to
makeFormSortablepassed the wrong prefix which meant that the dynamic formset code did not identify the numbering in the form field ids correctly and kept generating rows with the same ids. For some reason, our backend just ignored the fact that it received an array of values where it expected only a single one and decided to just sweep all but one value under the table.I also changed the
makeFormSortablecallback to remove theform-templateclass from newly created rows because the template we use stays in place and the rows are not the template, although I think that the dynamic formset code queries the template node only once in the beginning, otherwise we would be seeing rows with duplicate values created in all kinds of places.