Bug 38461: Fix random failures

All this is weird.
I found this and implemented it:
https://stackoverflow.com/questions/69425289/javascript-prompt-cause-document-is-not-focused
It was still not enough to reduce the failures.
The wait and adding the focus to the window seems ok.
If I remove one of those 3 hacks, I still get failures...

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit aab60455b5)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Jonathan Druart 2024-11-28 11:25:03 +01:00 committed by Paul Derscheid
parent 5f3c15600c
commit 325d88f3ce
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
2 changed files with 8 additions and 2 deletions

View File

@ -728,6 +728,10 @@ function _dt_buttons(params){
);
if ( table_settings ) {
const writeToClipboard= async (text, node) => {
await navigator.clipboard.writeText(text);
$(node).tooltip({trigger: 'manual', title: __("Copied!")}).tooltip('show');
};
buttons.push(
{
autoClose: true,
@ -745,10 +749,10 @@ function _dt_buttons(params){
delete state.time;
let searchParams = new URLSearchParams(window.location.search);
searchParams.set(table_key + '_state', btoa(state));
let url = window.location.origin + window.location.pathname + '?' + searchParams.toString() + window.location.hash;
if( navigator.clipboard && navigator.clipboard.writeText){
navigator.clipboard.writeText( url );
$(node).tooltip({trigger: 'manual', title: __("Copied!")}).tooltip('show');
writeToClipboard(url, node);
}
},
}

View File

@ -268,8 +268,10 @@ describe("kohaTable (using REST API)", () => {
// Close the 'Columns' list
cy.get(".dt-button-background").click();
cy.get(".dt-button-background").should("not.exist");
cy.wait(500); // ensure the animation completes, random failures?
// Copy the shareable link (Name and Code shown)
cy.window().focus();
cy.get(
`#${table_id}_wrapper .copyConditions_controls`
).click({ force: true });