|
Description
Kyle M Hall (khall)
2025-10-16 23:09:22 UTC
Created attachment 188063 [details] [review] Bug 41039: Prevent patron search button from being spammed triggering multiple api requests Every click of the "Search" button on members/members-home.pl or other area that utilizes patrons searching, will trigger another patron search api request. This button should be disabled until the first searches results are displayed. To demonstrate, open the network tab of the developer console on your web browser. Note each click if the button show another patron search api request. Test Plan: 1) Browse to members-home.pl 2) Open the network tab of the developer console on your web browser 3) Double click the Search button 4) Note the two api requests in the network tab 5) Apply this patch 6) Reload the page 7) Double click the Search button 8) Note only one api request is made If your results come back too fast, you may perform an initial search, then change the number of results from the default 20 to "All" to create a search that will take longer. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Created attachment 188123 [details] [review] Bug 41039: Prevent patron search button from being spammed triggering multiple api requests Every click of the "Search" button on members/members-home.pl or other area that utilizes patrons searching, will trigger another patron search api request. This button should be disabled until the first searches results are displayed. To demonstrate, open the network tab of the developer console on your web browser. Note each click if the button show another patron search api request. Test Plan: 1) Browse to members-home.pl 2) Open the network tab of the developer console on your web browser 3) Double click the Search button 4) Note the two api requests in the network tab 5) Apply this patch 6) Reload the page 7) Double click the Search button 8) Note only one api request is made If your results come back too fast, you may perform an initial search, then change the number of results from the default 20 to "All" to create a search that will take longer. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> I needed to put it in "Need Signoff" to then go to "Signed off". Sorry! Shouldn't we use preventDoubleFormSubmit here? (In reply to Jonathan Druart from comment #4) > Shouldn't we use preventDoubleFormSubmit here? I don't think that code works here because this is an ajax based search, so the doesn't reload after results are returned. (In reply to Kyle M Hall (khall) from comment #5) > (In reply to Jonathan Druart from comment #4) > > Shouldn't we use preventDoubleFormSubmit here? > > I don't think that code works here because this is an ajax based search, so > the doesn't reload after results are returned. Indeed sorry, silly idea. Test plan doesn't include tests for other places like http://localhost:8081/cgi-bin/koha/reserve/request.pl?biblionumber=29 but it does appear to work there too Created attachment 188191 [details] [review] Bug 41039: Prevent patron search button from being spammed triggering multiple api requests Every click of the "Search" button on members/members-home.pl or other area that utilizes patrons searching, will trigger another patron search api request. This button should be disabled until the first searches results are displayed. To demonstrate, open the network tab of the developer console on your web browser. Note each click if the button show another patron search api request. Test Plan: 1) Browse to members-home.pl 2) Open the network tab of the developer console on your web browser 3) Double click the Search button 4) Note the two api requests in the network tab 5) Apply this patch 6) Reload the page 7) Double click the Search button 8) Note only one api request is made If your results come back too fast, you may perform an initial search, then change the number of results from the default 20 to "All" to create a search that will take longer. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> Signed-off-by: David Cook <dcook@prosentient.com.au> We need Cypress or Selenium tests here. (In reply to Jonathan Druart from comment #9) > We need Cypress or Selenium tests here. Yeah, that thought crossed my mind. You're right. I wonder how best do that in this case. Wondering if we need to mock an endpoint to produce a delayed response so we can detect the disabled button? (In reply to David Cook from comment #10) > (In reply to Jonathan Druart from comment #9) > > We need Cypress or Selenium tests here. > > Yeah, that thought crossed my mind. You're right. I wonder how best do that > in this case. Wondering if we need to mock an endpoint to produce a delayed > response so we can detect the disabled button? I would try the easy way: Click "search", wait for the button to be disabled, then wait for the button to be enabled, then eventually click "search" again. Cypress is fast and the button should be disabled before we get the response. Run it in a loop to make sure it won't fail randomly. Created attachment 189031 [details] [review] Bug 41039: Prevent patron search button from being spammed triggering multiple api requests Every click of the "Search" button on members/members-home.pl or other area that utilizes patrons searching, will trigger another patron search api request. This button should be disabled until the first searches results are displayed. To demonstrate, open the network tab of the developer console on your web browser. Note each click if the button show another patron search api request. Test Plan: 1) Browse to members-home.pl 2) Open the network tab of the developer console on your web browser 3) Double click the Search button 4) Note the two api requests in the network tab 5) Apply this patch 6) Reload the page 7) Double click the Search button 8) Note only one api request is made If your results come back too fast, you may perform an initial search, then change the number of results from the default 20 to "All" to create a search that will take longer. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> Signed-off-by: David Cook <dcook@prosentient.com.au> Created attachment 189032 [details] [review] Bug 41039: Add cypress tests Patch from commit 2fcd87f Every click of the "Search" button on members/members-home.pl or other area that utilizes patrons searching, will trigger another patron search api request. This button should be disabled until the first searches results are displayed. To demonstrate, open the network tab of the developer console on your web browser. Note each click if the button show another patron search api request. Test Plan: 1) Browse to members-home.pl 2) Open the network tab of the developer console on your web browser 3) Double click the Search button 4) Note the two api requests in the network tab 5) Apply this patch 6) Reload the page 7) Double click the Search button 8) Note only one api request is made If your results come back too fast, you may perform an initial search, then change the number of results from the default 20 to "All" to create a search that will take longer. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> Signed-off-by: David Cook <dcook@prosentient.com.au> Created attachment 189649 [details] [review] Bug 41039: Prevent patron search button from being spammed triggering multiple api requests Every click of the "Search" button on members/members-home.pl or other area that utilizes patrons searching, will trigger another patron search api request. This button should be disabled until the first searches results are displayed. To demonstrate, open the network tab of the developer console on your web browser. Note each click if the button show another patron search api request. Test Plan: 1) Browse to members-home.pl 2) Open the network tab of the developer console on your web browser 3) Double click the Search button 4) Note the two api requests in the network tab 5) Apply this patch 6) Reload the page 7) Double click the Search button 8) Note only one api request is made If your results come back too fast, you may perform an initial search, then change the number of results from the default 20 to "All" to create a search that will take longer. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> Signed-off-by: David Cook <dcook@prosentient.com.au> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Created attachment 189650 [details] [review] Bug 41039: Add cypress tests Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Nice work everyone! Pushed to main for 25.11 Nice work everyone! Pushed to 25.05.x |