Skip to content

Commit c237ebb

Browse files
committed
Fix jest tests
1 parent 052b90c commit c237ebb

3 files changed

Lines changed: 152 additions & 125 deletions

File tree

client/dist/queuedjobs-admin.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/queuedjobs-admin.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @author Ed Wilde
99
* @version 1.0.0
1010
*/
11+
/* global jQuery */
1112
(function() {
1213
'use strict';
1314

@@ -50,12 +51,12 @@
5051
// SilverStripe CMS uses jQuery PJAX, so we need multiple event listeners
5152
document.addEventListener('pjax:end', () => this.setup());
5253
window.addEventListener('cms-content-loaded', () => this.setup());
53-
54+
5455
// Also listen on jQuery if available (SilverStripe uses jQuery PJAX)
5556
if (typeof jQuery !== 'undefined') {
5657
jQuery(document).on('pjax:end', () => this.setup());
5758
}
58-
59+
5960
// Periodically check if button needs to be created (fallback)
6061
// This handles cases where events don't fire reliably
6162
setInterval(() => {
@@ -116,20 +117,20 @@
116117
* Insert the button immediately before the filter button.
117118
* Handles different DOM structures that may occur during GridField updates.
118119
* Hides button if filter area is open (no filter button visible).
119-
*
120+
*
120121
* @param {HTMLElement} button - The button element to insert
121122
*/
122123
insertButtonBeforeFilter(button) {
123124
const filterButton = document.querySelector('button[name="showFilter"], .grid-field__filter-open');
124125
const gridField = document.querySelector('.ss-gridfield, .grid-field');
125-
126+
126127
if (!filterButton) {
127128
// Check if filter is open (has show-filter class)
128129
if (gridField && gridField.classList.contains('show-filter')) {
129130
// Filter is open, hide our button
130131
button.style.display = 'none';
131132
// Still need to insert it somewhere to keep reference
132-
const toolbar = document.querySelector('.cms-content-toolbar') ||
133+
const toolbar = document.querySelector('.cms-content-toolbar') ||
133134
document.querySelector('.cms-content-header');
134135
if (toolbar) {
135136
toolbar.appendChild(button);
@@ -192,11 +193,11 @@
192193
const form = document.querySelector('.queuedjobs-live-enabled');
193194
if (!form) return;
194195

195-
const observer = new MutationObserver((mutations) => {
196+
const observer = new MutationObserver(() => {
196197
const button = document.querySelector('.queuedjobs-live-toggle');
197198
const filterButton = document.querySelector('button[name="showFilter"], .grid-field__filter-open');
198199
const gridField = document.querySelector('.ss-gridfield, .grid-field');
199-
200+
200201
if (!button) {
201202
// Button was removed, re-create it
202203
this.createToggleButton();
@@ -207,7 +208,7 @@
207208
} else {
208209
// Check if filter is open/closed
209210
const filterIsOpen = gridField && gridField.classList.contains('show-filter');
210-
211+
211212
if (filterIsOpen && !filterButton) {
212213
// Filter is open, hide button
213214
button.style.display = 'none';
@@ -313,7 +314,7 @@
313314

314315
// Fade out (100ms transition)
315316
icon.style.opacity = '0';
316-
317+
317318
// Wait for fade out (100ms) + pause (200ms) before changing content
318319
setTimeout(() => {
319320
if (this.isPolling) {
@@ -329,16 +330,16 @@
329330
this.toggleButton.setAttribute('aria-label', 'Toggle auto-refresh. Currently stopped.');
330331
this.toggleButton.setAttribute('aria-pressed', 'false');
331332
}
332-
333+
333334
// Update transition for fade in
334335
icon.style.transition = 'opacity 0.15s ease';
335-
336+
336337
// Trigger reflow to ensure transition applies
337338
void icon.offsetHeight;
338-
339+
339340
// Fade in (150ms transition)
340341
icon.style.opacity = '1';
341-
342+
342343
// Reset transition back to default after fade in completes
343344
setTimeout(() => {
344345
icon.style.transition = '';
@@ -494,7 +495,7 @@
494495
notification.className = 'queuedjobs-live-notification';
495496
notification.setAttribute('role', 'alert');
496497
notification.setAttribute('aria-live', 'assertive');
497-
498+
498499
const messageSpan = document.createElement('span');
499500
messageSpan.textContent = message;
500501
notification.appendChild(messageSpan);

0 commit comments

Comments
 (0)