Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review dropdown filter behavior for Ticket owner dropdown #3563

Closed
stefanhaerter opened this issue Jul 2, 2024 · 10 comments · Fixed by #4036
Closed

Review dropdown filter behavior for Ticket owner dropdown #3563

stefanhaerter opened this issue Jul 2, 2024 · 10 comments · Fixed by #4036
Assignees
Labels
unittests Requests wrt unittests
Milestone

Comments

@stefanhaerter
Copy link
Contributor

In unit tests scripts/test/Selenium/Agent/AgentTicketActionCommon/AgentTicketOwner.t and scripts/test/Selenium/Agent/AgentTicketZoom.t, a failure can be observed when a new ticket owner is to be set. Assumption is that both failures are related to the same issue.

Additional observation: When using the dropdown filter manually via GUI, it works, but it does not when triggering a click event via Selenium test.

@stefanhaerter stefanhaerter added bug Something isn't working as intended unittests Requests wrt unittests labels Jul 2, 2024
@stefanhaerter stefanhaerter added this to the OTOBO 11.0.4 milestone Jul 2, 2024
@stefanhaerter
Copy link
Contributor Author

See #3100 for more context

@bschmalhofer bschmalhofer mentioned this issue Jul 2, 2024
12 tasks
@svenoe svenoe modified the milestones: OTOBO 11.0.4, OTOBO 11.0.5 Jul 29, 2024
@svenoe svenoe modified the milestones: OTOBO 11.0.5, OTOBO 11.0.6 Aug 5, 2024
@svenoe svenoe removed the bug Something isn't working as intended label Sep 25, 2024
@svenoe svenoe modified the milestones: OTOBO 11.0.6, OTOBO 11.0.7 Sep 25, 2024
@svenoe svenoe modified the milestones: OTOBO 11.0.7, OTOBO 11.0.8 Oct 22, 2024
@stefanhaerter stefanhaerter self-assigned this Oct 24, 2024
@stefanhaerter
Copy link
Contributor Author

So far, the investigation showed: The click via GUI is indeed treated differently than triggering the click event via javascript. This can be observed via console.trace() at a fitting location in var/httpd/htdocs/js/Core.UI.InputFields.js. The mechanism in the GUI involves focus on the search field, as far as I could manage to find out.

@MichaelThumes
Copy link
Contributor

Re: AgentTicketOwner.t

this looks promising:

diff --git a/scripts/test/Selenium/Agent/AgentTicketActionCommon/AgentTicketOwner.t b/scripts/test/Selenium/Agent/AgentTicketActionCommon/AgentTicketOwner.t
index 1a3419452..5b03d7e71 100644
--- a/scripts/test/Selenium/Agent/AgentTicketActionCommon/AgentTicketOwner.t
+++ b/scripts/test/Selenium/Agent/AgentTicketActionCommon/AgentTicketOwner.t
@@ -206,9 +206,11 @@ $Selenium->RunTest(
             "Out of office message is found for the user $TestUser[1]"
         );
 
-        # Change ticket owner by clicking.
-        # TODO: this does not actually select the user 1 and the test script fails
-        $UserSelectionElement->execute_script(q{ $(arguments[0]).click() });
+        # Change ticket owner by fakeing a click.
+        # simple click does not work due to lazy loading
+
+        my $UserSelectionElementForValueSet =  $Selenium->find_element( qq{#NewOwnerID}, 'css' );
+        $UserSelectionElementForValueSet->execute_script(qq{ arguments[0].value="$UserID[1]"; });
 
         $Selenium->find_element( "#Subject",        'css' )->send_keys('Test');
         $Selenium->find_element( "#RichText",       'css' )->send_keys('Test');

Not super-happy but it makes the test green, and as all my attempts to somehow trigger the lazy load from Selenium failed...

Didn't find time to look into AgentTicketZoom.t yet, looking forward to do so.

@stefanhaerter
Copy link
Contributor Author

Looks great, thank you for taking the time!

@bschmalhofer
Copy link
Contributor

I think that the better solution is to use the click() method on the filter checkbox. I try to prepare a patch,

@stefanhaerter
Copy link
Contributor Author

I remember trying out a few things around the click() method, but not exactly which - only that none of my tests worked, so I discarded them.

bschmalhofer added a commit that referenced this issue Dec 16, 2024
Use the click() method that actually updates the list of owners.
Do not rely on clicking on the wanted owner, set the value of the
selection directly.
@bschmalhofer
Copy link
Contributor

bschmalhofer commented Dec 16, 2024

Yes, using the click() method made the browser output more like the expected output. But actually selecting the owner did still not work. So I propose to use @MichaelThumes 's solution.

Are there objections to applying #3990 ?

@MichaelThumes
Copy link
Contributor

The following would also work on my machine (in the sense of making the test green):

#        my $UserSelectionElementForValueSet =  $Selenium->find_element( qq{#NewOwnerID}, 'css' );
#        $UserSelectionElementForValueSet->execute_script(qq{ arguments[0].value="$UserID[1]"; });

        $UserSelectionElement->execute_script( q{document.querySelector('label[for="NewOwnerID"]').click();} );
        sleep(5);
        $UserSelectionElement->execute_script( q{document.querySelectorAll('#NewOwnerID_Select ul li a')[0].click(); } );
        sleep(5);
        $UserSelectionElement->execute_script( q{document.querySelectorAll('#NewOwnerID_Select ul li a')[0].click(); } );

Not that it makes me any happier - whilst closer to actually testing the UI, it now relies on 'benefits of sleep'. Plus I would have a hard time to explain why this - unlike the 20 or so much more straightforward solutions I tried first - actually works .-(

@bschmalhofer
Copy link
Contributor

@MichaelThumes , yes, I would prefer your latest solution with the three clicks as it is closer to what is happening in the GUI.

@MichaelThumes
Copy link
Contributor

had a look at AgentTicketZoom.t as well

does not look related to me - rather simply html/css changes?. Anyway here comes another candidate:

diff --git a/scripts/test/Selenium/Agent/AgentTicketZoom.t b/scripts/test/Selenium/Agent/AgentTicketZoom.t
index b5f7d2cb0..10f9d0b3c 100644
--- a/scripts/test/Selenium/Agent/AgentTicketZoom.t
+++ b/scripts/test/Selenium/Agent/AgentTicketZoom.t
@@ -312,7 +312,7 @@ $Selenium->RunTest(
         );
 
         # click to sort by article number
-        $Selenium->find_element("//th[\@class='No Sortable tablesorter-header tablesorter-headerUnSorted']")->click();
+        $Selenium->find_element("//div[\@class='tablesorter-header-inner']/a")->click();
 
         # verify change in article order on column header click, test Core.UI.Table.Sort.js
         $Self->Is(

MichaelThumes added a commit that referenced this issue Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unittests Requests wrt unittests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants