The problem that I am trying to solve is - 
Say there is a test which has an autocomplete field with data "International Federation of Red Cross and Red Crescent Societies".
This test runs successfully, it fills in "International Federation of Red Cross and Red Crescent Societies (IFRC)" in the field. 
Now, I wish to find the widget used in the form, say in the "default" template. Here, the organisation name is a dropdown. I want the same test to successfully run on both autocomplete and dropdown.

Note that I have given test data as "International Federation of Red Cross and Red Crescent Societies" and it "International Federation of Red Cross and Red Crescent Societies (IFRC)" is present in the dropdown option.

So, here the test will fail just because of missing (IFRC). 

Let len = length("International Federation of Red Cross and Red Crescent Societies")

This commit does the following - 

1. Looks for "International Federation of Red Cross and Red Crescent Societies". (Because this is the longest possible match - exact match - automatically handled by LCS)
2. Looks for "International Federation of Red Cross and Red Crescent Societie" and "nternational Federation of Red Cross and Red Crescent Societies" (because these are the substrings with length = len-1)
3. Looks for substrings with length = len - 2...
... so on.

It stops wherever it gets the best match. (In this case, at step 1).

It is assumed that the test data is written correctly and should match fully with the options field, but with moving development, if some minor changes are added, then the tests would not fail. Eg - This happens with tests with data "Lospalos Warehouse (Warehouse)". In some templates, (Warehouse) might not be present. Also, in SendItem test, "Blankets - Australian Red Cross" is used in the test data whereas "Blankets - 123457 - Australian Red Cross" is present in the options.

SendItem used to pass before, but as I said, with minor changes in the options, this has started to fail.