[Koha-bugs] [Bug 32010] selenium/authentication_2fa.t is failing randomly

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Nov 2 09:04:52 CET 2022


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32010

--- Comment #7 from Jonathan Druart <jonathan.druart+koha at gmail.com> ---
In my understanding there is a missing wait_for_ajax call at after we click

The test:
279         $driver->find_element('//*[@id="pin_code"]')->clear;
280         $driver->find_element('//*[@id="pin_code"]')->send_keys($pin_code);
281         $driver->find_element('//*[@id="register-2FA"]')->click;
282         is( $driver->get_alert_text,
283             "Two-factor authentication correctly configured. You will be
redirected to the login screen."
284         );
285         $driver->accept_alert;

But wait_for_ajax is waiting for the return of success, and the alert is there.
The code:
250                 $.ajax({
251                     data: data,
252                     type: 'POST',
253                     url:
'/api/v1/auth/two-factor/registration/verification',
254                     success: function (data) {
255                         alert(_("Two-factor authentication correctly
configured. You will be redirected to the login screen."));
256                         window.location = "/cgi-bin/koha/mainpage.pl";
257                     },
258                     error: function (data) {
259                         const error = data.responseJSON.error;
260                         if ( error == 'Invalid pin' ) {
261                             $("#errors").html(_("Invalid PIN
code")).show();
262                         } else {
263                             alert(error);
264                         }
265                     },
266                 });

So either we remove the test, or adjust the code to make the alert appears
after the ajax call is done (which may make the code not very nice).

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list