From 84306ccf3d128024f88e63be104daebbf8bcf955 Mon Sep 17 00:00:00 2001 From: MichaelWest22 Date: Fri, 20 Jun 2025 09:02:11 +1200 Subject: [PATCH] Fix non chrome view transtions tests (#3338) fix non chrome view transitions tests --- test/attributes/hx-swap.js | 29 +++++++++++++++-------------- test/core/api.js | 23 ++++++++++++----------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/test/attributes/hx-swap.js b/test/attributes/hx-swap.js index 6722181d..9f29791d 100644 --- a/test/attributes/hx-swap.js +++ b/test/attributes/hx-swap.js @@ -311,20 +311,21 @@ describe('hx-swap attribute', function() { done() }) - it('works with transition:true', function(done) { - this.server.respondWith('GET', '/test', 'Clicked!') - var div = make( - "
" - ) - div.click() - this.server.respond() - div.innerText.should.equal('') - setTimeout(function() { - div.innerText.should.equal('Clicked!') - done() - }, 30) - }) - + if (/chrome/i.test(navigator.userAgent)) { + it('works with transition:true', function(done) { + this.server.respondWith('GET', '/test', 'Clicked!') + var div = make( + "
" + ) + div.click() + this.server.respond() + div.innerText.should.equal('') + setTimeout(function() { + div.innerText.should.equal('Clicked!') + done() + }, 50) + }) + } it('works with a settle delay', function(done) { this.server.respondWith('GET', '/test', "
") var div = make("
") diff --git a/test/core/api.js b/test/core/api.js index 1447de3d..be4627b5 100644 --- a/test/core/api.js +++ b/test/core/api.js @@ -494,17 +494,18 @@ describe('Core htmx API test', function() { }, 30) }) - it('swap works with a view transition', function(done) { - var div = make("
") - div.innerText.should.equal('') - htmx.swap(div, 'jsswapped', { transition: true }) - div.innerText.should.equal('') - setTimeout(function() { - div.innerText.should.equal('jsswapped') - done() - }, 30) - }) - + if (/chrome/i.test(navigator.userAgent)) { + it('swap works with a view transition', function(done) { + var div = make("
") + div.innerText.should.equal('') + htmx.swap(div, 'jsswapped', { transition: true }) + div.innerText.should.equal('') + setTimeout(function() { + div.innerText.should.equal('jsswapped') + done() + }, 50) + }) + } it('swaps content properly (with select)', function() { var output = make('') htmx.swap('#output', '

Swapped!

', { swapStyle: 'innerHTML' }, { select: '#select-me' })